From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xen.org, Ian.Campbell@citrix.com,
ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com,
wei.liu2@citrix.com, andrew.cooper3@citrix.com
Cc: Juergen Gross <jgross@suse.com>
Subject: [PATCH v4 1/4] libxc: split mapping p2m leaves into a separate function
Date: Thu, 7 Jan 2016 13:36:51 +0100 [thread overview]
Message-ID: <1452170214-17821-2-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1452170214-17821-1-git-send-email-jgross@suse.com>
In order to prepare using the virtual mapped linear p2m list for
migration split mapping of the p2m leaf pages into a separate function.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
tools/libxc/xc_sr_save_x86_pv.c | 77 ++++++++++++++++++++++++-----------------
1 file changed, 45 insertions(+), 32 deletions(-)
diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c
index c8d6f0b..d7acd37 100644
--- a/tools/libxc/xc_sr_save_x86_pv.c
+++ b/tools/libxc/xc_sr_save_x86_pv.c
@@ -68,6 +68,50 @@ static int copy_mfns_from_guest(const struct xc_sr_context *ctx,
}
/*
+ * Map the p2m leave pages and build an array of their pfns.
+ */
+static int map_p2m_leaves(struct xc_sr_context *ctx, xen_pfn_t *mfns,
+ size_t n_mfns)
+{
+ xc_interface *xch = ctx->xch;
+ unsigned x;
+
+ ctx->x86_pv.p2m = xc_map_foreign_pages(xch, ctx->domid, PROT_READ,
+ mfns, n_mfns);
+ if ( !ctx->x86_pv.p2m )
+ {
+ PERROR("Failed to map p2m frames");
+ return -1;
+ }
+
+ ctx->save.p2m_size = ctx->x86_pv.max_pfn + 1;
+ ctx->x86_pv.p2m_frames = n_mfns;
+ ctx->x86_pv.p2m_pfns = malloc(n_mfns * sizeof(*mfns));
+ if ( !ctx->x86_pv.p2m_pfns )
+ {
+ ERROR("Cannot allocate %zu bytes for p2m pfns list",
+ n_mfns * sizeof(*mfns));
+ return -1;
+ }
+
+ /* Convert leaf frames from mfns to pfns. */
+ for ( x = 0; x < n_mfns; ++x )
+ {
+ if ( !mfn_in_pseudophysmap(ctx, mfns[x]) )
+ {
+ ERROR("Bad mfn in p2m_frame_list[%u]", x);
+ dump_bad_pseudophysmap_entry(ctx, mfns[x]);
+ errno = ERANGE;
+ return -1;
+ }
+
+ ctx->x86_pv.p2m_pfns[x] = mfn_to_pfn(ctx, mfns[x]);
+ }
+
+ return 0;
+}
+
+/*
* Walk the guests frame list list and frame list to identify and map the
* frames making up the guests p2m table. Construct a list of pfns making up
* the table.
@@ -173,7 +217,6 @@ static int map_p2m(struct xc_sr_context *ctx)
ctx->x86_pv.p2m_frames = (ctx->x86_pv.max_pfn + fpp) / fpp;
DPRINTF("max_pfn %#lx, p2m_frames %d", ctx->x86_pv.max_pfn,
ctx->x86_pv.p2m_frames);
- ctx->save.p2m_size = ctx->x86_pv.max_pfn + 1;
fl_entries = (ctx->x86_pv.max_pfn / fpp) + 1;
/* Map the guest mid p2m frames. */
@@ -211,38 +254,8 @@ static int map_p2m(struct xc_sr_context *ctx)
}
/* Map the p2m leaves themselves. */
- ctx->x86_pv.p2m = xc_map_foreign_pages(xch, ctx->domid, PROT_READ,
- local_fl, fl_entries);
- if ( !ctx->x86_pv.p2m )
- {
- PERROR("Failed to map p2m frames");
- goto err;
- }
+ rc = map_p2m_leaves(ctx, local_fl, fl_entries);
- ctx->x86_pv.p2m_frames = fl_entries;
- ctx->x86_pv.p2m_pfns = malloc(local_fl_size);
- if ( !ctx->x86_pv.p2m_pfns )
- {
- ERROR("Cannot allocate %zu bytes for p2m pfns list",
- local_fl_size);
- goto err;
- }
-
- /* Convert leaf frames from mfns to pfns. */
- for ( x = 0; x < fl_entries; ++x )
- {
- if ( !mfn_in_pseudophysmap(ctx, local_fl[x]) )
- {
- ERROR("Bad mfn in p2m_frame_list[%u]", x);
- dump_bad_pseudophysmap_entry(ctx, local_fl[x]);
- errno = ERANGE;
- goto err;
- }
-
- ctx->x86_pv.p2m_pfns[x] = mfn_to_pfn(ctx, local_fl[x]);
- }
-
- rc = 0;
err:
free(local_fl);
--
2.6.2
next prev parent reply other threads:[~2016-01-07 12:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 12:36 [PATCH v4 0/4] support linear p2m list in migrate stream v2 Juergen Gross
2016-01-07 12:36 ` Juergen Gross [this message]
2016-01-07 12:36 ` [PATCH v4 2/4] libxc: support of linear p2m list for migration of pv-domains Juergen Gross
2016-01-07 12:36 ` [PATCH v4 3/4] libxc: stop migration in case of p2m list structural changes Juergen Gross
2016-01-07 12:36 ` [PATCH v4 4/4] libxc: set flag for support of linear p2m list in domain builder Juergen Gross
2016-01-07 13:23 ` [PATCH v4 0/4] support linear p2m list in migrate stream v2 Ian Campbell
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=1452170214-17821-2-git-send-email-jgross@suse.com \
--to=jgross@suse.com \
--cc=Ian.Campbell@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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).