All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 11/28] libxl: emuids: Pass correct emuid to internal functions
Date: Tue, 22 Dec 2015 18:44:46 +0000	[thread overview]
Message-ID: <1450809903-3393-12-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1450809903-3393-1-git-send-email-ian.jackson@eu.citrix.com>

Provide EMUID_PV and use it appropriately.  We split our qemus into
two:

EMUID_DM does actual emulation.  EMUID_PV is for PV backends.  Most
places relate to emulation and can simply pass EMUID_DM.

Creation is a notable exception, where we pass the emuid as a new
parameter to the spawn functions.

There is no overall functional change, because the ultimate consumer,
libxl__device_model_xs_path, does not pay any attention to the
parameter yet, and because we still need to plumb the emuid through to
the qemu argument construction.

Also, domain destruction does not yet pass the right emuid.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com
---
v6: Largely rewritten, but in some sense (at least conceptually)
    based on a similar concept in v5.
---
 tools/libxl/libxl_create.c   |   11 ++++++-----
 tools/libxl/libxl_dm.c       |   16 +++++++++-------
 tools/libxl/libxl_internal.c |    3 +--
 tools/libxl/libxl_internal.h |   15 +++++++++++----
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1af7066..41ece5a 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1309,10 +1309,11 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         libxl_device_vkb_dispose(&vkb);
 
         dcs->dmss.dm.guest_domid = domid;
-        if (libxl_defbool_val(d_config->b_info.device_model_stubdomain))
-            libxl__spawn_stub_dm(egc, &dcs->dmss);
-        else
-            libxl__spawn_local_dm(egc, &dcs->dmss.dm);
+        if (libxl_defbool_val(d_config->b_info.device_model_stubdomain)) {
+            libxl__spawn_stub_dm(egc, &dcs->dmss, EMUID_DM);
+        } else {
+            libxl__spawn_local_dm(egc, &dcs->dmss.dm, EMUID_DM);
+        }
 
         /*
          * Handle the domain's (and the related stubdomain's) access to
@@ -1348,7 +1349,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
 
         if (need_qemu) {
             dcs->dmss.dm.guest_domid = domid;
-            libxl__spawn_local_dm(egc, &dcs->dmss.dm);
+            libxl__spawn_local_dm(egc, &dcs->dmss.dm, EMUID_PV);
             return;
         } else {
             assert(!dcs->dmss.dm.guest_domid);
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 593f3e6..1e1dfa0 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1434,7 +1434,8 @@ char *libxl__stub_dm_name(libxl__gc *gc, const char *guest_name)
     return GCSPRINTF("%s-dm", guest_name);
 }
 
-void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
+void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss,
+                          int emuid)
 {
     STATE_AO_GC(sdss->dm.spawn.ao);
     libxl_ctx *ctx = libxl__gc_owner(gc);
@@ -1558,7 +1559,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
 retry_transaction:
     t = xs_transaction_start(ctx->xsh);
     const char *dmpath = libxl__device_model_xs_path(gc,
-            dm_domid, guest_domid, EMUID_DM, "");
+            dm_domid, guest_domid, emuid, "");
     xs_mkdir(ctx->xsh, t, dmpath);
     xs_set_permissions(ctx->xsh, t,
                        dmpath,
@@ -1668,7 +1669,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
     sdss->pvqemu.build_state = &sdss->dm_state;
     sdss->pvqemu.callback = spawn_stubdom_pvqemu_cb;
 
-    libxl__spawn_local_dm(egc, &sdss->pvqemu);
+    libxl__spawn_local_dm(egc, &sdss->pvqemu, EMUID_PV);
 
     return;
 
@@ -1724,7 +1725,7 @@ static void stubdom_pvqemu_cb(libxl__egc *egc,
                                   dm_domid, sdss->dm.guest_domid);
     sdss->xswait.path =
         libxl__device_model_xs_path(gc, dm_domid, sdss->dm.guest_domid,
-                                    EMUID_DM, "/state");
+                                    EMUID_PV, "/state");
     sdss->xswait.timeout_ms = LIBXL_STUBDOM_START_TIMEOUT * 1000;
     sdss->xswait.callback = stubdom_xswait_cb;
     rc = libxl__xswait_start(gc, &sdss->xswait);
@@ -1771,7 +1772,8 @@ static void device_model_spawn_outcome(libxl__egc *egc,
                                        libxl__dm_spawn_state *dmss,
                                        int rc);
 
-void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)
+void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss,
+                           int emuid)
 {
     /* convenience aliases */
     const int domid = dmss->guest_domid;
