diff mbox

[18/28] libxl: emuids: Change pid path in xenstore

Message ID 1450809903-3393-19-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
Introduce libxl__dm_xs_pid_path and use it everywhere.

There is no overall functional change, although there is a change to
these internal paths.  Also, the paths used are now relative (ie to
/local/domain/<domid-containing-device-model>) rather than absolute.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
v6: Rewritten, actual paths changed, patch title changed
v4: Update xenstore-paths.markdown
---
 docs/misc/xenstore-paths.markdown |   10 +++-------
 tools/libxl/libxl_dm.c            |   11 +++++------
 tools/libxl/libxl_internal.c      |    6 ++++++
 tools/libxl/libxl_internal.h      |    3 +++
 4 files changed, 17 insertions(+), 13 deletions(-)
diff mbox

Patch

diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown
index 208b64b..3bd31af 100644
--- a/docs/misc/xenstore-paths.markdown
+++ b/docs/misc/xenstore-paths.markdown
@@ -143,11 +143,6 @@  The guests name.
 
 The domain's own ID.
 
-#### ~/image/device-model-pid = INTEGER   [INTERNAL]
-
-The process ID of the device model associated with this domain, if it
-has one.
-
 #### ~/cpu/[0-9]+/availability = ("online"|"offline") [PV]
 
 One node for each virtual CPU up to the guest's configured
@@ -463,9 +458,10 @@  in the value supplied by the guest in this case).
 
 Contains the status of the device models running on the domain.
 
-#### ~/libxl/$DOMID/qdisk-backend-pid [w]
+#### ~/libxl/$DOMID/dm-pid-$EMUID [w] = INTEGER   [INTERNAL]
 
-Contains the PIDs of the device models running on the domain.
+Contains the PIDs of the device models running on this domain, to
+service $DOMID.
 
 ## Virtual Machine Paths
 
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 3bf1317..6b0bbed 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1867,7 +1867,7 @@  void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss,
     }
 
     const char *dom_path = libxl__xs_get_dompath(gc, domid);
-    spawn->pidpath = GCSPRINTF("%s/%s", dom_path, "image/device-model-pid");
+    spawn->pidpath = libxl__dm_xs_pid_path(gc, domid, emuid);
 
     if (vnc && vnc->passwd) {
         /* This xenstore key will only be used by qemu-xen-traditionnal.
@@ -1901,7 +1901,7 @@  retry_transaction:
     spawn->xspath = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID,
                                                 domid, emuid, "/state");
     spawn->timeout_ms = LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000;
-    spawn->pidpath = GCSPRINTF("%s/image/device-model-pid", dom_path);
+    spawn->pidpath = libxl__dm_xs_pid_path(gc, domid, emuid);
     spawn->midproc_cb = libxl__spawn_record_pid;
     spawn->confirm_cb = device_model_confirm;
     spawn->failure_cb = device_model_startup_failed;
@@ -2036,7 +2036,7 @@  void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)
      * because we will call this from unprivileged driver domains,
      * so save it in the current domain libxl private dir.
      */
-    dmss->spawn.pidpath = GCSPRINTF("libxl/%u/qdisk-backend-pid", domid);
+    dmss->spawn.pidpath = libxl__dm_xs_pid_path(gc, domid, EMUID_PV);
     dmss->spawn.midproc_cb = libxl__spawn_record_pid;
     dmss->spawn.confirm_cb = device_model_confirm;
     dmss->spawn.failure_cb = device_model_startup_failed;
@@ -2101,7 +2101,7 @@  int libxl__destroy_qdisk_backend(libxl__gc *gc, uint32_t domid)
     char *pid_path;
     int rc;
 
-    pid_path = GCSPRINTF("libxl/%u/qdisk-backend-pid", domid);
+    pid_path = libxl__dm_xs_pid_path(gc, domid, EMUID_PV);
 
     rc = kill_device_model(gc, pid_path);
     if (rc)
@@ -2129,8 +2129,7 @@  int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid,
         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));
+    rc = kill_device_model(gc, libxl__dm_xs_pid_path(gc, domid, emuid));
     if (rc)
         LOG(ERROR, "libxl__destroy_device_model failed for %d (emuid=%d)",
             domid, emuid);
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index d0c98b0..30271c9 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -576,6 +576,12 @@  char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid,
     return s;
 }
 
+char *libxl__dm_xs_pid_path(libxl__gc *gc, int guest_domid, int emuid)
+{
+    return GCSPRINTF("libxl/%d/dm-pid-%d", guest_domid, emuid);
+}
+
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 2248509..350ec29 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1986,6 +1986,9 @@  _hidden char *libxl__dm_xs_path_rel(libxl__gc *gc,
                                     uint32_t domid, int emuid);
     /* returns relative path (ie assuming we are the toolstack) */
 
+_hidden char *libxl__dm_xs_pid_path(libxl__gc *gc,
+                                    int guest_domid, int emuid);
+
 /*
  * Calling context and GC for event-generating functions:
  *