From patchwork Mon Jan 6 17:03:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EF071395 for ; Mon, 6 Jan 2020 17:05:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 160122072A for ; Mon, 6 Jan 2020 17:05:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="TNU1R0N4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 160122072A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioVnK-0004gv-Dz; Mon, 06 Jan 2020 17:03:58 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioVnI-0004gq-MI for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 17:03:56 +0000 X-Inumbo-ID: 85a45bda-30a6-11ea-ab37-12813bfff9fa Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 85a45bda-30a6-11ea-ab37-12813bfff9fa; Mon, 06 Jan 2020 17:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578330236; h=from:to:cc:subject:date:message-id:mime-version; bh=T0TvO4PiyCyyWHTsS8KfWe2W+1u04UiKwZdmhF+XwMk=; b=TNU1R0N4tv189GN3GqfdBgT/aZeeKGjM7rTOPBOyUPn5ucMLoAfHTSd8 T2zU3VlmUPU4Mm/sDzc9QoFyBuS8kokbsv7Rm92Kd9s9sB4OiOpbwuTPh wcTCO5oHrZ8RqnWYPyepj5lzEBjcpomM+qL38wgtuCsdR8x1xh9L2Ii+m w=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: a/Xu7BCyw9E0864JQE2DDcssl5rufYgudbqWUTo9pauoi/+YIGGyXYS1CFv6gEW7gQUYBH4buy at6fCzfGxaGnQWDonqrnGyMr2//T3XX2VemdoE9dDGqTDIONAkxNrdSNzHP1ajj5JD6Xk1H1Yn 6WBRXu6CsrmjW/JX7xb+vIqXZ+q4f8i6bE7Y3RhIFpp0SS2jSRPwtTUj1q7oIyzY2CMRTiu5kZ E/AMsd8qjlbZ95KzhJ0287UdACiBCpn8hmkaRvt9g2QRDGJAdsCO9kBR3erjM9fImzgrGxvmuQ 0CA= X-SBRS: 2.7 X-MesageID: 10494209 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,403,1571716800"; d="scan'208";a="10494209" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 17:03:52 +0000 Message-ID: <20200106170352.28582-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] tools/save: Drop unused parameters from xc_domain_save() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" XCFLAGS_CHECKPOINT_COMPRESS has been unused since c/s b15bc4345 (2015), XCFLAGS_HVM since c/s 9e8672f1c (2013), and XCFLAGS_STDVGA since c/s 087d43326 (2007). Drop the constants, and code which sets them. The separate hvm parameter (appeared in c/s d11bec8a1, 2007 and ultimately redundant with XCFLAGS_HVM), is used for sanity checking and debug printing, then discarded and replaced with Xen's idea of whether the domain is PV or HVM. Rearrange the logic in xc_domain_save() to ask Xen sightly earlier, and use a consistent idea of 'hvm' throughout. Removing this parameter removes the final user of libxl's dss->hvm, so drop that field as well. Update the doxygen comment to be accurate. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxc/include/xenguest.h | 15 +++++++-------- tools/libxc/xc_nomigrate.c | 2 +- tools/libxc/xc_sr_save.c | 31 ++++++++++++++++--------------- tools/libxl/libxl_dom_save.c | 21 +-------------------- tools/libxl/libxl_internal.h | 1 - tools/libxl/libxl_save_callout.c | 2 +- tools/libxl/libxl_save_helper.c | 3 +-- 7 files changed, 27 insertions(+), 48 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index fdb03e32da..1c358a0577 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -26,9 +26,6 @@ #define XCFLAGS_LIVE (1 << 0) #define XCFLAGS_DEBUG (1 << 1) -#define XCFLAGS_HVM (1 << 2) -#define XCFLAGS_STDVGA (1 << 3) -#define XCFLAGS_CHECKPOINT_COMPRESS (1 << 4) #define X86_64_B_SIZE 64 #define X86_32_B_SIZE 32 @@ -124,16 +121,18 @@ typedef enum { /** * This function will save a running domain. * - * @parm xch a handle to an open hypervisor interface - * @parm fd the file descriptor to save a domain to - * @parm dom the id of the domain + * @param xch a handle to an open hypervisor interface + * @param io_fd the file descriptor to save a domain to + * @param dom the id of the domain + * @param flags XCFLAGS_xxx * @param stream_type XC_MIG_STREAM_NONE if the far end of the stream * doesn't use checkpointing + * @param recv_fd Only used for XC_MIG_STREAM_COLO. Contains backchannel from + * the destination side. * @return 0 on success, -1 on failure */ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, - uint32_t flags /* XCFLAGS_xxx */, - struct save_callbacks* callbacks, int hvm, + uint32_t flags, struct save_callbacks *callbacks, xc_migration_stream_t stream_type, int recv_fd); /* callbacks provided by xc_domain_restore */ diff --git a/tools/libxc/xc_nomigrate.c b/tools/libxc/xc_nomigrate.c index c4dca88eb0..5a1d7e46f9 100644 --- a/tools/libxc/xc_nomigrate.c +++ b/tools/libxc/xc_nomigrate.c @@ -21,7 +21,7 @@ #include int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t flags, - struct save_callbacks* callbacks, int hvm, + struct save_callbacks *callbacks, xc_migration_stream_t stream_type, int recv_fd) { errno = ENOSYS; diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index 5a40e588e0..6f61f85ee0 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -967,7 +967,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t flags, struct save_callbacks* callbacks, - int hvm, xc_migration_stream_t stream_type, int recv_fd) + xc_migration_stream_t stream_type, int recv_fd) { struct xc_sr_context ctx = { @@ -982,32 +982,33 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, ctx.save.checkpointed = stream_type; ctx.save.recv_fd = recv_fd; + if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) != 1 ) + { + PERROR("Failed to get domain info"); + return -1; + } + + if ( ctx.dominfo.domid != dom ) + { + ERROR("Domain %u does not exist", dom); + return -1; + } + /* If altering migration_stream update this assert too. */ assert(stream_type == XC_MIG_STREAM_NONE || stream_type == XC_MIG_STREAM_REMUS || stream_type == XC_MIG_STREAM_COLO); /* Sanity checks for callbacks. */ - if ( hvm ) + if ( ctx.dominfo.hvm ) assert(callbacks->switch_qemu_logdirty); if ( ctx.save.checkpointed ) assert(callbacks->checkpoint && callbacks->postcopy); if ( ctx.save.checkpointed == XC_MIG_STREAM_COLO ) assert(callbacks->wait_checkpoint); - DPRINTF("fd %d, dom %u, flags %u, hvm %d", io_fd, dom, flags, hvm); - - if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) != 1 ) - { - PERROR("Failed to get domain info"); - return -1; - } - - if ( ctx.dominfo.domid != dom ) - { - ERROR("Domain %u does not exist", dom); - return -1; - } + DPRINTF("fd %d, dom %u, flags %u, hvm %d", + io_fd, dom, flags, ctx.dominfo.hvm); ctx.domid = dom; diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c index 65610e6055..32e3cb5a13 100644 --- a/tools/libxl/libxl_dom_save.c +++ b/tools/libxl/libxl_dom_save.c @@ -408,22 +408,8 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) rc = libxl__domain_suspend_init(egc, dsps, type); if (rc) goto out; - switch (type) { - case LIBXL_DOMAIN_TYPE_PVH: - case LIBXL_DOMAIN_TYPE_HVM: { - dss->hvm = 1; - break; - } - case LIBXL_DOMAIN_TYPE_PV: - dss->hvm = 0; - break; - default: - abort(); - } - dss->xcflags = (live ? XCFLAGS_LIVE : 0) - | (debug ? XCFLAGS_DEBUG : 0) - | (dss->hvm ? XCFLAGS_HVM : 0); + | (debug ? XCFLAGS_DEBUG : 0); /* Disallow saving a guest with vNUMA configured because migration * stream does not preserve node information. @@ -440,11 +426,6 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss) goto out; } - if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_REMUS) { - if (libxl_defbool_val(r_info->compression)) - dss->xcflags |= XCFLAGS_CHECKPOINT_COMPRESS; - } - if (dss->checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_NONE) callbacks->suspend = libxl__domain_suspend_callback; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index a99f3627e4..ba8c9b41ab 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -3591,7 +3591,6 @@ struct libxl__domain_save_state { const libxl_domain_remus_info *remus; /* private */ int rc; - int hvm; int xcflags; libxl__domain_suspend_state dsps; union { diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c index caa1396813..0b11495f9b 100644 --- a/tools/libxl/libxl_save_callout.c +++ b/tools/libxl/libxl_save_callout.c @@ -87,7 +87,7 @@ void libxl__xc_domain_save(libxl__egc *egc, libxl__domain_save_state *dss, libxl__srm_callout_enumcallbacks_save(&shs->callbacks.save.a); const unsigned long argnums[] = { - dss->domid, dss->xcflags, dss->hvm, cbflags, + dss->domid, dss->xcflags, cbflags, dss->checkpointed_stream, }; diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index cdad40be4f..0f52930c45 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -252,7 +252,6 @@ int main(int argc, char **argv) recv_fd = atoi(NEXTARG); uint32_t dom = strtoul(NEXTARG,0,10); uint32_t flags = strtoul(NEXTARG,0,10); - int hvm = atoi(NEXTARG); unsigned cbflags = strtoul(NEXTARG,0,10); xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10); assert(!*++argv); @@ -263,7 +262,7 @@ int main(int argc, char **argv) setup_signals(save_signal_handler); r = xc_domain_save(xch, io_fd, dom, flags, &helper_save_callbacks, - hvm, stream_type, recv_fd); + stream_type, recv_fd); complete(r); } else if (!strcmp(mode,"--restore-domain")) {