diff mbox

[10/28] libxl: kill_device_model: Silently tolerate ENOENT on pid xs path

Message ID 1450809903-3393-11-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson Dec. 22, 2015, 6:44 p.m. UTC
If the pid is absent in xenstore, this means there is no such DM.  Do
not complain about this, then.  This allows us to simplify call sites.
Do so for libxl__destroy_domid.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v6: New patch.
---
 tools/libxl/libxl.c    |    4 +---
 tools/libxl/libxl_dm.c |    7 ++++++-
 2 files changed, 7 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 5414649..2a0c092 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1606,7 +1606,6 @@  void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis)
     libxl_ctx *ctx = CTX;
     uint32_t domid = dis->domid;
     char *dom_path;
-    char *pid;
     int rc, dm_present;
 
     libxl__ev_child_init(&dis->destroyer);
@@ -1642,8 +1641,7 @@  void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis)
         }
         /* fall through */
     case LIBXL_DOMAIN_TYPE_PV:
-        pid = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("/local/domain/%d/image/device-model-pid", domid));
-        dm_present = (pid != NULL);
+        dm_present = 1;
         break;
     case LIBXL_DOMAIN_TYPE_INVALID:
         rc = ERROR_FAIL;
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index b85b377..593f3e6 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -2053,11 +2053,16 @@  static int kill_device_model(libxl__gc *gc, const char *xs_path_pid)
     int ret, pid;
 
     ret = libxl__xs_read_checked(gc, XBT_NULL, xs_path_pid, &xs_pid);
-    if (ret || !xs_pid) {
+    if (ret) {
         LOG(ERROR, "unable to find device model pid in %s", xs_path_pid);
         ret = ret ? : ERROR_FAIL;
         goto out;
     }
+    if (!xs_pid) {
+        /* Jolly good */
+        ret = 0;
+        goto out;
+    }
     pid = atoi(xs_pid);
 
     ret = kill(pid, SIGHUP);