From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: libxc: domain restore: fold redundant variables Date: Mon, 24 Mar 2014 12:46:20 +0000 Message-ID: <5330291C.6070300@citrix.com> References: <53302F9D020000780000154B@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0105149084839463350==" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WS4Gn-0002jE-VZ for xen-devel@lists.xenproject.org; Mon, 24 Mar 2014 12:46:26 +0000 In-Reply-To: <53302F9D020000780000154B@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Ian Campbell , xen-devel , Ian Jackson List-Id: xen-devel@lists.xenproject.org --===============0105149084839463350== Content-Type: multipart/alternative; boundary="------------060401000609080807030502" --------------060401000609080807030502 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit 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 Having just reverse engineered this as part of rewriting migration from scratch, this looks accurate. Reviewed-by: Andrew Cooper > > --- 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 --------------060401000609080807030502 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
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

--------------060401000609080807030502-- --===============0105149084839463350== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============0105149084839463350==--