Take some improvements from libxl__destroy_qdisk_backend:
* Use libxl__xs_rm_checked rather than xs_rm
* Remove the pid from xenstore

Then libxl__destroy_qdisk_backend can be made into a simple wrapper
around libxl__destroy_device_model.

Signed-off-by: Ian Jackson <ian.jack...@eu.citrix.com>
---
v6: New patch.
---
 tools/libxl/libxl_dm.c |   27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 6b0bbed..886ed9c 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -2098,21 +2098,12 @@ out:
 /* Helper to destroy a Qdisk backend */
 int libxl__destroy_qdisk_backend(libxl__gc *gc, uint32_t domid)
 {
-    char *pid_path;
-    int rc;
-
-    pid_path = libxl__dm_xs_pid_path(gc, domid, EMUID_PV);
+    unsigned emuidmap;
 
-    rc = kill_device_model(gc, pid_path);
-    if (rc)
-        goto out;
+    libxl__dm_emuidmap_get(gc, domid, &emuidmap);
+    /* better to blunder on if this fails */
 
-    libxl__xs_rm_checked(gc, XBT_NULL, pid_path);
-    libxl__xs_rm_checked(gc, XBT_NULL,
-                         libxl__dm_xs_path_rel(gc, domid, EMUID_PV));
-
-out:
-    return rc;
+    return libxl__destroy_device_model(gc, domid, emuidmap, EMUID_PV);
 }
 
 int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid,
@@ -2123,16 +2114,16 @@ int libxl__destroy_device_model(libxl__gc *gc, uint32_t 
domid,
     if (!(emuidmap & (1u << emuid)))
         return 0;
 
-    char *path = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID,
-                                             domid, emuid, "");
-    if (!xs_rm(CTX->xsh, XBT_NULL, path))
-        LOG(ERROR, "xs_rm failed for %s", path);
+    const char *control_path = libxl__dm_xs_path_rel(gc, domid, emuid);
+    libxl__xs_rm_checked(gc, XBT_NULL, control_path);
 
     /* We should try to destroy the device model anyway. */
-    rc = kill_device_model(gc, libxl__dm_xs_pid_path(gc, domid, emuid));
+    const char *pid_path = libxl__dm_xs_pid_path(gc, domid, emuid);
+    rc = kill_device_model(gc, pid_path);
     if (rc)
         LOG(ERROR, "libxl__destroy_device_model failed for %d (emuid=%d)",
             domid, emuid);
+    libxl__xs_rm_checked(gc, XBT_NULL, pid_path);
 
     libxl__qmp_cleanup(gc, domid);
     return rc;
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to