xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Ian Jackson <ian.jackson@eu.citrix.com>, xen-devel@lists.xensource.com
Cc: Wei Liu <wei.liu2@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: Re: [PATCH 25/28] libxl: emuids: Perhaps change dm xs control path
Date: Thu, 7 Jan 2016 17:26:30 +0000	[thread overview]
Message-ID: <1452187590.21055.269.camel@citrix.com> (raw)
In-Reply-To: <1450809903-3393-26-git-send-email-ian.jackson@eu.citrix.com>

On Tue, 2015-12-22 at 18:45 +0000, Ian Jackson wrote:
> We are going to want to run two qemus, which will mean them having
> different xs control paths.  But sometimes we will run only one qemu
> to do both jobs, in which case there has to be one xs control path,
> because otherwise the single qemu will only see in xenstore either the
> HVM DM work to do, or the PV (eg qdisk) backend work to do.
> 
> So we need to record whether any particular domain has been set up
> this way.  Use a new emuid flag bit EMUID_SPLIT which just tells us
> whether we are running two qemus in this way.

So, do I understand correctly that the states (combinations of bits) are:

0 		No QEMUs
PV 		Single QEMU only providing PV backends
DM		Single QEMU only providing device emulation
PV|DM 		Single QEMU providing PV backends and device emulation
SPLIT|PV|DM	A pair of QEMUs, one for PV b/e and one for device emu
SPLIT|PV	Nonsense
SPLIT|DM	Nonsense	

?

Describing SPLIT as an "ID" is a bit odd (it's a kind of meta thing) but I
suppose I can see why it is done this way. An alternative might be to have
a separate bit for the PV|DM case together, maybe you discarded that
possibility though?

Ian.



> 
> If we do set this flag, we pass the emulator_id to qemu, so that qemu
> and libxl agree on the xenstore path.  Obviously this depends on qemu
> understanding emulator_id, but we don't check that now, because:
> 
> We do not actually ever set EMUID_SPLIT, because when we run split
> qemus we also need to actually run two qemus which means a lot of
> non-xs-path-related changes which are more readable in a separate
> patch.
> 
> So right now there is no overall functional change.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
> ---
> v6: Rewritten.
> ---
>  docs/misc/xenstore-paths.markdown |   11 +++++++++++
>  tools/libxl/libxl_dm.c            |   15 +++++++++++++++
>  tools/libxl/libxl_internal.c      |   16 +++++++++++++++-
>  tools/libxl/libxl_internal.h      |    1 +
>  4 files changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-
> paths.markdown
> index 3bd31af..1dc54ac 100644
> --- a/docs/misc/xenstore-paths.markdown
> +++ b/docs/misc/xenstore-paths.markdown
> @@ -339,6 +339,17 @@ A PV console backend. Described in
> [console.txt](console.txt)
>  Information relating to device models running in the domain. $DOMID is
>  the target domain of the device model.
>  
> +#### ~/device-model/$DOMID[/$EMULATOR_ID]/* [INTERNAL]
> +
> +Information relating to device models running in the domain. $DOMID is
> +the target domain of the device model.
> +
> +$EMULATOR_ID indentifies a specific device model instance (multiple
> +device model instances for the same domain are possible).  This path
> +component is present only if there are (going to be) more than one
> +device model for the domain.  See `/libxl/$DOMID/dm-emuidmap` and
> +`EMUID_SPLIT` in `libxl_internal.h`.
> +
>  #### ~/libxl/disable_udev = ("1"|"0") []
>  
>  Indicates whether device hotplug scripts in this domain should be run
> diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
> index 58760e7..d805800 100644
> --- a/tools/libxl/libxl_dm.c
> +++ b/tools/libxl/libxl_dm.c
> @@ -1236,6 +1236,11 @@ static int
> libxl__build_device_model_args_new(libxl__gc *gc,
>              flexarray_append(dm_args, "-runas");
>              flexarray_append(dm_args, user);
>          }
> +        if (state->emuidmap & (1u << EMUID_SPLIT)) {
> +            flexarray_append(dm_args, "-xenopts");
> +            flexarray_append(dm_args,
> +                             GCSPRINTF("emulator_id=%u", emuid));
> +        }
>      }
>      flexarray_append(dm_args, NULL);
>      *args = (char **) flexarray_contents(dm_args);
> @@ -1943,6 +1948,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc,
> libxl__dm_spawn_state *dmss)
>      const char *dm;
>      int logfile_w, null = -1, rc;
>      uint32_t domid = dmss->guest_domid;
> +    unsigned emuidmap;
>  
>      /* Always use qemu-xen as device model */
>      dm = qemu_xen_path(gc);
> @@ -1958,6 +1964,15 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc,
> libxl__dm_spawn_state *dmss)
>      flexarray_vappend(dm_args, "-monitor", "/dev/null", NULL);
>      flexarray_vappend(dm_args, "-serial", "/dev/null", NULL);
>      flexarray_vappend(dm_args, "-parallel", "/dev/null", NULL);
> +
> +    rc = libxl__dm_emuidmap_get(gc, domid, &emuidmap);
> +    if (rc) goto error;
> +
> +    if (emuidmap & (1u << EMUID_SPLIT)) {
> +        flexarray_append(dm_args, "-xenopts");
> +        flexarray_append(dm_args,
> +                GCSPRINTF("emulator_id=%u", EMUID_PV));
> +    }
>      flexarray_append(dm_args, NULL);
>      args = (char **) flexarray_contents(dm_args);
>  
> diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
> index 30271c9..8dc34ad 100644
> --- a/tools/libxl/libxl_internal.c
> +++ b/tools/libxl/libxl_internal.c
> @@ -556,7 +556,21 @@ void libxl__update_domain_configuration(libxl__gc
> *gc,
>  char *libxl__dm_xs_path_rel(libxl__gc *gc,
>                              uint32_t domid, int emuid)
>  {
> -    return GCSPRINTF("device-model/%u", domid);
> +    unsigned emuidmap;
> +
> +    libxl__dm_emuidmap_get_bodgeerrors(gc, domid, &emuidmap);
> +
> +    if (!(emuidmap & (1u << emuid))) {
> +        LOG(ERROR,
> + "Trying to find path for emulator %d but map is %#x, probable BUG",
> +            emuid, emuidmap);
> +    }
> +
> +    if (!(emuidmap & (1u << EMUID_SPLIT))) {
> +        return GCSPRINTF("device-model/%u", domid);
> +    } else {
> +        return GCSPRINTF("device-model/%u/%u", domid, emuid);
> +    }
>  }
>  
>  char *libxl__device_model_xs_path(libxl__gc *gc, uint32_t dm_domid,
> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
> index 82f264a..02c35e0 100644
> --- a/tools/libxl/libxl_internal.h
> +++ b/tools/libxl/libxl_internal.h
> @@ -1962,6 +1962,7 @@ _hidden libxl_device_model_version
> libxl__default_device_model(libxl__gc *gc);
>  enum {
>      EMUID_PV,
>      EMUID_DM,
> +    EMUID_SPLIT, /* we will run both PV and DM, put emuid in xs path */
>      /* NB stubdom and its PV service domain not recorded here */
>  };
>  

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

  reply	other threads:[~2016-01-07 17:26 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 ` [PATCH 11/28] libxl: emuids: Pass correct emuid to internal functions Ian Jackson
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 [this message]
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=1452187590.21055.269.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).