[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 14/28] libxl: emuids: Pass emuid to dm destruction



Rather than recomputing this with a switch() statement, etc., we rely
on the emuidmap to tell us which qemus to destroy.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
v6: New patch.  This is a new approach in v6.

squash! libxl: Pass emuid to dm destruction
---
 tools/libxl/libxl.c          |   31 ++++++++++++-------------------
 tools/libxl/libxl_dm.c       |   13 +++++++++----
 tools/libxl/libxl_internal.h |    3 ++-
 3 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 2a0c092..dff4478 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1606,7 +1606,8 @@ void libxl__destroy_domid(libxl__egc *egc, 
libxl__destroy_domid_state *dis)
     libxl_ctx *ctx = CTX;
     uint32_t domid = dis->domid;
     char *dom_path;
-    int rc, dm_present;
+    int rc;
+    unsigned emuidmap;
 
     libxl__ev_child_init(&dis->destroyer);
 
@@ -1633,27 +1634,19 @@ void libxl__destroy_domid(libxl__egc *egc, 
libxl__destroy_domid_state *dis)
         goto out;
     }
 
-    switch (libxl__domain_type(gc, domid)) {
-    case LIBXL_DOMAIN_TYPE_HVM:
-        if (libxl_get_stubdom_id(CTX, domid)) {
-            dm_present = 0;
-            break;
-        }
-        /* fall through */
-    case LIBXL_DOMAIN_TYPE_PV:
-        dm_present = 1;
-        break;
-    case LIBXL_DOMAIN_TYPE_INVALID:
-        rc = ERROR_FAIL;
-        goto out;
-    default:
-        abort();
-    }
+    libxl__dm_emuidmap_get_bodgeerrors(gc, domid, &emuidmap);
 
-    if (dm_present) {
-        libxl__destroy_device_model(gc, domid);
+    libxl__destroy_device_model(gc, domid, emuidmap, EMUID_PV);
 
+    if (libxl__domain_type(gc, domid) == LIBXL_DOMAIN_TYPE_HVM &&
+        libxl_get_stubdom_id(CTX, domid)) {
+        /* This is destroyed in libxl__domain_destroy */
+    } else {
+        libxl__destroy_device_model(gc, domid, emuidmap, EMUID_DM);
     }
+
+    libxl__destroy_device_model(gc, domid, emuidmap, EMUID_PV);
+
     dis->drs.ao = ao;
     dis->drs.domid = domid;
     dis->drs.callback = devices_destroy_cb;
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 2bd1eb0..bcae664 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -2111,20 +2111,25 @@ out:
     return rc;
 }
 
-int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid)
+int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid,
+                                unsigned emuidmap, int emuid)
 {
     int rc;
 
+    if (!(emuidmap & (1u << emuid)))
+        return 0;
+
     char *path = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID,
-                                             domid, EMUID_DM, "");
+                                             domid, emuid, "");
     if (!xs_rm(CTX->xsh, XBT_NULL, path))
         LOG(ERROR, "xs_rm failed for %s", path);
+
     /* We should try to destroy the device model anyway. */
     rc = kill_device_model(gc,
                 GCSPRINTF("/local/domain/%d/image/device-model-pid", domid));
     if (rc)
-        LOG(ERROR, "libxl__destroy_device_model failed for %d",
-            domid);
+        LOG(ERROR, "libxl__destroy_device_model failed for %d (emuid=%d)",
+            domid, emuid);
 
     libxl__qmp_cleanup(gc, domid);
     return rc;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 0194823..4a9003d 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1656,7 +1656,8 @@ _hidden int 
libxl__wait_for_device_model_deprecated(libxl__gc *gc,
                                                       void *userdata),
                                 void *check_callback_userdata);
 
-_hidden int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid);
+_hidden int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid,
+                                        unsigned emuidmap, int emuid);
 
 _hidden const libxl_vnc_info *libxl__dm_vnc(const libxl_domain_config *g_cfg);
 
-- 
1.7.10.4


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.