]> www.infradead.org Git - users/dwmw2/qemu.git/commit
i386/xen: introduce/release domain to xenstored
authorJoao Martins <joao.m.martins@oracle.com>
Fri, 28 Sep 2018 17:10:48 +0000 (13:10 -0400)
committerJoao Martins <joao.m.martins@oracle.com>
Tue, 19 Feb 2019 14:00:57 +0000 (09:00 -0500)
commit8bae96604edc6a91231de3390ca5bff6f99b2f08
tree2a383583deda5a7761aa938cb31e6ca3cc1f178d
parent28d13f5d508e765a8061299873000c43e4c35531
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>
include/exec/memory.h
memory.c
target/i386/cpu.c
target/i386/cpu.h
target/i386/xen-proto.h
target/i386/xen.c