WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH]: xl: Check a domain exists before destroying it

On Mon, 2011-01-24 at 17:27 +0000, Christoph Egger wrote:
> > > 7. Too many error information showed when destroy an inexistent guest
> > > (Community) http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=1714
> >
> > A three line fix?
> 
> Already posted to this list:
> http://lists.xensource.com/archives/html/xen-devel/2011-01/msg01452.html

This is quite a clever fix but I think Ian Jacksons comments are
correct. We should do a libxl_domain_info() and bail early in the
destroy path if that fails.

---
xl: Check a domain exists before destroying it

Also fix a mis-formatted error message in xl destroy command.

Signed-off-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>

diff -r b59f04eb8978 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri Jan 21 18:06:23 2011 +0000
+++ b/tools/libxl/libxl.c       Mon Jan 24 17:39:33 2011 +0000
@@ -654,10 +654,21 @@ int libxl_event_get_disk_eject_info(libx
 int libxl_domain_destroy(libxl_ctx *ctx, uint32_t domid, int force)
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
+    libxl_dominfo dominfo;
     char *dom_path;
     char *vm_path;
     int rc, dm_present;
 
+    rc = libxl_domain_info(ctx, &dominfo, domid);
+    switch(rc) {
+    case 0:
+        break;
+    case ERROR_INVAL:
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "non-existant domain %d", domid);
+    default:
+        return rc;
+    }
+
     if (libxl__domain_is_hvm(ctx, domid)) {
         dm_present = 1;
     } else {
diff -r b59f04eb8978 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Jan 21 18:06:23 2011 +0000
+++ b/tools/libxl/xl_cmdimpl.c  Mon Jan 24 17:39:33 2011 +0000
@@ -2176,7 +2176,7 @@ static void destroy_domain(const char *p
         exit(-1);
     }
     rc = libxl_domain_destroy(&ctx, domid, 0);
-    if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n.",rc); exit(-1); }
+    if (rc) { fprintf(stderr,"destroy failed (rc=%d).\n",rc); exit(-1); }
 }
 
 static void shutdown_domain(const char *p, int wait)



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel