From patchwork Fri Jan 3 20:51:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11317395 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 8F185138D for ; Fri, 3 Jan 2020 20:53:19 +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 6088F215A4 for ; Fri, 3 Jan 2020 20:53:19 +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="WtNgDB4l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6088F215A4 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 1inTv6-0006Xq-Ld; Fri, 03 Jan 2020 20:51:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inTv5-0006Xl-NU for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 20:51:43 +0000 X-Inumbo-ID: d3acf2bc-2e6a-11ea-88e7-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d3acf2bc-2e6a-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 20:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578084695; h=from:to:cc:subject:date:message-id:mime-version; bh=T0TvO4PiyCyyWHTsS8KfWe2W+1u04UiKwZdmhF+XwMk=; b=WtNgDB4l/hmsMri0/JWglt0N28AKw2eikVjVXLUf6nnMCeu83/4Ie0ut Yx73dWiGlAf82+roqhoLX2tWyH8HqgvwzGB1F8Jjyc0KqVJT6HlzgmCy3 v/zZ8/Za278ihUtXGkw1kUeN/d5oL+GAu/WLF/cuhC4USL9BtLQWKl6wc Q=; 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: 7dvzsJr1hO0sBh6PKCpkKe4mi6WlqGL5MdermXE5a1qTO9XYtP1Z+SYOGY8QOiS2w88FW76cdM gH8LBbiiNHDPwFoOSZzlaeDVRmxwAB/Bm9f1ceeCsnseBN0nZBAJeMXc7p+yo3d5NXQalilgSW hYB+B9y3qMDPpeoiNqNYM/Tt+gPJvwljxEslMMkoFYdaJWoBO2g7xkfgz52qctbzBVPv+fw1Hp t6XSLidSpiSvpjYA9yKIGieS+V1r/7HtZtz0CQsLzMUboul6KLxJyLTn3V0+2rXx857a/pNA+W 80w= X-SBRS: 2.7 X-MesageID: 10424784 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,392,1571716800"; d="scan'208";a="10424784" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 20:51:30 +0000 Message-ID: <20200103205130.9785-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 --- 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")) {