[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] HVM: clean up hvm_save_one()



commit 6378ceeec7dfa648b4d75b313a614a0008c51fdf
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jun 14 11:39:06 2017 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jun 14 11:39:06 2017 +0200

    HVM: clean up hvm_save_one()
    
    Eliminate the for_each_vcpu() loop and the associated local variables,
    don't override the save handler's return code, and correct formatting.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/common/hvm/save.c | 35 +++++++++++++----------------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/xen/common/hvm/save.c b/xen/common/hvm/save.c
index 045e5a3..1a7135e 100644
--- a/xen/common/hvm/save.c
+++ b/xen/common/hvm/save.c
@@ -79,36 +79,27 @@ size_t hvm_save_size(struct domain *d)
 int hvm_save_one(struct domain *d, unsigned int typecode, unsigned int 
instance,
                  XEN_GUEST_HANDLE_64(uint8) handle, uint64_t *bufsz)
 {
-    int rv = -ENOENT;
-    size_t sz = 0;
-    struct vcpu *v;
-    hvm_domain_context_t ctxt = { 0, };
+    int rv;
+    hvm_domain_context_t ctxt = { };
     const struct hvm_save_descriptor *desc;
 
-    if ( d->is_dying 
-         || typecode > HVM_SAVE_CODE_MAX 
-         || hvm_sr_handlers[typecode].size < sizeof(*desc)
-         || hvm_sr_handlers[typecode].save == NULL )
+    if ( d->is_dying ||
+         typecode > HVM_SAVE_CODE_MAX ||
+         hvm_sr_handlers[typecode].size < sizeof(*desc) ||
+         !hvm_sr_handlers[typecode].save )
         return -EINVAL;
 
+    ctxt.size = hvm_sr_handlers[typecode].size;
     if ( hvm_sr_handlers[typecode].kind == HVMSR_PER_VCPU )
-        for_each_vcpu(d, v)
-            sz += hvm_sr_handlers[typecode].size;
-    else 
-        sz = hvm_sr_handlers[typecode].size;
-    
-    ctxt.size = sz;
-    ctxt.data = xmalloc_bytes(sz);
+        ctxt.size *= d->max_vcpus;
+    ctxt.data = xmalloc_bytes(ctxt.size);
     if ( !ctxt.data )
         return -ENOMEM;
 
-    if ( hvm_sr_handlers[typecode].save(d, &ctxt) != 0 )
-    {
-        printk(XENLOG_G_ERR "HVM%d save: failed to save type %"PRIu16"\n",
-               d->domain_id, typecode);
-        rv = -EFAULT;
-    }
-    else if ( ctxt.cur >= sizeof(*desc) )
+    if ( (rv = hvm_sr_handlers[typecode].save(d, &ctxt)) != 0 )
+        printk(XENLOG_G_ERR "HVM%d save: failed to save type %"PRIu16" (%d)\n",
+               d->domain_id, typecode, rv);
+    else if ( rv = -ENOENT, ctxt.cur >= sizeof(*desc) )
     {
         uint32_t off;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.