diff options
author | Gleb Natapov <gleb@redhat.com> | 2009-06-09 08:56:29 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-09-10 01:32:52 -0400 |
commit | 988a2cae6a3c0dea6df59808a935a9a697bfc28c (patch) | |
tree | c1118d86c5d6f24fe738c608917b0affb311f26d /arch/s390 | |
parent | 73880c80aa9c8dc353cd0ad26579023213cd5314 (diff) |
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/s390')
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 098bfa6fbdf6..07ced89740d7 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -211,13 +211,17 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) | |||
211 | static void kvm_free_vcpus(struct kvm *kvm) | 211 | static void kvm_free_vcpus(struct kvm *kvm) |
212 | { | 212 | { |
213 | unsigned int i; | 213 | unsigned int i; |
214 | struct kvm_vcpu *vcpu; | ||
214 | 215 | ||
215 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | 216 | kvm_for_each_vcpu(i, vcpu, kvm) |
216 | if (kvm->vcpus[i]) { | 217 | kvm_arch_vcpu_destroy(vcpu); |
217 | kvm_arch_vcpu_destroy(kvm->vcpus[i]); | 218 | |
218 | kvm->vcpus[i] = NULL; | 219 | mutex_lock(&kvm->lock); |
219 | } | 220 | for (i = 0; i < atomic_read(&kvm->online_vcpus); i++) |
220 | } | 221 | kvm->vcpus[i] = NULL; |
222 | |||
223 | atomic_set(&kvm->online_vcpus, 0); | ||
224 | mutex_unlock(&kvm->lock); | ||
221 | } | 225 | } |
222 | 226 | ||
223 | void kvm_arch_sync_events(struct kvm *kvm) | 227 | void kvm_arch_sync_events(struct kvm *kvm) |
@@ -314,8 +318,6 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, | |||
314 | BUG_ON(!kvm->arch.sca); | 318 | BUG_ON(!kvm->arch.sca); |
315 | if (!kvm->arch.sca->cpu[id].sda) | 319 | if (!kvm->arch.sca->cpu[id].sda) |
316 | kvm->arch.sca->cpu[id].sda = (__u64) vcpu->arch.sie_block; | 320 | kvm->arch.sca->cpu[id].sda = (__u64) vcpu->arch.sie_block; |
317 | else | ||
318 | BUG_ON(!kvm->vcpus[id]); /* vcpu does already exist */ | ||
319 | vcpu->arch.sie_block->scaoh = (__u32)(((__u64)kvm->arch.sca) >> 32); | 321 | vcpu->arch.sie_block->scaoh = (__u32)(((__u64)kvm->arch.sca) >> 32); |
320 | vcpu->arch.sie_block->scaol = (__u32)(__u64)kvm->arch.sca; | 322 | vcpu->arch.sie_block->scaol = (__u32)(__u64)kvm->arch.sca; |
321 | 323 | ||
@@ -683,6 +685,7 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
683 | int user_alloc) | 685 | int user_alloc) |
684 | { | 686 | { |
685 | int i; | 687 | int i; |
688 | struct kvm_vcpu *vcpu; | ||
686 | 689 | ||
687 | /* A few sanity checks. We can have exactly one memory slot which has | 690 | /* A few sanity checks. We can have exactly one memory slot which has |
688 | to start at guest virtual zero and which has to be located at a | 691 | to start at guest virtual zero and which has to be located at a |
@@ -707,14 +710,10 @@ int kvm_arch_set_memory_region(struct kvm *kvm, | |||
707 | return -EINVAL; | 710 | return -EINVAL; |
708 | 711 | ||
709 | /* request update of sie control block for all available vcpus */ | 712 | /* request update of sie control block for all available vcpus */ |
710 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | 713 | kvm_for_each_vcpu(i, vcpu, kvm) { |
711 | if (kvm->vcpus[i]) { | 714 | if (test_and_set_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests)) |
712 | if (test_and_set_bit(KVM_REQ_MMU_RELOAD, | 715 | continue; |
713 | &kvm->vcpus[i]->requests)) | 716 | kvm_s390_inject_sigp_stop(vcpu, ACTION_RELOADVCPU_ON_STOP); |
714 | continue; | ||
715 | kvm_s390_inject_sigp_stop(kvm->vcpus[i], | ||
716 | ACTION_RELOADVCPU_ON_STOP); | ||
717 | } | ||
718 | } | 717 | } |
719 | 718 | ||
720 | return 0; | 719 | return 0; |