diff options
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 25e1f9c97b1a..777fe533cfe7 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -738,10 +738,7 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) | |||
738 | 738 | ||
739 | me = get_cpu(); | 739 | me = get_cpu(); |
740 | spin_lock(&kvm->requests_lock); | 740 | spin_lock(&kvm->requests_lock); |
741 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | 741 | kvm_for_each_vcpu(i, vcpu, kvm) { |
742 | vcpu = kvm->vcpus[i]; | ||
743 | if (!vcpu) | ||
744 | continue; | ||
745 | if (test_and_set_bit(req, &vcpu->requests)) | 742 | if (test_and_set_bit(req, &vcpu->requests)) |
746 | continue; | 743 | continue; |
747 | cpu = vcpu->cpu; | 744 | cpu = vcpu->cpu; |
@@ -1718,7 +1715,7 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu) | |||
1718 | static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) | 1715 | static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) |
1719 | { | 1716 | { |
1720 | int r; | 1717 | int r; |
1721 | struct kvm_vcpu *vcpu; | 1718 | struct kvm_vcpu *vcpu, *v; |
1722 | 1719 | ||
1723 | vcpu = kvm_arch_vcpu_create(kvm, id); | 1720 | vcpu = kvm_arch_vcpu_create(kvm, id); |
1724 | if (IS_ERR(vcpu)) | 1721 | if (IS_ERR(vcpu)) |
@@ -1736,8 +1733,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) | |||
1736 | goto vcpu_destroy; | 1733 | goto vcpu_destroy; |
1737 | } | 1734 | } |
1738 | 1735 | ||
1739 | for (r = 0; r < atomic_read(&kvm->online_vcpus); r++) | 1736 | kvm_for_each_vcpu(r, v, kvm) |
1740 | if (kvm->vcpus[r]->vcpu_id == id) { | 1737 | if (v->vcpu_id == id) { |
1741 | r = -EEXIST; | 1738 | r = -EEXIST; |
1742 | goto vcpu_destroy; | 1739 | goto vcpu_destroy; |
1743 | } | 1740 | } |
@@ -2526,11 +2523,9 @@ static int vcpu_stat_get(void *_offset, u64 *val) | |||
2526 | *val = 0; | 2523 | *val = 0; |
2527 | spin_lock(&kvm_lock); | 2524 | spin_lock(&kvm_lock); |
2528 | list_for_each_entry(kvm, &vm_list, vm_list) | 2525 | list_for_each_entry(kvm, &vm_list, vm_list) |
2529 | for (i = 0; i < KVM_MAX_VCPUS; ++i) { | 2526 | kvm_for_each_vcpu(i, vcpu, kvm) |
2530 | vcpu = kvm->vcpus[i]; | 2527 | *val += *(u32 *)((void *)vcpu + offset); |
2531 | if (vcpu) | 2528 | |
2532 | *val += *(u32 *)((void *)vcpu + offset); | ||
2533 | } | ||
2534 | spin_unlock(&kvm_lock); | 2529 | spin_unlock(&kvm_lock); |
2535 | return 0; | 2530 | return 0; |
2536 | } | 2531 | } |