From patchwork Tue Dec 22 18:44:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 7906801 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 025A39F349 for ; Tue, 22 Dec 2015 18:48:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0369120501 for ; Tue, 22 Dec 2015 18:48:27 +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 DC87F204FC for ; Tue, 22 Dec 2015 18:48:25 +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 1aBRwq-0002Jr-6o; Tue, 22 Dec 2015 18:46:12 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aBRwb-0001jl-A9 for xen-devel@lists.xensource.com; Tue, 22 Dec 2015 18:45:57 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id AD/C2-28221-56A99765; Tue, 22 Dec 2015 18:45:57 +0000 X-Env-Sender: prvs=791371759=Ian.Jackson@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1450809948!12405671!9 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 18519 invoked from network); 22 Dec 2015 18:45:56 -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:56 -0000 X-IronPort-AV: E=Sophos;i="5.20,465,1444694400"; d="scan'208";a="327002759" From: Ian Jackson To: Date: Tue, 22 Dec 2015 18:44:59 +0000 Message-ID: <1450809903-3393-25-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: MIA2 Cc: Ian Jackson , Wei Liu , Ian Campbell , Stefano Stabellini Subject: [Xen-devel] [PATCH 24/28] libxl: dm spawn records rc in state struct rather than passing as argument 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 This is going to be much more convenient in a moment, when one of the call sites is going to want to run two in parallel. No functional change. Signed-off-by: Ian Jackson --- v6: New patch. --- tools/libxl/libxl.c | 4 ++-- tools/libxl/libxl_create.c | 14 +++++++------- tools/libxl/libxl_dm.c | 22 +++++++++++++--------- tools/libxl/libxl_internal.h | 5 +++-- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index dff4478..3bb6d3b 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -4345,10 +4345,10 @@ static void device_complete(libxl__egc *egc, libxl__ao_device *aodev) libxl__nested_ao_free(aodev->ao); } -static void qdisk_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss, - int rc) +static void qdisk_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss) { STATE_AO_GC(dmss->spawn.ao); + int rc = dmss->rc; LOG(DEBUG, "qdisk backend spawn for domain %u %s", dmss->guest_domid, rc ? "failed" : "succeed"); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index be9bb7b..e67e402 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -803,8 +803,7 @@ static void remus_checkpoint_stream_done( static void domcreate_dm_support_checked(libxl__egc *egc, libxl__dm_support_check_state *checking, int rc); static void domcreate_devmodel_started(libxl__egc *egc, - libxl__dm_spawn_state *dmss, - int rc); + libxl__dm_spawn_state *dmss); static void domcreate_bootloader_console_available(libxl__egc *egc, libxl__bootloader_state *bl); static void domcreate_bootloader_done(libxl__egc *egc, @@ -1387,8 +1386,8 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, if (d_config->b_info.device_model_version == LIBXL_DEVICE_MODEL_VERSION_NONE) { - domcreate_devmodel_started(egc, &dcs->dmss.dm, 0); - return; + dcs->dmss.dm.rc = 0; + domcreate_devmodel_started(egc, &dcs->dmss.dm); } libxl_device_vkb_init(&vkb); @@ -1440,7 +1439,8 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, return; } else { assert(!dcs->dmss.dm.guest_domid); - domcreate_devmodel_started(egc, &dcs->dmss.dm, 0); + dcs->dmss.dm.rc = 0; + domcreate_devmodel_started(egc, &dcs->dmss.dm); return; } } @@ -1456,11 +1456,11 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, } static void domcreate_devmodel_started(libxl__egc *egc, - libxl__dm_spawn_state *dmss, - int ret) + libxl__dm_spawn_state *dmss) { libxl__domain_create_state *dcs = CONTAINER_OF(dmss, *dcs, dmss.dm); STATE_AO_GC(dmss->spawn.ao); + int ret = dmss->rc; int domid = dcs->guest_domid; /* convenience aliases */ diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 5e1a6cf..58760e7 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1369,8 +1369,7 @@ retry_transaction: } static void spawn_stubdom_pvqemu_cb(libxl__egc *egc, - libxl__dm_spawn_state *stubdom_dmss, - int rc); + libxl__dm_spawn_state *stubdom_dmss); static void spawn_stub_launch_dm(libxl__egc *egc, libxl__multidev *aodevs, int ret); @@ -1534,7 +1533,8 @@ retry_transaction: out: assert(ret); - spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, ret); + sdss->pvqemu.rc = ret; + spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu); } static void spawn_stub_launch_dm(libxl__egc *egc, @@ -1632,16 +1632,17 @@ static void spawn_stub_launch_dm(libxl__egc *egc, out: assert(ret); - spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu, ret); + sdss->pvqemu.rc = ret; + spawn_stubdom_pvqemu_cb(egc, &sdss->pvqemu); } static void spawn_stubdom_pvqemu_cb(libxl__egc *egc, - libxl__dm_spawn_state *stubdom_dmss, - int rc) + libxl__dm_spawn_state *stubdom_dmss) { libxl__stub_dm_spawn_state *sdss = CONTAINER_OF(stubdom_dmss, *sdss, pvqemu); STATE_AO_GC(sdss->dm.spawn.ao); + int rc = stubdom_dmss->rc; uint32_t dm_domid = sdss->pvqemu.guest_domid; libxl_domain_config *d_config = stubdom_dmss->guest_config; @@ -1712,7 +1713,8 @@ static void stubdom_xswait_cb(libxl__egc *egc, libxl__xswait_state *xswait, return; out: libxl__xswait_stop(gc, xswait); - sdss->callback(egc, &sdss->dm, rc); + sdss->dm.rc = rc; + sdss->callback(egc, &sdss->dm); } /* callbacks passed to libxl__spawn_spawn */ @@ -1929,7 +1931,8 @@ static void device_model_spawn_outcome(libxl__egc *egc, } out: - dmss->callback(egc, dmss, rc); + dmss->rc = rc; + dmss->callback(egc, dmss); } void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) @@ -2005,7 +2008,8 @@ error: assert(rc); if (logfile_w >= 0) close(logfile_w); if (null >= 0) close(null); - dmss->callback(egc, dmss, rc); + dmss->rc = rc; + dmss->callback(egc, dmss); return; } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 350ec29..82f264a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3413,12 +3413,13 @@ _hidden void libxl__add_vtpms(libxl__egc *egc, libxl__ao *ao, uint32_t domid, typedef struct libxl__dm_spawn_state libxl__dm_spawn_state; -typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*, - int rc /* if !0, error was logged */); +typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*); struct libxl__dm_spawn_state { /* mixed - spawn.ao must be initialised by user; rest is private: */ libxl__spawn_state spawn; + /* filled in by dm spawn just before making callback */ + int rc; /* if !0, error was logged */ /* filled in by user, must remain valid: */ uint32_t guest_domid; /* domain being served */ libxl_domain_config *guest_config;