From: Wen Congyang <ghostwcy@gmail.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [Patch v6 11/13] tools/libxc: x86 HVM restore code
Date: Fri, 18 Jul 2014 22:38:50 +0800 [thread overview]
Message-ID: <53C9317A.9090701@gmail.com> (raw)
In-Reply-To: <1404754682-28379-12-git-send-email-andrew.cooper3@citrix.com>
At 2014/7/8 1:38, Andrew Cooper Wrote:
> Restore the x86 HVM specific parts of a domain. This is the HVM_CONTEXT and
> HVM_PARAMS records.
>
> There is no need for any page localisation.
>
> This also includes writing the trailing qemu save record to a file because
> this is what libxc currently does. This is intended to be moved into libxl
> proper in the future.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> tools/libxc/saverestore/common.h | 1 +
> tools/libxc/saverestore/restore_x86_hvm.c | 336 +++++++++++++++++++++++++++++
> 2 files changed, 337 insertions(+)
> create mode 100644 tools/libxc/saverestore/restore_x86_hvm.c
>
> diff --git a/tools/libxc/saverestore/common.h b/tools/libxc/saverestore/common.h
> index 8d125f9..4894cac 100644
> --- a/tools/libxc/saverestore/common.h
> +++ b/tools/libxc/saverestore/common.h
> @@ -241,6 +241,7 @@ extern struct xc_sr_save_ops save_ops_x86_pv;
> extern struct xc_sr_save_ops save_ops_x86_hvm;
>
> extern struct xc_sr_restore_ops restore_ops_x86_pv;
> +extern struct xc_sr_restore_ops restore_ops_x86_hvm;
>
> struct xc_sr_record
> {
> diff --git a/tools/libxc/saverestore/restore_x86_hvm.c b/tools/libxc/saverestore/restore_x86_hvm.c
> new file mode 100644
> index 0000000..0004dee
> --- /dev/null
> +++ b/tools/libxc/saverestore/restore_x86_hvm.c
> @@ -0,0 +1,336 @@
> +#include <assert.h>
> +#include <arpa/inet.h>
> +
> +#include "common_x86.h"
> +
> +/* TODO: remove */
> +static int handle_toolstack(struct xc_sr_context *ctx, struct xc_sr_record *rec)
> +{
> + xc_interface *xch = ctx->xch;
> + int rc;
> +
> + if ( !ctx->restore.callbacks || !ctx->restore.callbacks->toolstack_restore )
> + return 0;
> +
> + rc = ctx->restore.callbacks->toolstack_restore(ctx->domid, rec->data, rec->length,
> + ctx->restore.callbacks->data);
> + if ( rc < 0 )
> + PERROR("restoring toolstack");
> + return rc;
> +}
> +
> +/*
> + * Process an HVM_CONTEXT record from the stream.
> + */
> +static int handle_hvm_context(struct xc_sr_context *ctx, struct xc_sr_record *rec)
> +{
> + xc_interface *xch = ctx->xch;
> + int rc;
> +
> + rc = xc_domain_hvm_setcontext(xch, ctx->domid, rec->data, rec->length);
> + if ( rc < 0 )
> + PERROR("Unable to restore HVM context");
> + return rc;
> +}
> +
> +/*
> + * Process an HVM_PARAMS record from the stream.
> + */
> +static int handle_hvm_params(struct xc_sr_context *ctx, struct xc_sr_record *rec)
> +{
> + xc_interface *xch = ctx->xch;
> + struct xc_sr_rec_hvm_params *hdr = rec->data;
> + struct xc_sr_rec_hvm_params_entry *entry = hdr->param;
> + unsigned int i;
> + int rc;
> +
> + if ( rec->length < sizeof(*hdr)
> + || rec->length < sizeof(*hdr) + hdr->count * sizeof(*entry) )
> + {
> + ERROR("hvm_params record is too short");
> + return -1;
> + }
> +
> + for ( i = 0; i < hdr->count; i++, entry++ )
> + {
> + switch ( entry->index )
> + {
> + case HVM_PARAM_CONSOLE_PFN:
> + ctx->restore.console_mfn = entry->value;
> + xc_clear_domain_page(xch, ctx->domid, entry->value);
> + break;
> + case HVM_PARAM_STORE_PFN:
> + ctx->restore.xenstore_mfn = entry->value;
> + xc_clear_domain_page(xch, ctx->domid, entry->value);
> + break;
> + case HVM_PARAM_IOREQ_PFN:
> + case HVM_PARAM_BUFIOREQ_PFN:
> + xc_clear_domain_page(xch, ctx->domid, entry->value);
ioreq page may contain pending i/o request, so I think we should not clear
them.
Thanks
Wen Congyang
> + break;
> + }
> +
> + rc = xc_set_hvm_param(xch, ctx->domid, entry->index, entry->value);
> + if ( rc < 0 )
> + {
> + PERROR("set HVM param %"PRId64" = 0x%016"PRIx64,
> + entry->index, entry->value);
> + return rc;
> + }
> + }
> + return 0;
> +}
> +
next prev parent reply other threads:[~2014-07-18 14:38 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 17:37 [PATCH v6 0/13] Migration Stream v2 Andrew Cooper
2014-07-07 17:37 ` [Patch v6 01/13] docs: libxc migration stream specification Andrew Cooper
2014-07-08 3:53 ` Hongyang Yang
2014-07-08 8:48 ` Andrew Cooper
2014-07-08 8:59 ` Hongyang Yang
2014-07-08 9:36 ` David Vrabel
2014-07-08 10:48 ` Andrew Cooper
2014-07-07 17:37 ` [Patch v6 02/13] tools/python: Scripts relating to migrationv2 streams Andrew Cooper
2014-07-28 15:20 ` Ian Campbell
2014-07-28 15:38 ` Andrew Cooper
2014-07-28 15:58 ` Ian Campbell
2014-07-29 13:55 ` Jon Ludlam
2014-07-07 17:37 ` [Patch v6 03/13] [HACK] tools/libxc: save/restore v2 framework Andrew Cooper
2014-07-07 17:37 ` [Patch v6 04/13] tools/libxc: C implementation of stream format Andrew Cooper
2014-07-07 17:37 ` [Patch v6 05/13] tools/libxc: noarch common code Andrew Cooper
2014-07-07 17:37 ` [Patch v6 06/13] tools/libxc: x86 " Andrew Cooper
2014-07-07 17:37 ` [Patch v6 07/13] tools/libxc: x86 PV " Andrew Cooper
2014-07-07 17:37 ` [Patch v6 08/13] tools/libxc: x86 PV save code Andrew Cooper
2014-07-07 17:37 ` [Patch v6 09/13] tools/libxc: x86 PV restore code Andrew Cooper
2014-07-07 17:37 ` [Patch v6 10/13] tools/libxc: x86 HVM save code Andrew Cooper
2014-07-07 17:38 ` [Patch v6 11/13] tools/libxc: x86 HVM restore code Andrew Cooper
2014-07-18 14:38 ` Wen Congyang [this message]
2014-07-18 15:09 ` Andrew Cooper
2014-07-18 15:42 ` Paul Durrant
2014-07-18 16:13 ` Wen Congyang
2014-07-07 17:38 ` [Patch v6 12/13] tools/libxc: noarch save code Andrew Cooper
2014-07-07 17:38 ` [Patch v6 13/13] tools/libxc: noarch restore code Andrew Cooper
2014-07-08 10:50 ` [PATCH v6 0/13] Migration Stream v2 David Vrabel
2014-07-08 11:10 ` Ian Campbell
2014-07-08 16:35 ` Konrad Rzeszutek Wilk
2014-07-08 17:35 ` Andrew Cooper
2014-07-09 6:01 ` Hongyang Yang
2014-07-09 9:40 ` Andrew Cooper
2014-07-09 15:27 ` Konrad Rzeszutek Wilk
2014-07-10 10:19 ` Andrew Cooper
2014-07-28 15:01 ` Ian Campbell
2014-07-28 15:02 ` Andrew Cooper
2014-07-28 15:20 ` 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=53C9317A.9090701@gmail.com \
--to=ghostwcy@gmail.com \
--cc=andrew.cooper3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.