xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libxl: fix dm destruction when there is no pid
@ 2012-05-03 12:31 Roger Pau Monne
  2012-05-04 17:18 ` Ian Jackson
  0 siblings, 1 reply; 2+ messages in thread
From: Roger Pau Monne @ 2012-05-03 12:31 UTC (permalink / raw)
  To: xen-devel; +Cc: Roger Pau Monne

Fix qemu dm model destruction if the pid in xenstore is 0 (or is not
present).

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
---
 tools/libxl/libxl_dm.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 11de03f..b2bae68 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1081,6 +1081,11 @@ int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid)
 
     pid = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/image/device-model-pid", domid));
     if (!pid) {
+        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't find device model's pid");
+        ret = ERROR_INVAL;
+        goto out;
+    }
+    if (!atoi(pid)) {
         int stubdomid = libxl_get_stubdom_id(ctx, domid);
         const char *savefile;
 
@@ -1122,10 +1127,10 @@ int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid)
             goto out;
         }
     }
-    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid));
-    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/hvmloader", domid));
 
 out:
+    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid));
+    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/hvmloader", domid));
     return ret;
 }
 
-- 
1.7.7.5 (Apple Git-26)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libxl: fix dm destruction when there is no pid
  2012-05-03 12:31 [PATCH] libxl: fix dm destruction when there is no pid Roger Pau Monne
@ 2012-05-04 17:18 ` Ian Jackson
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Jackson @ 2012-05-04 17:18 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel

Roger Pau Monne writes ("[Xen-devel] [PATCH] libxl: fix dm destruction when there is no pid"):
> Fix qemu dm model destruction if the pid in xenstore is 0 (or is not
> present).

Firstly, this needs rewrapping.

Secondly,
>      pid = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/image/device-model-pid", domid));
>      if (!pid) {
> +        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Couldn't find device model's pid");
> +        ret = ERROR_INVAL;
> +        goto out;
> +    }
> +    if (!atoi(pid)) {
>          int stubdomid = libxl_get_stubdom_id(ctx, domid);

This seems to change the logic regarding stubdoms.  Are you sure this
is correct ?  Previously if the entry didn't exist, we took the
stubdom path.

> -    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid));
> -    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/hvmloader", domid));
>  
>  out:
> +    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/0/device-model/%d", domid));
> +    xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(gc, "/local/domain/%d/hvmloader", domid));

While moving this, you might as well rewrap it (or use GCSPRINTF).

Ian.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-04 17:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-03 12:31 [PATCH] libxl: fix dm destruction when there is no pid Roger Pau Monne
2012-05-04 17:18 ` Ian Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).