[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 09/13] xenstore: make use of the "xenstore domain" flag
On Fri, 2015-12-18 at 14:14 +0100, Juergen Gross wrote: > Create the xenstore domain with the xs_domain flag specified. This > enables us to test whether such a domain is already running before > we create it. As there ought to be only one xenstore in the system > we don't need to start another one. > > Signed-off-by: Juergen Gross <jgross@xxxxxxxx> > --- > Âtools/helpers/init-xenstore-domain.c | 25 +++++++++++++++++++++++-- > Â1 file changed, 23 insertions(+), 2 deletions(-) > > diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init- > xenstore-domain.c > index 17f0151..4cd9e0f 100644 > --- a/tools/helpers/init-xenstore-domain.c > +++ b/tools/helpers/init-xenstore-domain.c > @@ -66,7 +66,8 @@ static int build(xc_interface *xch) > ÂÂÂÂÂ} else { > ÂÂÂÂÂÂÂÂÂssid = SECINITSID_DOMU; > ÂÂÂÂÂ} > -ÂÂÂÂrv = xc_domain_create(xch, ssid, handle, 0, &domid, NULL); > +ÂÂÂÂrv = xc_domain_create(xch, ssid, handle, XEN_DOMCTL_CDF_xs_domain, > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ&domid, NULL); > ÂÂÂÂÂif (rv) { > ÂÂÂÂÂÂÂÂÂfprintf(stderr, "xc_domain_create failed\n"); > ÂÂÂÂÂÂÂÂÂgoto err; > @@ -165,6 +166,21 @@ err: > ÂÂÂÂÂreturn rv; > Â} > Â > +static int check_domain(xc_interface *xch) > +{ > +ÂÂÂÂxc_dominfo_t info; > +ÂÂÂÂuint32_t dom; > + > +ÂÂÂÂdom = 0; You can pretty safely skip dom0 I think? > +ÂÂÂÂwhile (xc_domain_getinfo(xch, dom, 1, &info) == 1) { Logging errors (i.e. on return < 0) would be nice I think. > +ÂÂÂÂÂÂÂÂif (info.xs_domain) > +ÂÂÂÂÂÂÂÂÂÂÂÂreturn 1; > +ÂÂÂÂÂÂÂÂdom = info.domid + 1; > +ÂÂÂÂ} > + > +ÂÂÂÂreturn 0; > +} > + > Âint main(int argc, char** argv) > Â{ > ÂÂÂÂÂint opt; > @@ -204,7 +220,12 @@ int main(int argc, char** argv) > ÂÂÂÂÂÂÂÂÂreturn 1; > ÂÂÂÂÂ} > Â > -ÂÂÂÂrv = build(xch); > +ÂÂÂÂrv = check_domain(xch); > + > +ÂÂÂÂif (!rv) > +ÂÂÂÂÂÂÂÂrv = build(xch); > +ÂÂÂÂelse > +ÂÂÂÂÂÂÂÂfprintf(stderr, "xenstore domain already present.\n"); > Â > ÂÂÂÂÂxc_interface_close(xch); > Â _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |