From nobody Mon Feb 9 22:24:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580136098045473.02371377120085; Mon, 27 Jan 2020 06:41:38 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iw5ZX-0003Fi-0k; Mon, 27 Jan 2020 14:41:03 +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 1iw5ZV-0003Ee-IY for xen-devel@lists.xenproject.org; Mon, 27 Jan 2020 14:41:01 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 090e335c-4113-11ea-855d-12813bfff9fa; Mon, 27 Jan 2020 14:41:00 +0000 (UTC) X-Inumbo-ID: 090e335c-4113-11ea-855d-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1580136060; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=UNm4zczGTkV6kuIslxpw7OwaP9zsTScDkSBhFsLwK+k=; b=DvtpZI/qcssvtjiiIW8J9uwGqIwoZkpaE3cOYAqdrwcib3xE4H3ZWrY9 +txN7pbX8M4uGUG5e7N6HinNQ13R/5a1QSlIfEuqDIk6b5P12UBZ9GWUo VGEP3+RPUlzs6jzbDX9o6h2mqwqjnYRl6li6YwbS/v/nXnAc3cXoc1hPc Y=; Authentication-Results: esa4.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 (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Cbo4zisRT1ImK31wSjt/X7yFLMCHfc+COFa0Eq3+BIiEhdIv++cX7DvUUbVsqmguc50jmK6gpZ KBZVUXK6izi5l50T7lk9T8iaXvUIcpKiW0bdwAlb3t42DWsIQoSUYLcc9jf1/9gfh8m1JoGGp/ bFRb3k4RlLKa9C0R1Gsn89cNstuJjwe6V4iIoQyj2jBLp/T7eJZ1xEcEop2XP8ultozXF4ctgy J/GoYMl2OhNk2VBl4qq9yQbRePeSHqtBo2gfU3Ki2WAvn6Cs3Cti3ByRnA90NsJDhHT0MbJYHs i9Y= X-SBRS: 2.7 X-MesageID: 12093218 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,370,1574139600"; d="scan'208";a="12093218" From: Andrew Cooper To: Xen-devel Date: Mon, 27 Jan 2020 14:34:42 +0000 Message-ID: <20200127143444.25538-16-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200127143444.25538-1-andrew.cooper3@citrix.com> References: <20200127143444.25538-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 15/17] tools/libx[cl]: Plumb 'missing' through 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Pre Xen-4.14 streams will not contain any CPUID/MSR information. There is nothing libxc can do about this, and will have to rely on the higher level toolstack to provide backwards compatibility. To facilitate this, extend the static_data_done() callback, highlighting the missing information, and modify libxl to use it. At the libxc level, this requires an arch-specific hook which, for now, always reports CPUID and MSR= as missing. This will be adjusted in a later change. No overall functional change - this is just plumbing. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD v2: * Split/rearrange from v1 * Don't re-evalute 'k' on migrate --- tools/libxc/include/xenguest.h | 12 ++++++++++-- tools/libxc/xc_sr_common.h | 9 +++++++++ tools/libxc/xc_sr_common_x86.c | 8 ++++++++ tools/libxc/xc_sr_common_x86.h | 5 +++++ tools/libxc/xc_sr_restore.c | 7 ++++++- tools/libxc/xc_sr_restore_x86_hvm.c | 1 + tools/libxc/xc_sr_restore_x86_pv.c | 1 + tools/libxl/libxl_create.c | 18 ++++++++++++++---- tools/libxl/libxl_save_msgs_gen.pl | 2 +- 9 files changed, 55 insertions(+), 8 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index b4df8d0ffe..7a12d21ff2 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -139,8 +139,16 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint3= 2_t dom, =20 /* callbacks provided by xc_domain_restore */ struct restore_callbacks { - /* Called once the STATIC_DATA_END record has been received/inferred. = */ - int (*static_data_done)(void *data); + /* + * Called once the STATIC_DATA_END record has been received/inferred. + * + * For compatibility with older streams, provides a list of static data + * expected to be found in the stream, which was missing. A higher le= vel + * toolstack is responsible for providing any necessary compatibiltiy. + */ +#define XGR_SDD_MISSING_CPUID (1 << 0) +#define XGR_SDD_MISSING_MSR (1 << 1) + int (*static_data_done)(unsigned int missing, void *data); =20 /* Called after a new checkpoint to suspend the guest. */ int (*suspend)(void *data); diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index 7742260690..f3bdea8006 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -159,6 +159,15 @@ struct xc_sr_restore_ops int (*process_record)(struct xc_sr_context *ctx, struct xc_sr_record *= rec); =20 /** + * Perform any actions required after the static data has arrived. Ca= lled + * when the STATIC_DATA_COMPLETE record has been recieved/inferred. + * 'missing' should be filled in for any data item the higher level + * toolstack needs to provide compatiblity for. + */ + int (*static_data_complete)(struct xc_sr_context *ctx, + unsigned int *missing); + + /** * Perform any actions required after the stream has been finished. Ca= lled * after the END record has been received. */ diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 6267655dab..a849891634 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -132,6 +132,14 @@ int handle_x86_msr_policy(struct xc_sr_context *ctx, s= truct xc_sr_record *rec) return rc; } =20 +int x86_static_data_complete(struct xc_sr_context *ctx, unsigned int *miss= ing) +{ + /* TODO: Become conditional on there being no data in the stream. */ + *missing =3D XGR_SDD_MISSING_MSR | XGR_SDD_MISSING_CPUID; + + return 0; +} + /* * Local variables: * mode: C diff --git a/tools/libxc/xc_sr_common_x86.h b/tools/libxc/xc_sr_common_x86.h index d1050981dd..e08d81e0e7 100644 --- a/tools/libxc/xc_sr_common_x86.h +++ b/tools/libxc/xc_sr_common_x86.h @@ -34,6 +34,11 @@ int handle_x86_cpuid_policy(struct xc_sr_context *ctx, int handle_x86_msr_policy(struct xc_sr_context *ctx, struct xc_sr_record *rec); =20 +/* + * Perform common x86 actions required after the static data has arrived. + */ +int x86_static_data_complete(struct xc_sr_context *ctx, unsigned int *miss= ing); + #endif /* * Local variables: diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index bb94cd879d..bc811e6e3a 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -659,6 +659,7 @@ static int buffer_record(struct xc_sr_context *ctx, str= uct xc_sr_record *rec) int handle_static_data_end(struct xc_sr_context *ctx) { xc_interface *xch =3D ctx->xch; + unsigned int missing =3D 0; int rc =3D 0; =20 if ( ctx->restore.seen_static_data_end ) @@ -669,9 +670,13 @@ int handle_static_data_end(struct xc_sr_context *ctx) =20 ctx->restore.seen_static_data_end =3D true; =20 + rc =3D ctx->restore.ops.static_data_complete(ctx, &missing); + if ( rc ) + return rc; + if ( ctx->restore.callbacks->static_data_done && (rc =3D ctx->restore.callbacks->static_data_done( - ctx->restore.callbacks->data) !=3D 0) ) + missing, ctx->restore.callbacks->data) !=3D 0) ) ERROR("static_data_done() callback failed: %d\n", rc); =20 return rc; diff --git a/tools/libxc/xc_sr_restore_x86_hvm.c b/tools/libxc/xc_sr_restor= e_x86_hvm.c index cef99e0397..9190edaee7 100644 --- a/tools/libxc/xc_sr_restore_x86_hvm.c +++ b/tools/libxc/xc_sr_restore_x86_hvm.c @@ -248,6 +248,7 @@ struct xc_sr_restore_ops restore_ops_x86_hvm =3D .localise_page =3D x86_hvm_localise_page, .setup =3D x86_hvm_setup, .process_record =3D x86_hvm_process_record, + .static_data_complete =3D x86_static_data_complete, .stream_complete =3D x86_hvm_stream_complete, .cleanup =3D x86_hvm_cleanup, }; diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xc_sr_restore= _x86_pv.c index 3aac4bd502..1252cd1310 100644 --- a/tools/libxc/xc_sr_restore_x86_pv.c +++ b/tools/libxc/xc_sr_restore_x86_pv.c @@ -1194,6 +1194,7 @@ struct xc_sr_restore_ops restore_ops_x86_pv =3D .localise_page =3D x86_pv_localise_page, .setup =3D x86_pv_setup, .process_record =3D x86_pv_process_record, + .static_data_complete =3D x86_static_data_complete, .stream_complete =3D x86_pv_stream_complete, .cleanup =3D x86_pv_cleanup, }; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 09f84858d5..1d54cdc429 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1298,7 +1298,8 @@ static void libxl__colo_restore_setup_done(libxl__egc= *egc, libxl__stream_read_start(egc, &dcs->srs); } =20 -int libxl__srm_callout_callback_static_data_done(void *user) +int libxl__srm_callout_callback_static_data_done(unsigned int missing, + void *user) { libxl__save_helper_state *shs =3D user; libxl__domain_create_state *dcs =3D shs->caller_state; @@ -1308,9 +1309,18 @@ int libxl__srm_callout_callback_static_data_done(voi= d *user) const libxl_domain_config *d_config =3D dcs->guest_config; const libxl_domain_build_info *info =3D &d_config->b_info; =20 - libxl__cpuid_apply_policy(ctx, dcs->guest_domid); - if (info->cpuid !=3D NULL) - libxl__cpuid_set(ctx, dcs->guest_domid, info->cpuid); + /* + * CPUID/MSR information is not present in pre Xen-4.14 streams. + * + * Libxl used to always regenerate the CPUID policy from first princip= les + * on migrate. Continue to do so for backwards compatibility when the + * stream doesn't contain any CPUID data. + */ + if (missing & XGR_SDD_MISSING_CPUID) { + libxl__cpuid_apply_policy(ctx, dcs->guest_domid); + if (info->cpuid !=3D NULL) + libxl__cpuid_set(ctx, dcs->guest_domid, info->cpuid); + } =20 return 0; } diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_ms= gs_gen.pl index 93dc252370..5bfbd4fd10 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -29,7 +29,7 @@ our @msgs =3D ( [ 'srcxA', "wait_checkpoint", [] ], [ 'scxA', "switch_qemu_logdirty", [qw(uint32_t domid unsigned enable)] ], - [ 'rcxW', "static_data_done", [] ], + [ '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 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel