i386/xen: introduce/release domain to xenstored
We connect to xenstored and can send the INTRODUCE_DOMAIN message with
the pfn and domid. This will allow xenstored to map the domain ring and
channel to serve xenbus (domain) client requests.
xs_read()'s failure is indicated by NULL return value while @len will
report length of error string. If /tool/xenstored/domid mnode does not
exist in xenstore then we assume that Domain-0 is where xenstore is
hosted.
Try to fetch where xenstore domain leaves such that we can create the
unbound ports and seed grant table accordingly.
Finally seed xenstore with the default entries. The entries comprised at
init time (before introduce_domain) and are all domain local paths:
<domain-path>/memory/static-max = <memory-in-kb>
<domain-path>/memory/target = <memory-in-kb>
<domain-path>/memory/videoram = <memory-in-kb>
<domain-path>/domid = <domain-id>
<domain-path>/cpu/<vcpu_id>/availability = (online|offline)
<domain-path>/store/ring-ref = <xenstore-mfn>
<domain-path>/store/port = <xenstore-port>
All of which have r/w permission alongside parent its domain path
(/local/domain/<domid>). When we gracefully shutdown or 'quit' via
HMP/QMP we properly release the domain with the release_domain()
message. Unattended shutdown is handled by xenstored itself and
hypervisor propragating the VIRQ_DOM_EXC interrupt to xenstored.
qemu allocates the SPECIALPAGE_XENSTORE page as a MAP_PRIVATE |
MAP_ANON mapping. The same mapping will be done on xenstored (via
/dev/xen/gntdev) as a MAP_SHARED mapping on the SPECIALPAGE_XENSTORE
grant-entry.
This leads to an interesting breakage of xenstored's rss counter:
BUG: Bad rss-counter state mm:
00000000acd9575d idx:1 val:-1
BUG: Bad rss-counter state mm:
00000000acd9575d idx:3 val:1
Since it seems nonsensical to do a MAP_PRIVATE mapping for a page
that is meant to be shared with a different process, we switch
to a MAP_SHARED | MAP_ANON mapping.
Co-developed-by: Ankur Arora <ankur.a.arora@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>