From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
Ian Jackson <Ian.Jackson@citrix.com>
Subject: [Xen-devel] [PATCH 12/12] libxc/save: Write X86_{CPUID, MSR}_DATA records
Date: Tue, 24 Dec 2019 15:19:32 +0000 [thread overview]
Message-ID: <20191224151932.6304-13-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20191224151932.6304-1-andrew.cooper3@citrix.com>
With all other plumbing in place, obtain the CPU Policy from Xen and
write it into the migration stream.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <Ian.Jackson@citrix.com>
CC: Wei Liu <wl@xen.org>
---
tools/libxc/xc_sr_common_x86.c | 50 ++++++++++++++++++++++++++++++++++++++++
tools/libxc/xc_sr_common_x86.h | 6 +++++
tools/libxc/xc_sr_save_x86_hvm.c | 2 +-
tools/libxc/xc_sr_save_x86_pv.c | 3 ++-
4 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c
index d4d86bb12f..09fb1d93d6 100644
--- a/tools/libxc/xc_sr_common_x86.c
+++ b/tools/libxc/xc_sr_common_x86.c
@@ -49,6 +49,56 @@ int x86_static_data_complete(struct xc_sr_context *ctx)
return 0;
}
+int write_x86_cpu_policy_records(struct xc_sr_context *ctx)
+{
+ xc_interface *xch = ctx->xch;
+ struct xc_sr_record cpuid = { .type = REC_TYPE_X86_CPUID_POLICY, };
+ struct xc_sr_record msrs = { .type = REC_TYPE_X86_MSR_POLICY, };
+ uint32_t nr_leaves = 0, nr_msrs = 0;
+ int rc;
+
+ if ( xc_get_cpu_policy_size(xch, &nr_leaves, &nr_msrs) < 0 )
+ {
+ PERROR("Unable to get CPU Policy size");
+ return -1;
+ }
+
+ cpuid.data = malloc(nr_leaves * sizeof(xen_cpuid_leaf_t));
+ msrs.data = malloc(nr_msrs * sizeof(xen_msr_entry_t));
+ if ( !cpuid.data || !msrs.data )
+ {
+ ERROR("Cannot allocate memory for CPU Policy");
+ rc = -1;
+ goto out;
+ }
+
+ if ( xc_get_domain_cpu_policy(xch, ctx->domid, &nr_leaves, cpuid.data,
+ &nr_msrs, msrs.data) )
+ {
+ PERROR("Unable to get d%d CPU Policy", ctx->domid);
+ rc = -1;
+ goto out;
+ }
+
+ cpuid.length = nr_leaves * sizeof(xen_cpuid_leaf_t);
+ if ( cpuid.length )
+ {
+ rc = write_record(ctx, &cpuid);
+ if ( rc )
+ goto out;
+ }
+
+ msrs.length = nr_msrs * sizeof(xen_msr_entry_t);
+ if ( msrs.length )
+ rc = write_record(ctx, &msrs);
+
+ out:
+ free(cpuid.data);
+ free(msrs.data);
+
+ return rc;
+}
+
int handle_x86_cpuid_policy(struct xc_sr_context *ctx, struct xc_sr_record *rec)
{
xc_interface *xch = ctx->xch;
diff --git a/tools/libxc/xc_sr_common_x86.h b/tools/libxc/xc_sr_common_x86.h
index f7fa4fe62b..7b1823eca9 100644
--- a/tools/libxc/xc_sr_common_x86.h
+++ b/tools/libxc/xc_sr_common_x86.h
@@ -20,6 +20,12 @@ 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);
/*
+ * Obtains a domains CPU Policy from Xen, and writes X86_{CPUID,MSR}_POLICY
+ * records into the stream.
+ */
+int write_x86_cpu_policy_records(struct xc_sr_context *ctx);
+
+/*
* Parses an X86_CPUID_POLICY record and stashes the content for application
* when a STATIC_DATA_END record is encountered.
*/
diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c
index c146e827bc..5b95d20b19 100644
--- a/tools/libxc/xc_sr_save_x86_hvm.c
+++ b/tools/libxc/xc_sr_save_x86_hvm.c
@@ -172,7 +172,7 @@ static int x86_hvm_setup(struct xc_sr_context *ctx)
static int x86_hvm_static_data(struct xc_sr_context *ctx)
{
- return 0;
+ return write_x86_cpu_policy_records(ctx);
}
static int x86_hvm_start_of_stream(struct xc_sr_context *ctx)
diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c
index 9d1ca6ead7..2e9aa9ea16 100644
--- a/tools/libxc/xc_sr_save_x86_pv.c
+++ b/tools/libxc/xc_sr_save_x86_pv.c
@@ -1030,7 +1030,8 @@ static int x86_pv_setup(struct xc_sr_context *ctx)
static int x86_pv_static_data(struct xc_sr_context *ctx)
{
- return write_x86_pv_info(ctx);
+ return (write_x86_pv_info(ctx) ?:
+ write_x86_cpu_policy_records(ctx));
}
static int x86_pv_start_of_stream(struct xc_sr_context *ctx)
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-12-24 15:41 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-24 15:19 [Xen-devel] [PATCH 00/12] Support CPUID/MSR data in migration streams Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 01/12] libxc/save: Shrink code volume where possible Andrew Cooper
2020-01-14 16:48 ` Ian Jackson
2020-01-14 16:55 ` Ian Jackson
2020-01-15 19:22 ` Andrew Cooper
2020-04-27 17:19 ` Ian Jackson
2020-04-27 19:55 ` Wei Liu
2020-04-27 20:00 ` Andrew Cooper
2020-04-28 9:46 ` Wei Liu
2019-12-24 15:19 ` [Xen-devel] [PATCH 02/12] libxc/restore: Introduce functionality to simplify blob handling Andrew Cooper
2020-01-14 16:50 ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 03/12] libxc/migration: Rationalise the 'checkpointed' field to 'stream_type' Andrew Cooper
2020-01-14 15:58 ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 04/12] libxc/migration: Adjust layout of struct xc_sr_context Andrew Cooper
2020-01-14 16:04 ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 05/12] tools/migration: Drop IHDR_VERSION constant from libxc and python Andrew Cooper
2020-01-14 16:05 ` Ian Jackson
2020-01-15 15:29 ` Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 06/12] docs/migration Specify migration v3 and STATIC_DATA_END Andrew Cooper
2020-01-03 14:44 ` Jan Beulich
2020-01-09 14:54 ` Andrew Cooper
2020-01-14 16:07 ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 07/12] python/migration: Update validation logic to understand a v3 stream Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 08/12] libxc/restore: Support v3 streams, and cope with v2 compatibilty Andrew Cooper
2020-01-14 17:02 ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 09/12] libxc/save: Write a v3 stream Andrew Cooper
2020-01-14 17:05 ` Ian Jackson
2019-12-24 15:19 ` [Xen-devel] [PATCH 10/12] docs/migration: Specify X86_{CPUID, MSR}_POLICY records Andrew Cooper
2020-01-03 14:49 ` Jan Beulich
2020-01-03 14:55 ` Andrew Cooper
2020-01-03 15:30 ` Jan Beulich
2020-01-09 15:30 ` Andrew Cooper
2020-01-14 16:12 ` Ian Jackson
2020-01-15 15:48 ` Andrew Cooper
2020-01-14 16:08 ` Ian Jackson
2020-01-15 15:36 ` Andrew Cooper
2019-12-24 15:19 ` [Xen-devel] [PATCH 11/12] libxc/restore: Handle X86_{CPUID, MSR}_DATA records Andrew Cooper
2020-01-14 17:16 ` Ian Jackson
2019-12-24 15:19 ` Andrew Cooper [this message]
2020-01-14 17:21 ` [Xen-devel] [PATCH 12/12] libxc/save: Write " Ian Jackson
2020-01-15 15:52 ` Andrew Cooper
2020-01-03 13:06 ` [Xen-devel] [PATCH] Use CPUID/MSR data from migration streams Andrew Cooper
2020-01-03 13:06 ` [Xen-devel] [PATCH 15/20] fixup tools/migration: Formatting and style cleanup Andrew Cooper
2020-01-03 13:06 ` [Xen-devel] [PATCH 16/20] tools/libxl: Simplify callback handling in libxl-save-helper Andrew Cooper
2020-01-14 17:27 ` Ian Jackson
2020-01-15 16:16 ` Andrew Cooper
2020-01-03 13:06 ` [Xen-devel] [PATCH 17/20] tools/libx[cl]: Plumb static_data_done() up into libxl Andrew Cooper
2020-01-14 17:30 ` Ian Jackson
2020-01-15 16:34 ` Andrew Cooper
2020-05-29 15:58 ` Ian Jackson
2020-01-03 13:06 ` [Xen-devel] [PATCH 18/20] tools/libxl: Plumb domain_create_state down into libxl__build_pre() Andrew Cooper
2020-01-14 17:32 ` Ian Jackson
2020-01-03 13:06 ` [Xen-devel] [PATCH 19/20] tools/libxl: Re-position CPUID handling during domain construction Andrew Cooper
2020-01-14 17:33 ` Ian Jackson
2020-01-14 17:51 ` Andrew Cooper
2020-01-14 18:12 ` Ian Jackson
2020-01-03 13:06 ` [Xen-devel] [PATCH 20/20] tools/libxc: Restore CPUID/MSR data found in the migration stream Andrew Cooper
2020-01-14 17:34 ` Ian Jackson
2020-01-15 18:53 ` [Xen-devel] [PATCH 0.5/12] tools/migration: Formatting and style cleanup Andrew Cooper
2020-01-15 21:26 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191224151932.6304-13-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).