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

[Xen-changelog] [xen-unstable] xen: Simplify callers of boot_vcpu(). In VCPUOP_up, check



# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1327054435 0
# Node ID a3f67482c3216681394c857729e0f08315cbe46a
# Parent  2273ef2083d4a369044bdd8677635e0c0c3ae594
xen: Simplify callers of boot_vcpu(). In VCPUOP_up, check
is_initialised under the per-domain lock.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 2273ef2083d4 -r a3f67482c321 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Thu Jan 19 13:09:23 2012 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Fri Jan 20 10:13:55 2012 +0000
@@ -685,11 +685,7 @@
     }
 
     /* Need to init this vcpu before loading its contents */
-    rc = 0;
-    domain_lock(d);
-    if ( !v->is_initialised )
-        rc = boot_vcpu(d, vcpuid, NULL);
-    domain_unlock(d);
+    rc = boot_vcpu(d, vcpuid, NULL);
     if ( rc != 0 )
         return rc;
 
diff -r 2273ef2083d4 -r a3f67482c321 xen/common/compat/domain.c
--- a/xen/common/compat/domain.c        Thu Jan 19 13:09:23 2012 +0000
+++ b/xen/common/compat/domain.c        Fri Jan 20 10:13:55 2012 +0000
@@ -46,11 +46,7 @@
             break;
         }
 
-        domain_lock(d);
-        rc = -EEXIST;
-        if ( !v->is_initialised )
-            rc = boot_vcpu(d, vcpuid, cmp_ctxt);
-        domain_unlock(d);
+        rc = boot_vcpu(d, vcpuid, cmp_ctxt);
 
         xfree(cmp_ctxt);
         break;
diff -r 2273ef2083d4 -r a3f67482c321 xen/common/domain.c
--- a/xen/common/domain.c       Thu Jan 19 13:09:23 2012 +0000
+++ b/xen/common/domain.c       Fri Jan 20 10:13:55 2012 +0000
@@ -781,10 +781,13 @@
 int boot_vcpu(struct domain *d, int vcpuid, vcpu_guest_context_u ctxt)
 {
     struct vcpu *v = d->vcpu[vcpuid];
+    int rc;
 
-    BUG_ON(v->is_initialised);
+    domain_lock(d);
+    rc = v->is_initialised ? -EEXIST : arch_set_info_guest(v, ctxt);
+    domain_unlock(d);
 
-    return arch_set_info_guest(v, ctxt);
+    return rc;
 }
 
 void vcpu_reset(struct vcpu *v)
@@ -844,23 +847,23 @@
             return -EFAULT;
         }
 
-        domain_lock(d);
-        rc = -EEXIST;
-        if ( !v->is_initialised )
-            rc = boot_vcpu(d, vcpuid, ctxt);
-        domain_unlock(d);
+        rc = boot_vcpu(d, vcpuid, ctxt);
 
         free_vcpu_guest_context(ctxt);
         break;
 
-    case VCPUOP_up:
+    case VCPUOP_up: {
+        bool_t wake = 0;
+        domain_lock(d);
         if ( !v->is_initialised )
-            return -EINVAL;
-
-        if ( test_and_clear_bit(_VPF_down, &v->pause_flags) )
+            rc = -EINVAL;
+        else
+            wake = test_and_clear_bit(_VPF_down, &v->pause_flags);
+        domain_unlock(d);
+        if ( wake )
             vcpu_wake(v);
-
         break;
+    }
 
     case VCPUOP_down:
         if ( !test_and_set_bit(_VPF_down, &v->pause_flags) )

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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