From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
xen-devel@lists.xen.org, stefano.stabellini@eu.citrix.com,
julien.grall@citrix.com
Cc: andrew.cooper3@citrix.com, Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH RFC XEN v1 11/14] tools: migrate: refactor selection of save/restore ops to be arch specific
Date: Wed, 9 Dec 2015 14:32:25 +0000 [thread overview]
Message-ID: <1449671548-4050-11-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1449671507.16124.264.camel@citrix.com>
I wasn't sure of the best way to achieve this, but a pair of per-arch
hooks seemed to be preferable to ifdeffery.
I also wasn't sure about the change to guest_type for save. The
restore half of the ctxt already has such a field but since the save
side treats it as an input to the process as opposed to the restore
side which determines it from the stream it seemed like keeping them
separate was best.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: andyhhp
---
tools/libxc/xc_sr_common.h | 15 +++++++++++++++
tools/libxc/xc_sr_common_x86.c | 22 ++++++++++++++++++++++
tools/libxc/xc_sr_restore.c | 15 +++------------
tools/libxc/xc_sr_save.c | 22 +++++++---------------
4 files changed, 47 insertions(+), 27 deletions(-)
diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h
index 64f6082..0d36c8d 100644
--- a/tools/libxc/xc_sr_common.h
+++ b/tools/libxc/xc_sr_common.h
@@ -174,6 +174,9 @@ struct xc_sr_context
struct xc_sr_save_ops ops;
struct save_callbacks *callbacks;
+ /* For Domain Header */
+ uint32_t guest_type;
+
/* Live migrate vs non live suspend. */
bool live;
@@ -317,9 +320,21 @@ struct xc_sr_context
extern struct xc_sr_save_ops save_ops_x86_pv;
extern struct xc_sr_save_ops save_ops_x86_hvm;
+extern struct xc_sr_save_ops save_ops_arm;
extern struct xc_sr_restore_ops restore_ops_x86_pv;
extern struct xc_sr_restore_ops restore_ops_x86_hvm;
+extern struct xc_sr_restore_ops restore_ops_arm;
+
+/*
+ * Arch function to select the correct ctx.{save,restore}.ops
+ * implementation for the guest. Will update the appropriate ops
+ * pointer.
+ *
+ * _save must also set ctx->save.guest_type.
+ */
+void xc_sr_select_restore_ops(struct xc_sr_context *ctx);
+void xc_sr_select_save_ops(struct xc_sr_context *ctx);
struct xc_sr_record
{
diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c
index 98f1cef..151bb0a 100644
--- a/tools/libxc/xc_sr_common_x86.c
+++ b/tools/libxc/xc_sr_common_x86.c
@@ -43,6 +43,28 @@ int handle_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec)
return 0;
}
+void xc_sr_select_save_ops(struct xc_sr_context *ctx)
+{
+ if ( ctx->dominfo.hvm )
+ {
+ ctx->save.guest_type = DHDR_TYPE_X86_HVM;
+ ctx->save.ops = save_ops_x86_hvm;
+ }
+ else
+ {
+ ctx->guest_type = DHDR_TYPE_X86_PV;
+ ctx->save.ops = save_ops_x86_pv;
+ }
+}
+
+void xc_sr_select_restore_ops(struct xc_sr_context *ctx)
+{
+ if ( ctx->dominfo.hvm )
+ ctx->restore.ops = restore_ops_x86_hvm;
+ else
+ ctx->restore.ops = restore_ops_x86_pv;
+}
+
/*
* Local variables:
* mode: C
diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c
index 05159bb..80f6bc5 100644
--- a/tools/libxc/xc_sr_restore.c
+++ b/tools/libxc/xc_sr_restore.c
@@ -763,18 +763,9 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom,
if ( read_headers(&ctx) )
return -1;
- if ( ctx.dominfo.hvm )
- {
- ctx.restore.ops = restore_ops_x86_hvm;
- if ( restore(&ctx) )
- return -1;
- }
- else
- {
- ctx.restore.ops = restore_ops_x86_pv;
- if ( restore(&ctx) )
- return -1;
- }
+ xc_sr_select_restore_ops(&ctx);
+ if ( restore(&ctx) )
+ return -1;
IPRINTF("XenStore: mfn %#"PRIpfn", dom %d, evt %u",
ctx.restore.xenstore_gfn,
diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c
index 0c12e56..e6e659d 100644
--- a/tools/libxc/xc_sr_save.c
+++ b/tools/libxc/xc_sr_save.c
@@ -6,7 +6,7 @@
/*
* Writes an Image header and Domain header into the stream.
*/
-static int write_headers(struct xc_sr_context *ctx, uint16_t guest_type)
+static int write_headers(struct xc_sr_context *ctx)
{
xc_interface *xch = ctx->xch;
int32_t xen_version = xc_version(xch, XENVER_version, NULL);
@@ -19,7 +19,7 @@ static int write_headers(struct xc_sr_context *ctx, uint16_t guest_type)
};
struct xc_sr_dhdr dhdr =
{
- .type = guest_type,
+ .type = ctx->save.guest_type,
.page_shift = XC_PAGE_SHIFT,
.xen_major = (xen_version >> 16) & 0xffff,
.xen_minor = (xen_version) & 0xffff,
@@ -724,13 +724,13 @@ static void cleanup(struct xc_sr_context *ctx)
/*
* Save a domain.
*/
-static int save(struct xc_sr_context *ctx, uint16_t guest_type)
+static int save(struct xc_sr_context *ctx)
{
xc_interface *xch = ctx->xch;
int rc, saved_rc = 0, saved_errno = 0;
IPRINTF("Saving domain %d, type %s",
- ctx->domid, dhdr_type_to_str(guest_type));
+ ctx->domid, dhdr_type_to_str(ctx->save.guest_type));
rc = setup(ctx);
if ( rc )
@@ -738,7 +738,7 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type)
xc_report_progress_single(xch, "Start of stream");
- rc = write_headers(ctx, guest_type);
+ rc = write_headers(ctx);
if ( rc )
goto err;
@@ -884,16 +884,8 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom,
return -1;
}
- if ( ctx.dominfo.hvm )
- {
- ctx.save.ops = save_ops_x86_hvm;
- return save(&ctx, DHDR_TYPE_X86_HVM);
- }
- else
- {
- ctx.save.ops = save_ops_x86_pv;
- return save(&ctx, DHDR_TYPE_X86_PV);
- }
+ xc_sr_select_save_ops(&ctx);
+ return save(&ctx);
}
/*
--
2.6.1
next prev parent reply other threads:[~2015-12-09 14:32 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-09 14:31 [PATCH RFC v1 00/14] xen: arm: support for save restore and dead migration Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 01/14] xen: arm: Add gic_hw_desc Ian Campbell
2015-12-15 16:15 ` Stefano Stabellini
2015-12-15 16:21 ` Ian Campbell
2015-12-15 16:35 ` Andrew Cooper
2015-12-15 16:56 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 02/14] xen: arm: Provide a mechanism to read (and decode) an LR from a saved VCPU Ian Campbell
2015-12-15 16:22 ` Stefano Stabellini
2015-12-09 14:32 ` [PATCH RFC XEN v1 03/14] xen: arm: switch arch_do_domctl to a common exit path Ian Campbell
2015-12-15 16:34 ` Stefano Stabellini
2015-12-15 16:57 ` Ian Campbell
2015-12-15 17:07 ` Andrew Cooper
2015-12-15 17:11 ` Jan Beulich
2015-12-09 14:32 ` [PATCH RFC XEN v1 04/14] xen: arm: Implement XEN_DOMCTL_getpageframeinfo3 Ian Campbell
2015-12-15 16:44 ` Stefano Stabellini
2015-12-09 14:32 ` [PATCH RFC XEN v1 05/14] xen: arm: Implement basic XEN_DOMCTL_{set, get}hvmcontext support Ian Campbell
2015-12-15 18:00 ` Stefano Stabellini
2015-12-16 10:18 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 06/14] xen: arm: Add some basic platform info to save header Ian Campbell
2015-12-15 18:37 ` Stefano Stabellini
2015-12-16 10:20 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 07/14] xen: arm: Save and restore basic per-VCPU state Ian Campbell
2015-12-16 14:55 ` Stefano Stabellini
2015-12-16 15:04 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 08/14] xen: arm: Save and restore arch timer state Ian Campbell
2015-12-16 15:53 ` Stefano Stabellini
2015-12-16 16:02 ` Ian Campbell
2015-12-16 16:17 ` Julien Grall
2015-12-16 16:37 ` Ian Campbell
2015-12-16 18:05 ` Stefano Stabellini
2015-12-17 9:33 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 09/14] xen: arm: Save and restore GIC state Ian Campbell
2015-12-16 18:30 ` Stefano Stabellini
2015-12-17 9:54 ` Ian Campbell
2015-12-22 16:44 ` Stefano Stabellini
2015-12-09 14:32 ` [PATCH RFC XEN v1 10/14] tools: Switch a few CONFIG_MIGRATE features to CONFIG_X86 Ian Campbell
2015-12-09 15:16 ` Andrew Cooper
2015-12-09 14:32 ` Ian Campbell [this message]
2015-12-09 15:26 ` [PATCH RFC XEN v1 11/14] tools: migrate: refactor selection of save/restore ops to be arch specific Andrew Cooper
2015-12-09 15:33 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 12/14] tools: libxc: implement modify_returncode for ARM Ian Campbell
2015-12-16 16:22 ` Stefano Stabellini
2015-12-16 16:36 ` Ian Campbell
2015-12-09 14:32 ` [PATCH RFC XEN v1 13/14] tools: libxc: wire up migration " Ian Campbell
2015-12-09 15:48 ` Andrew Cooper
2015-12-09 14:32 ` [PATCH RFC XEN v1 14/14] tools/libxl: BODGE ARM save/restore and (dead) migration Ian Campbell
2015-12-09 14:33 ` [PATCH RFC LINUX v1] xen: arm: enable migration on ARM Ian Campbell
2016-01-06 17:47 ` Stefano Stabellini
2016-01-06 17:57 ` Stefano Stabellini
2016-01-07 9:47 ` Ian Campbell
2016-01-07 9:43 ` Ian Campbell
2016-01-06 17:55 ` Stefano Stabellini
2016-01-07 9:47 ` Ian Campbell
2016-01-07 11:32 ` Stefano Stabellini
2015-12-09 15:51 ` [PATCH RFC v1 00/14] xen: arm: support for save restore and dead migration Andrew Cooper
2015-12-09 16:09 ` 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=1449671548-4050-11-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=julien.grall@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).