From patchwork Tue Dec 22 18:44:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 7906811 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 75507BEEE5 for ; Tue, 22 Dec 2015 18:48:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65BC420503 for ; Tue, 22 Dec 2015 18:48:35 +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 49DEF20501 for ; Tue, 22 Dec 2015 18:48:34 +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 1aBRvu-0001GP-Rw; Tue, 22 Dec 2015 18:45:14 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aBRvs-0001G4-SE for xen-devel@lists.xensource.com; Tue, 22 Dec 2015 18:45:12 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 83/37-21571-83A99765; Tue, 22 Dec 2015 18:45:12 +0000 X-Env-Sender: prvs=791371759=Ian.Jackson@citrix.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1450809908!6310965!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22416 invoked from network); 22 Dec 2015 18:45:11 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Dec 2015 18:45:11 -0000 X-IronPort-AV: E=Sophos;i="5.20,465,1444694400"; d="scan'208";a="320985041" From: Ian Jackson To: Date: Tue, 22 Dec 2015 18:44:46 +0000 Message-ID: <1450809903-3393-12-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 11/28] libxl: emuids: Pass correct emuid to internal functions 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 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 Signed-off-by: Ian Jackson 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);