From patchwork Fri Jan 3 13:06:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316907 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 04284109A for ; Fri, 3 Jan 2020 13:08:05 +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 D3BC520866 for ; Fri, 3 Jan 2020 13:08:04 +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="C4VkVu4Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3BC520866 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 1inMfN-0004ED-6d; Fri, 03 Jan 2020 13:07:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inMfM-0004DX-8V for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:07:00 +0000 X-Inumbo-ID: e49a8fc6-2e29-11ea-a914-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e49a8fc6-2e29-11ea-a914-bc764e2007e4; Fri, 03 Jan 2020 13:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=PHP2KunlTWORkKc8EeqqmVhshlq7AlcvEna5zhXo66M=; b=C4VkVu4ZPU3+9AexlW++lW1Yewlx1uKYJYhmwbt+3rF4msAWvtFqRjlv UDrispWNckaq4+6Dkv+M5VsWgdS4YjX1+Ht7+2lwrC7DrQjaV4wRI7oXt cIsb8B4c/r9txLGd3xBP8ey8DKWpszqlhX4ZNXbdoItPONItRcDFPFdDh s=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: iy6gUgXeuZl6uXIjKSuftEPHCTLrunRcpPynxXgyD7E63ttotEyIXxT9nNGR3yK41WF0b99R8S OG14qvBgImhI4iJsoctcHqlQgZoYRIxMB9jI6x7Gh+n7IG5kcA2nais83fklZu+mWlq7g+SR0l M1ZL5u83OBmz9x7G19yuDTBdvnjUZXVuf7KmmjG4iUeOTezRPY07ZNnzPhp6Z0fPgGaslilTGZ kj+sFOkvQo7/CSzESjxM3fYtH9ztxojGWVdlHhiiT0p/MFep9w4vc7omF29Mki7aSCmscF7GMr IFs= X-SBRS: 2.7 X-MesageID: 10571945 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,390,1571716800"; d="scan'208";a="10571945" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:13 +0000 Message-ID: <20200103130616.13724-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 17/20] tools/libx[cl]: Plumb static_data_done() up into libxl 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" libxl is going to have to provide compatibility for pre 4.14 streams which don't contain CPUID information. Introduce the static_data_done() callback and plumb it up into libxl. No overall change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxc/include/xenguest.h | 9 +++++++++ tools/libxc/xc_sr_common_x86.c | 13 ++++++++++++- tools/libxc/xc_sr_restore.c | 1 + tools/libxl/libxl_create.c | 13 +++++++++++++ tools/libxl/libxl_save_msgs_gen.pl | 1 + 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index d81baa6cc2..be80544bd0 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -140,6 +140,15 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, /* callbacks provided by xc_domain_restore */ struct restore_callbacks { + /* + * Called once the STATIC_DATA_END record has been received/inferred. + * Passes in the blocks of static data which have not been received, which + * the higher level toolstack must provide backwards compatibility for. + */ +#define XGR_SDD_MISSING_CPUID (1 << 0) +#define XGR_SDD_MISSING_MSR (1 << 1) + int (*static_data_done)(unsigned int missing, void *data); + /* Called after a new checkpoint to suspend the guest. */ int (*suspend)(void *data); diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 09fb1d93d6..c3d1d30d91 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -44,9 +44,20 @@ int handle_x86_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec) int x86_static_data_complete(struct xc_sr_context *ctx) { + xc_interface *xch = ctx->xch; + unsigned int missing = 0; + int rc; + /* TODO - something useful. */ + missing = XGR_SDD_MISSING_MSR | XGR_SDD_MISSING_CPUID; - return 0; + rc = ctx->restore.callbacks->static_data_done( + missing, ctx->restore.callbacks->data); + + if ( rc ) + ERROR("static_data_done() callback failed: %d\n", rc); + + return rc; } int write_x86_cpu_policy_records(struct xc_sr_context *ctx) diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index d4bd60a31e..09d8a08316 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -908,6 +908,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, assert(callbacks->checkpoint); /* Fallthrough */ case XC_STREAM_PLAIN: + assert(callbacks->static_data_done); break; default: diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 32d45dcef0..fdc76917dc 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1227,6 +1227,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.dcs = dcs; /* Restore */ + callbacks->static_data_done = libxl__srm_callout_callback_static_data_done; callbacks->restore_results = libxl__srm_callout_callback_restore_results; /* COLO only supports HVM now because it does not work very @@ -1296,6 +1297,18 @@ static void libxl__colo_restore_setup_done(libxl__egc *egc, libxl__stream_read_start(egc, &dcs->srs); } +int libxl__srm_callout_callback_static_data_done(unsigned int missing, + void *user) +{ + libxl__save_helper_state *shs = user; + libxl__domain_create_state *dcs = shs->caller_state; + STATE_AO_GC(dcs->ao); + + /* TODO - something useful. */ + + return 0; +} + void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn, xen_pfn_t console_mfn, void *user) { diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_msgs_gen.pl index 831a15e0bb..5bfbd4fd10 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -29,6 +29,7 @@ our @msgs = ( [ 'srcxA', "wait_checkpoint", [] ], [ 'scxA', "switch_qemu_logdirty", [qw(uint32_t domid unsigned enable)] ], + [ 'rcxW', "static_data_done", [qw(unsigned missing)] ], [ 'rcx', "restore_results", ['xen_pfn_t', 'store_gfn', 'xen_pfn_t', 'console_gfn'] ], [ 'srW', "complete", [qw(int retval