xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: libxc: domain restore: fold redundant variables
Date: Mon, 24 Mar 2014 12:46:20 +0000	[thread overview]
Message-ID: <5330291C.6070300@citrix.com> (raw)
In-Reply-To: <53302F9D020000780000154B@nat28.tlf.novell.com>


[-- Attachment #1.1: Type: text/plain, Size: 5531 bytes --]

On 24/03/14 12:14, Jan Beulich wrote:
> "vcpuextstate_size" being non-zero fully expresses "vcpuextstate" being
> true - drop the latter.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Having just reverse engineered this as part of rewriting migration from
scratch, this looks accurate.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

>
> --- a/tools/libxc/xc_domain_restore.c
> +++ b/tools/libxc/xc_domain_restore.c
> @@ -248,7 +248,7 @@ static int uncanonicalize_pagetable(
>  static xen_pfn_t *load_p2m_frame_list(
>      xc_interface *xch, struct restore_ctx *ctx,
>      int io_fd, int *pae_extended_cr3, int *ext_vcpucontext,
> -    int *vcpuextstate, uint32_t *vcpuextstate_size)
> +    uint32_t *vcpuextstate_size)
>  {
>      xen_pfn_t *p2m_frame_list;
>      vcpu_guest_context_any_t ctxt;
> @@ -326,7 +326,6 @@ static xen_pfn_t *load_p2m_frame_list(
>              }
>              else if ( !strncmp(chunk_sig, "xcnt", 4) )
>              {
> -                *vcpuextstate = 1;
>                  if ( RDEXACT(io_fd, vcpuextstate_size, sizeof(*vcpuextstate_size)) )
>                  {
>                      PERROR("read extended vcpu state size failed");
> @@ -520,7 +519,7 @@ static int buffer_tail_hvm(xc_interface 
>                             struct tailbuf_hvm *buf, int fd,
>                             unsigned int max_vcpu_id, uint64_t *vcpumap,
>                             int ext_vcpucontext,
> -                           int vcpuextstate, uint32_t vcpuextstate_size)
> +                           uint32_t vcpuextstate_size)
>  {
>      uint8_t *tmp;
>      unsigned char qemusig[21];
> @@ -588,7 +587,6 @@ static int buffer_tail_pv(xc_interface *
>                            struct tailbuf_pv *buf, int fd,
>                            unsigned int max_vcpu_id, uint64_t *vcpumap,
>                            int ext_vcpucontext,
> -                          int vcpuextstate,
>                            uint32_t vcpuextstate_size)
>  {
>      unsigned int i;
> @@ -629,9 +627,7 @@ static int buffer_tail_pv(xc_interface *
>                 : sizeof(vcpu_guest_context_x86_32_t)) * buf->vcpucount;
>      if ( ext_vcpucontext )
>          vcpulen += 128 * buf->vcpucount;
> -    if ( vcpuextstate ) {
> -        vcpulen += vcpuextstate_size * buf->vcpucount;
> -    }
> +    vcpulen += vcpuextstate_size * buf->vcpucount;
>  
>      if ( !(buf->vcpubuf) ) {
>          if ( !(buf->vcpubuf = malloc(vcpulen)) ) {
> @@ -671,16 +667,14 @@ static int buffer_tail_pv(xc_interface *
>  static int buffer_tail(xc_interface *xch, struct restore_ctx *ctx,
>                         tailbuf_t *buf, int fd, unsigned int max_vcpu_id,
>                         uint64_t *vcpumap, int ext_vcpucontext,
> -                       int vcpuextstate, uint32_t vcpuextstate_size)
> +                       uint32_t vcpuextstate_size)
>  {
>      if ( buf->ishvm )
>          return buffer_tail_hvm(xch, ctx, &buf->u.hvm, fd, max_vcpu_id, vcpumap,
> -                               ext_vcpucontext, vcpuextstate,
> -                               vcpuextstate_size);
> +                               ext_vcpucontext, vcpuextstate_size);
>      else
>          return buffer_tail_pv(xch, ctx, &buf->u.pv, fd, max_vcpu_id, vcpumap,
> -                              ext_vcpucontext, vcpuextstate,
> -                              vcpuextstate_size);
> +                              ext_vcpucontext, vcpuextstate_size);
>  }
>  
>  static void tailbuf_free_hvm(struct tailbuf_hvm *buf)
> @@ -1421,7 +1415,6 @@ int xc_domain_restore(xc_interface *xch,
>      DECLARE_DOMCTL;
>      xc_dominfo_t info;
>      int rc = 1, frc, i, j, n, m, pae_extended_cr3 = 0, ext_vcpucontext = 0;
> -    int vcpuextstate = 0;
>      uint32_t vcpuextstate_size = 0;
>      unsigned long mfn, pfn;
>      int nraces = 0;
> @@ -1527,7 +1520,7 @@ int xc_domain_restore(xc_interface *xch,
>          /* Load the p2m frame list, plus potential extended info chunk */
>          p2m_frame_list = load_p2m_frame_list(xch, ctx,
>              io_fd, &pae_extended_cr3, &ext_vcpucontext,
> -            &vcpuextstate, &vcpuextstate_size);
> +            &vcpuextstate_size);
>  
>          if ( !p2m_frame_list )
>              goto out;
> @@ -1730,7 +1723,7 @@ int xc_domain_restore(xc_interface *xch,
>      if ( !ctx->completed ) {
>  
>          if ( buffer_tail(xch, ctx, &tailbuf, io_fd, max_vcpu_id, vcpumap,
> -                         ext_vcpucontext, vcpuextstate, vcpuextstate_size) < 0 ) {
> +                         ext_vcpucontext, vcpuextstate_size) < 0 ) {
>              ERROR ("error buffering image tail");
>              goto out;
>          }
> @@ -1783,7 +1776,7 @@ int xc_domain_restore(xc_interface *xch,
>      memset(&tmptail, 0, sizeof(tmptail));
>      tmptail.ishvm = hvm;
>      if ( buffer_tail(xch, ctx, &tmptail, io_fd, max_vcpu_id, vcpumap,
> -                     ext_vcpucontext, vcpuextstate, vcpuextstate_size) < 0 ) {
> +                     ext_vcpucontext, vcpuextstate_size) < 0 ) {
>          ERROR ("error buffering image tail, finishing");
>          goto out;
>      }
> @@ -2147,7 +2140,7 @@ int xc_domain_restore(xc_interface *xch,
>          }
>  
>   vcpu_ext_state_restore:
> -        if ( !vcpuextstate )
> +        if ( !vcpuextstate_size )
>              continue;
>  
>          memcpy(&domctl.u.vcpuextstate.xfeature_mask, vcpup,
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel


[-- Attachment #1.2: Type: text/html, Size: 6330 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2014-03-24 12:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-24 12:14 libxc: domain restore: fold redundant variables Jan Beulich
2014-03-24 12:46 ` Andrew Cooper [this message]
2014-03-27 16:45   ` 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=5330291C.6070300@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --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).