From patchwork Tue Dec 22 18:45:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 7906581 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D9C179F349 for ; Tue, 22 Dec 2015 18:47:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBF0920501 for ; Tue, 22 Dec 2015 18:47:54 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B80F620502 for ; Tue, 22 Dec 2015 18:47:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aBRwj-00025W-AS; Tue, 22 Dec 2015 18:46:05 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aBRwa-0001hr-MB for xen-devel@lists.xensource.com; Tue, 22 Dec 2015 18:45:56 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id 99/91-12889-46A99765; Tue, 22 Dec 2015 18:45:56 +0000 X-Env-Sender: prvs=791371759=Ian.Jackson@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1450809948!12405671!8 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18441 invoked from network); 22 Dec 2015 18:45:55 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-3.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 22 Dec 2015 18:45:55 -0000 X-IronPort-AV: E=Sophos;i="5.20,465,1444694400"; d="scan'208";a="327002760" From: Ian Jackson To: Date: Tue, 22 Dec 2015 18:45:00 +0000 Message-ID: <1450809903-3393-26-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1450809903-3393-1-git-send-email-ian.jackson@eu.citrix.com> References: <1450809903-3393-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Ian Jackson , Wei Liu , Ian Campbell , Stefano Stabellini Subject: [Xen-devel] [PATCH 25/28] libxl: emuids: Perhaps change dm xs control path X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. 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 Signed-off-by: Ian Jackson --- 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 */ };