All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 3/4] tools/libxc: Avoid generating inappropriate zero-length records
Date: Mon, 25 Jul 2016 10:45:53 +0100	[thread overview]
Message-ID: <20160725094553.GE1008@citrix.com> (raw)
In-Reply-To: <1469121457-365-4-git-send-email-andrew.cooper3@citrix.com>

On Thu, Jul 21, 2016 at 06:17:36PM +0100, Andrew Cooper wrote:
> It was never intended for records such as these to be sent with zero content.
> 

Wouldn't it be better to modify write_split_record to ignore zero
content instead of patching up different places?

> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxc/xc_sr_save_x86_hvm.c |  4 ++++
>  tools/libxc/xc_sr_save_x86_pv.c  | 12 ++++++++++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c
> index ba50a43..5401bf9 100644
> --- a/tools/libxc/xc_sr_save_x86_hvm.c
> +++ b/tools/libxc/xc_sr_save_x86_hvm.c
> @@ -112,6 +112,10 @@ static int write_hvm_params(struct xc_sr_context *ctx)
>          }
>      }
>  
> +    /* No params? Skip this record. */
> +    if ( hdr.count == 0 )
> +        return 0;
> +
>      rc = write_split_record(ctx, &rec, entries, hdr.count * sizeof(*entries));
>      if ( rc )
>          PERROR("Failed to write HVM_PARAMS record");
> diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c
> index 4a29460..5fb9f2f 100644
> --- a/tools/libxc/xc_sr_save_x86_pv.c
> +++ b/tools/libxc/xc_sr_save_x86_pv.c
> @@ -607,6 +607,10 @@ static int write_one_vcpu_extended(struct xc_sr_context *ctx, uint32_t id)
>          return -1;
>      }
>  
> +    /* No content? Skip the record. */
> +    if ( domctl.u.ext_vcpucontext.size == 0 )
> +        return 0;
> +
>      return write_split_record(ctx, &rec, &domctl.u.ext_vcpucontext,
>                                domctl.u.ext_vcpucontext.size);
>  }
> @@ -662,6 +666,10 @@ static int write_one_vcpu_xsave(struct xc_sr_context *ctx, uint32_t id)
>          goto err;
>      }
>  
> +    /* No xsave state? Skip this record. */
> +    if ( domctl.u.vcpuextstate.size == 0 )
> +        goto out;
> +
>      rc = write_split_record(ctx, &rec, buffer, domctl.u.vcpuextstate.size);
>      if ( rc )
>          goto err;
> @@ -728,6 +736,10 @@ static int write_one_vcpu_msrs(struct xc_sr_context *ctx, uint32_t id)
>          goto err;
>      }
>  
> +    /* No MSRs? Skip this record. */
> +    if ( domctl.u.vcpu_msrs.msr_count == 0 )
> +        goto out;
> +
>      rc = write_split_record(ctx, &rec, buffer,
>                              domctl.u.vcpu_msrs.msr_count *
>                              sizeof(xen_domctl_vcpu_msr_t));
> -- 
> 2.1.4
> 

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

  reply	other threads:[~2016-07-25  9:45 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-21 17:17 [PATCH RFC 0/4] Fix issues with zero-length records in migration v2 Andrew Cooper
2016-07-21 17:17 ` [PATCH 1/4] docs: Clarify the expected behaviour of zero length records Andrew Cooper
2016-07-25  9:45   ` Wei Liu
2016-07-25 10:21   ` David Vrabel
2016-07-25 10:25     ` Andrew Cooper
2016-07-25 10:35       ` David Vrabel
2016-07-25 10:38         ` Andrew Cooper
2016-07-25 10:44           ` David Vrabel
2016-07-25 10:45             ` Andrew Cooper
2016-07-25 11:18   ` Ian Jackson
2016-07-21 17:17 ` [PATCH 2/4] tools/libxc: Tolerate zero-length records in migration v2 streams Andrew Cooper
2016-07-25  9:46   ` Wei Liu
2016-07-25 12:21   ` David Vrabel
2016-07-25 12:46     ` Andrew Cooper
2016-07-25 13:00       ` David Vrabel
2016-07-21 17:17 ` [PATCH 3/4] tools/libxc: Avoid generating inappropriate zero-length records Andrew Cooper
2016-07-25  9:45   ` Wei Liu [this message]
2016-07-25  9:57     ` Andrew Cooper
2016-07-25 10:14       ` Wei Liu
2016-07-25 10:32   ` David Vrabel
2016-07-25 11:44     ` Ian Jackson
2016-07-25 17:15     ` Ian Jackson
2016-07-26  9:23       ` Wei Liu
2016-07-26 13:37         ` Ian Jackson
2016-07-21 17:17 ` [PATCH 4/4] tools/python: Adjust migration v2 library to warn about " Andrew Cooper
2016-07-25  9:46   ` Wei Liu
2017-03-14 13:20 ` [PATCH RFC 0/4] Fix issues with zero-length records in migration v2 Julien Grall
2017-03-14 13:50   ` Andrew Cooper
2017-03-14 14:21     ` Wei Liu
2017-03-28 18:24       ` Julien Grall

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=20160725094553.GE1008@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=Ian.Jackson@eu.citrix.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.