@@ -1832,7 +1834,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)
     }
 
     path = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID,
-                                       domid, EMUID_DM, "");
+                                       domid, emuid, "");
     xs_mkdir(ctx->xsh, XBT_NULL, path);
 
     if (b_info->type == LIBXL_DOMAIN_TYPE_HVM &&
@@ -1887,7 +1889,7 @@ retry_transaction:
 
     spawn->what = GCSPRINTF("domain %d device model", domid);
     spawn->xspath = libxl__device_model_xs_path(gc, LIBXL_TOOLSTACK_DOMID,
-                                                domid, EMUID_DM, "/state");
+                                                domid, emuid, "/state");
     spawn->timeout_ms = LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000;
     spawn->pidpath = GCSPRINTF("%s/image/device-model-pid", dom_path);
     spawn->midproc_cb = libxl__spawn_record_pid;
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index ec93797..843fdbf 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -554,8 +554,7 @@ void libxl__update_domain_configuration(libxl__gc *gc,
 }
 
 char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid,
-                                  uint32_t domid,
-                                  struct dummy_qemu_emulator_id emuid,
+                                  uint32_t domid, int emuid,
                                   const char *format,  ...)
 {
     char *s, *fmt;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index ea56cda..71c1e17 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1956,10 +1956,15 @@ _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);
   /* Return the system-wide default device model */
 _hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc);
 
-static const struct dummy_qemu_emulator_id { int x; } EMUID_DM;
+enum {
+    EMUID_PV,
+    EMUID_DM,
+    /* NB stubdom and its PV service domain not recorded here */
+};
+
 _hidden char *libxl__device_model_xs_path(libxl__gc *gc,
         uint32_t dm_domid,
-        uint32_t domid, struct dummy_qemu_emulator_id,
+        uint32_t domid, int emuid,
         const char *format, ...) PRINTF_ATTRIBUTE(5, 6);
 
 /*
@@ -3399,7 +3404,8 @@ struct libxl__dm_spawn_state {
     libxl__dm_spawn_cb *callback;
 };
 
-_hidden void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state*);
+_hidden void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state*,
+                                   int emuid);
 
 /* Stubdom device models. */
 
@@ -3418,7 +3424,8 @@ typedef struct {
     libxl__xswait_state xswait;
 } libxl__stub_dm_spawn_state;
 
-_hidden void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state*);
+_hidden void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state*,
+                                  int emuid);
 
 _hidden char *libxl__stub_dm_name(libxl__gc *gc, const char * guest_name);
 
