libxl: add service function to check whether device model is running
authorJuergen Gross <jgross@suse.com>
Tue, 29 Mar 2016 05:29:19 +0000 (07:29 +0200)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 6 Apr 2016 13:58:02 +0000 (14:58 +0100)
Add an internal service function to check for a running device model.
This can be used later when adding devices to a domain requiring a
device model for either printing an error message or starting the
device model in case it is not already running.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_dm.c
tools/libxl/libxl_internal.h

index 75f00beeae73db12ac6c52e20ba3700c494bb043..1ac7848677e02d17809a60144393c3e8162b92a8 100644 (file)
@@ -1552,7 +1552,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);
@@ -1575,8 +1574,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 = libxl__dm_active(gc, domid);
         break;
     case LIBXL_DOMAIN_TYPE_INVALID:
         rc = ERROR_FAIL;
index a45b2c0ca945476d55fa60f245a736ea29fc2b37..bc043fe9fc7a26341a5b6944a2fe91b945915de3 100644 (file)
@@ -2377,6 +2377,16 @@ out:
     return ret;
 }
 
+int libxl__dm_active(libxl__gc *gc, uint32_t domid)
+{
+    char *pid, *path;
+
+    path = GCSPRINTF("/local/domain/%d/image/device-model-pid", domid);
+    pid = libxl__xs_read(gc, XBT_NULL, path);
+
+    return pid != NULL;
+}
+
 /*
  * Local variables:
  * mode: C
index 770f129c2453e80d175d02ab2082eb56fee4349d..eaa150d5ea09e6eb5e96d434d9fbefb446f53cbe 100644 (file)
@@ -1625,6 +1625,7 @@ _hidden bool libxl__query_qemu_backend(libxl__gc *gc,
                                        uint32_t backend_id,
                                        const char *type,
                                        bool def);
+_hidden int libxl__dm_active(libxl__gc *gc, uint32_t domid);
 
 /*
  * This function will fix reserved device memory conflict