summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm
diff options
context:
space:
mode:
authorGleb Natapov <gleb@redhat.com>2009-06-09 15:56:29 +0300
committerAvi Kivity <avi@redhat.com>2009-09-10 08:32:52 +0300
commit988a2cae6a3c0dea6df59808a935a9a697bfc28c (patch)
treec1118d86c5d6f24fe738c608917b0affb311f26d /arch/powerpc/kvm
parent73880c80aa9c8dc353cd0ad26579023213cd5314 (diff)
downloadop-kernel-dev-988a2cae6a3c0dea6df59808a935a9a697bfc28c.zip
op-kernel-dev-988a2cae6a3c0dea6df59808a935a9a697bfc28c.tar.gz
KVM: Use macro to iterate over vcpus.
[christian: remove unused variables on s390] Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm')
-rw-r--r--arch/powerpc/kvm/powerpc.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 2cf915e..7ad30e0 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -122,13 +122,17 @@ struct kvm *kvm_arch_create_vm(void)
static void kvmppc_free_vcpus(struct kvm *kvm)
{
unsigned int i;
+ struct kvm_vcpu *vcpu;
- for (i = 0; i < KVM_MAX_VCPUS; ++i) {
- if (kvm->vcpus[i]) {
- kvm_arch_vcpu_free(kvm->vcpus[i]);
- kvm->vcpus[i] = NULL;
- }
- }
+ kvm_for_each_vcpu(i, vcpu, kvm)
+ kvm_arch_vcpu_free(vcpu);
+
+ mutex_lock(&kvm->lock);
+ for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
+ kvm->vcpus[i] = NULL;
+
+ atomic_set(&kvm->online_vcpus, 0);
+ mutex_unlock(&kvm->lock);
}
void kvm_arch_sync_events(struct kvm *kvm)
OpenPOWER on IntegriCloud