From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Frediano Ziglio <frediano.ziglio@citrix.com>,
David Vrabel <david.vrabel@citrix.com>,
Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v4 7/9] tools/libxc: x86 pv restore implementation
Date: Wed, 7 May 2014 16:37:31 +0100 [thread overview]
Message-ID: <536A533B.8070501@citrix.com> (raw)
In-Reply-To: <1399471843.13430.108.camel@kazak.uk.xensource.com>
On 07/05/14 15:10, Ian Campbell wrote:
>
>> + if ( xc_domain_getinfo(xch, dom, 1, &ctx.dominfo) != 1 )
>> + {
>> + PERROR("Failed to get domain info");
>> + return -1;
>> + }
>> +
>> + if ( ctx.dominfo.domid != dom )
>> + {
>> + ERROR("Domain %d does not exist", dom);
>> + return -1;
>> + }
>> +
>> + ctx.domid = dom;
>> + IPRINTF("Restoring domain %d", dom);
>> +
>> + if ( read_headers(&ctx) )
>> + return -1;
>> +
>> + if ( ctx.dominfo.hvm )
>> + {
>> + ERROR("HVM Restore not supported yet");
>> + return -1;
>> + }
>> + else
> Unneeded.
Perhaps, but it makes more readable patches as hvm restore is added later.
Furthermore, all of this will need tweaking when this series stops
trying to coexist alongside the legacy code.
>
>> +
>> +static int handle_x86_pv_vcpu_basic(struct context *ctx, struct record *rec)
>> +{
>> + xc_interface *xch = ctx->xch;
>> + struct rec_x86_pv_vcpu *vhdr = rec->data;
>> + vcpu_guest_context_any_t vcpu;
>> + size_t vcpusz = ctx->x86_pv.width == 8 ? sizeof vcpu.x64 : sizeof vcpu.x32;
>> + xen_pfn_t pfn, mfn;
>> + unsigned long tmp;
>> + unsigned i;
>> + int rc = -1;
>> +
>> + if ( rec->length <= sizeof *vhdr )
>> + {
>> + ERROR("X86_PV_VCPU_BASIC record trucated: length %"PRIu32", min %zu",
> "truncated"
>
>> + else if ( (ctx->x86_pv.pfn_types[pfn] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK) !=
>> + (((xen_pfn_t)ctx->x86_pv.levels) << XEN_DOMCTL_PFINFO_LTAB_SHIFT) )
> I'd think some temporaries would help with clarity here.
This was code largely cribbed from the legacy code, as it is gnarly and
brittle and I didn't fancy subtly breaking something in the middle. I
will see what I can do to clean it up.
>
>> +static int handle_x86_pv_vcpu_extended(struct context *ctx, struct record *rec)
>> +{
>> + xc_interface *xch = ctx->xch;
>> + struct rec_x86_pv_vcpu *vcpu = rec->data;
>> + DECLARE_DOMCTL;
>> +
>> + if ( rec->length <= sizeof *vcpu )
>> + {
>> + ERROR("X86_PV_VCPU_EXTENDED record trucated: length %"PRIu32", min %zu",
>> + rec->length, sizeof *vcpu + 1);
> I've just realised that there was a X86_PV_VCPU_EXTENDED in
> handle_x86_pv_vcpu_basic which was wrong, but I've trimmed it already so
> I'll comment here.
Noted.
>
>
>> + return -1;
>> + }
>> + else if ( rec->length > sizeof *vcpu + 128 )
> There's an awful lot of magic numbers throughout this series. Can we try
> and use meaningful symbolic names for things please.
This one, no. It is magic even in the legacy stream, and is sizeof
domctl.u on the sending toolstack, which thinking forward is not
necessarily sizeof domctl.u on the receiving toolstack.
>
>> +int restore_x86_pv(struct context *ctx)
>> +{
>> + xc_interface *xch = ctx->xch;
>> + struct record rec;
>> + int rc;
>> +
>> + IPRINTF("In experimental %s", __func__);
>> +
>> + if ( ctx->restore.guest_type != DHDR_TYPE_x86_pv )
>> + {
>> + ERROR("Unable to restore %s domain into an x86_pv domain",
>> + dhdr_type_to_str(ctx->restore.guest_type));
>> + return -1;
>> + }
>> + else if ( ctx->restore.guest_page_size != 4096 )
> #define's exist for this.
>
>> + /* all done */
>> + IPRINTF("All Done");
>> + assert(!rc);
>> + goto cleanup;
>> +
>> + err:
>> + assert(rc);
> FWIW I think you could drop this and let the success case fall through
> without the hop and a skip..
I would prefer not to. This assert has already caught 1 error of mine,
and I seem to remember also caught a bug in an early version of c/s
dda0b77d2caa
~Andrew
>
>> + cleanup:
>> +
>> + free(ctx->x86_pv.p2m);
>> + free(ctx->x86_pv.p2m_pfns);
>> + free(ctx->x86_pv.pfn_types);
>> + free(ctx->restore.populated_pfns);
>> +
>> + if ( ctx->x86_pv.m2p )
>> + munmap(ctx->x86_pv.m2p, ctx->x86_pv.nr_m2p_frames * PAGE_SIZE);
>> +
>> + return rc;
>> +}
>> +
>> +/*
>> + * Local variables:
>> + * mode: C
>> + * c-file-style: "BSD"
>> + * c-basic-offset: 4
>> + * tab-width: 4
>> + * indent-tabs-mode: nil
>> + * End:
>> + */
>
next prev parent reply other threads:[~2014-05-07 15:37 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-30 18:36 [PATCH v4 0/9] Migration Stream v2 Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 1/9] libxc: add DECLARE_HYPERCALL_BUFFER_SHADOW() Andrew Cooper
2014-05-07 11:45 ` Ian Campbell
2014-05-07 12:00 ` David Vrabel
2014-05-07 12:06 ` Ian Campbell
2014-04-30 18:36 ` [PATCH v4 2/9] [HACK] tools/libxc: save/restore v2 framework Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 3/9] tools/libxc: Stream specification and some common code Andrew Cooper
2014-05-07 11:57 ` Ian Campbell
2014-05-07 12:06 ` David Vrabel
2014-05-07 12:14 ` Andrew Cooper
2014-05-07 13:07 ` Ian Campbell
2014-05-07 13:20 ` Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 4/9] tools/libxc: Scripts for inspection/valdiation of legacy and new streams Andrew Cooper
2014-05-07 12:03 ` Ian Campbell
2014-05-07 12:08 ` David Vrabel
2014-05-07 12:27 ` Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 5/9] tools/libxc: common code Andrew Cooper
2014-05-07 13:03 ` Ian Campbell
2014-05-07 14:38 ` Andrew Cooper
2014-05-07 16:08 ` Ian Campbell
2014-05-07 16:30 ` Andrew Cooper
2014-05-07 16:35 ` Ian Campbell
2014-05-08 8:29 ` David Vrabel
2014-04-30 18:36 ` [PATCH v4 6/9] tools/libxc: x86 pv save implementation Andrew Cooper
2014-05-07 13:58 ` Ian Campbell
2014-05-07 15:20 ` Andrew Cooper
2014-05-07 16:15 ` Ian Campbell
2014-04-30 18:36 ` [PATCH v4 7/9] tools/libxc: x86 pv restore implementation Andrew Cooper
2014-05-07 14:10 ` Ian Campbell
2014-05-07 15:37 ` Andrew Cooper [this message]
2014-05-07 16:17 ` Ian Campbell
2014-04-30 18:36 ` [PATCH v4 8/9] tools/libxc: x86 hvm save implementation Andrew Cooper
2014-05-07 14:14 ` Ian Campbell
2014-05-07 15:39 ` Andrew Cooper
2014-04-30 18:36 ` [PATCH v4 9/9] tools/libxc: x86 hvm restore implementation Andrew Cooper
2014-05-07 14:15 ` Ian Campbell
2014-05-01 16:41 ` [PATCH v4 0/9] Migration Stream v2 Konrad Rzeszutek Wilk
2014-05-01 17:32 ` Andrew Cooper
2014-05-07 14:23 ` 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=536A533B.8070501@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=david.vrabel@citrix.com \
--cc=frediano.ziglio@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.