xenstore: destroy xenstore domain in case of error after creating it
authorJuergen Gross <jgross@suse.com>
Mon, 18 Jan 2016 08:03:56 +0000 (09:03 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 18 Jan 2016 16:34:20 +0000 (16:34 +0000)
When creating a xenstore domain via init-xenstore-domain destroy it
in case of an error occurred after calling xc_domain_create().

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/helpers/init-xenstore-domain.c

index 9c47af1ba696ebabbe8d09f71a75a427cad1ac26..a9c5821be481e406584f8d34552b236a120351c1 100644 (file)
@@ -11,7 +11,7 @@
 #include <xenstore.h>
 #include <xen/sys/xenbus_dev.h>
 
-static uint32_t domid = -1;
+static uint32_t domid = ~0;
 
 static int build(xc_interface *xch, int argc, char** argv)
 {
@@ -94,6 +94,8 @@ static int build(xc_interface *xch, int argc, char** argv)
 err:
     if ( dom )
         xc_dom_release(dom);
+    if ( domid != ~0 )
+        xc_domain_destroy(xch, domid);
     close(xs_fd);
     return rv;
 }