diff mbox

[v3,07/15] xenstore: destroy xenstore domain in case of error after creating it

Message ID 1452258526-4797-8-git-send-email-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jürgen Groß Jan. 8, 2016, 1:08 p.m. UTC
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>
---
 tools/helpers/init-xenstore-domain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ian Campbell Jan. 15, 2016, 4:02 p.m. UTC | #1
On Fri, 2016-01-08 at 14:08 +0100, Juergen Gross wrote:
> 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>
diff mbox

Patch

diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
index 9c47af1..a9c5821 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -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;
 }