xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* libxc: domain restore: fold redundant variables
@ 2014-03-24 12:14 Jan Beulich
  2014-03-24 12:46 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2014-03-24 12:14 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Campbell, Ian Jackson

[-- Attachment #1: Type: text/plain, Size: 5080 bytes --]

"vcpuextstate_size" being non-zero fully expresses "vcpuextstate" being
true - drop the latter.

Signed-off-by: Jan Beulich <jbeulich@suse.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,



[-- Attachment #2: libxc-domain-restore-vcpuextstate.patch --]
[-- Type: text/plain, Size: 5127 bytes --]

libxc: domain restore: fold redundant variables

"vcpuextstate_size" being non-zero fully expresses "vcpuextstate" being
true - drop the latter.

Signed-off-by: Jan Beulich <jbeulich@suse.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,

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

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libxc: domain restore: fold redundant variables
  2014-03-24 12:14 libxc: domain restore: fold redundant variables Jan Beulich
@ 2014-03-24 12:46 ` Andrew Cooper
  2014-03-27 16:45   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2014-03-24 12:46 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Ian Campbell, xen-devel, Ian Jackson


[-- 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libxc: domain restore: fold redundant variables
  2014-03-24 12:46 ` Andrew Cooper
@ 2014-03-27 16:45   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2014-03-27 16:45 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel, Ian Jackson, Jan Beulich

On Mon, 2014-03-24 at 12:46 +0000, Andrew Cooper wrote:
> 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>

Acked + applied, thanks guys.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-27 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-24 12:14 libxc: domain restore: fold redundant variables Jan Beulich
2014-03-24 12:46 ` Andrew Cooper
2014-03-27 16:45   ` Ian Campbell

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).