aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/domain.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2012-01-20 10:13:55 +0000
committerKeir Fraser <keir@xen.org>2012-01-20 10:13:55 +0000
commit2d7d54adfddce658c056a8c87dd74b3766db01a3 (patch)
tree0e79e37e1d532fed7b2bef0cd55cede2fea76c0a /xen/common/domain.c
parent2d94bc491a586d28d00575b52ea60cc08c71f7b6 (diff)
downloadxen-2d7d54adfddce658c056a8c87dd74b3766db01a3.tar.gz
xen-2d7d54adfddce658c056a8c87dd74b3766db01a3.tar.bz2
xen-2d7d54adfddce658c056a8c87dd74b3766db01a3.zip
xen: Simplify callers of boot_vcpu(). In VCPUOP_up, check
is_initialised under the per-domain lock. Signed-off-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/common/domain.c')
-rw-r--r--xen/common/domain.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 52a63efb82..2cc6ab150c 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -781,10 +781,13 @@ void domain_unpause_by_systemcontroller(struct domain *d)
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 @@ long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg)
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) )