-- 
1.7.10.4

  parent reply	other threads:[~2015-12-22 18:44 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 18:44 [RFC PATCH v6 00/28] libxl: Deprivilege qemu Ian Jackson
2015-12-22 18:44 ` [PATCH 01/28] libxl: Move FILLZERO up in libxl_internal.h Ian Jackson
2016-01-07 17:08   ` Ian Campbell
2015-12-22 18:44 ` [PATCH 02/28] libxl: libxl_types_internal.idl: Add Emacs mode comment Ian Jackson
2016-01-07 17:09   ` Ian Campbell
2015-12-22 18:44 ` [PATCH 03/28] libxl: Provide libxl__dm_support_* Ian Jackson
2016-01-07 17:13   ` Ian Campbell
2016-01-08 12:13     ` Ian Jackson
2016-01-11 17:00     ` Jim Fehlig
2016-01-14 10:14       ` Ian Campbell
2016-01-14 18:31         ` Jim Fehlig
2016-01-15  9:56           ` Ian Campbell
2016-01-15 14:54             ` Jim Fehlig
2015-12-22 18:44 ` [PATCH 04/28] libxl: Invoke libxl__dm_support_* Ian Jackson
2015-12-22 18:44 ` [PATCH 05/28] libxl: libxl__spawn_stub_dm: Introduce `dmpath' Ian Jackson
2015-12-22 18:44 ` [PATCH 06/28] libxl: qemu_pci_*: Introduce DMPATH local macro, twice Ian Jackson
2015-12-22 18:44 ` [PATCH 07/28] libxl: libxl__device_model_xs_path: Add emulator_id parameter Ian Jackson
2015-12-22 18:44 ` [PATCH 08/28] libxl: libxl__destroy_domid: Bring dm destruction together Ian Jackson
2015-12-22 18:44 ` [PATCH 09/28] libxl: Move some error handling and cleanup into libxl__destroy_device_model Ian Jackson
2015-12-22 18:44 ` [PATCH 10/28] libxl: kill_device_model: Silently tolerate ENOENT on pid xs path Ian Jackson
2015-12-22 18:44 ` Ian Jackson [this message]
2015-12-22 18:44 ` [PATCH 12/28] libxl: Use libxl__device_model_xs_path in libxl__spawn_qdisk_backend Ian Jackson
2015-12-22 18:44 ` [PATCH 13/28] libxl: emuids: Record which emuids we have started to create Ian Jackson
2015-12-22 18:44 ` [PATCH 14/28] libxl: emuids: Pass emuid to dm destruction Ian Jackson
2015-12-22 18:44 ` [PATCH 15/28] libxl: emuids: Pass emuid to device model argument construction Ian Jackson
2015-12-22 18:44 ` [PATCH 16/28] libxl: emuids: Provide libxl__dm_xs_path_rel Ian Jackson
2015-12-22 18:44 ` [PATCH 17/28] libxl: emuids: Do not open-code device-model/%u in libxl__destroy_qdisk_backend Ian Jackson
2015-12-22 18:44 ` [PATCH 18/28] libxl: emuids: Change pid path in xenstore Ian Jackson
2015-12-22 18:44 ` [PATCH 19/28] libxl: Improve libxl__destroy_device_model Ian Jackson
2015-12-22 18:44 ` [PATCH 20/28] libxl: domcreate_dm_support_checked: Introduce `goto out' Ian Jackson
2015-12-22 18:44 ` [PATCH 21/28] libxl: dm user: Reject attempts to set user!=root with qemu trad Ian Jackson
2016-01-07 17:20   ` Ian Campbell
2016-01-08 12:16     ` Ian Jackson
2016-01-08 12:23       ` Ian Campbell
2015-12-22 18:44 ` [PATCH 22/28] libxl: dm user: Document the default Ian Jackson
2016-01-07 17:20   ` Ian Campbell
2015-12-22 18:44 ` [PATCH 23/28] libxl: dm user: Move user choice earlier, and fill in config Ian Jackson
2015-12-22 18:44 ` [PATCH 24/28] libxl: dm spawn records rc in state struct rather than passing as argument Ian Jackson
2015-12-22 18:45 ` [PATCH 25/28] libxl: emuids: Perhaps change dm xs control path Ian Jackson
2016-01-07 17:26   ` Ian Campbell
2016-01-08 14:12     ` Ian Jackson
2016-01-08 14:36       ` Ian Campbell
2016-01-08 14:45         ` Ian Jackson
2016-01-08 14:49           ` Ian Campbell
2015-12-22 18:45 ` [PATCH 26/28] libxl: spawns two QEMUs for HVM guests Ian Jackson
2016-01-07 17:28   ` Ian Campbell
2016-01-08 14:35     ` Ian Jackson
2016-01-08 14:52       ` Ian Campbell
2015-12-22 18:45 ` [PATCH 27/28] libxl: Limit qemu physmap entries Ian Jackson
2016-01-07 17:28   ` Ian Campbell
2015-12-22 18:45 ` [PATCH 28/28] libxl: xsrestrict QEMU Ian Jackson
2016-01-07 17:36   ` Ian Campbell
2016-01-08 14:38     ` Ian Jackson
2016-04-10 19:52   ` Stefano Stabellini
2016-01-07 16:19 ` [RFC PATCH v6 00/28] libxl: Deprivilege qemu Wei Liu
2016-01-07 16:23   ` Stefano Stabellini
2016-01-07 16:36     ` Ian Jackson
2016-04-10 19:36 ` Stefano Stabellini
2016-04-11 10:35   ` Wei Liu
2016-04-14 17:27   ` Ian Jackson
2016-04-28 14:32     ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1450809903-3393-12-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.