aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/irq_comm.c6
-rw-r--r--virt/kvm/kvm_main.c19
2 files changed, 9 insertions, 16 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index 08a9a49481b2..bb8a1b5e41c1 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -68,10 +68,8 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
68 kvm_is_dm_lowest_prio(irq)) 68 kvm_is_dm_lowest_prio(irq))
69 printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n"); 69 printk(KERN_INFO "kvm: apic: phys broadcast and lowest prio\n");
70 70
71 for (i = 0; i < KVM_MAX_VCPUS; i++) { 71 kvm_for_each_vcpu(i, vcpu, kvm) {
72 vcpu = kvm->vcpus[i]; 72 if (!kvm_apic_present(vcpu))
73
74 if (!vcpu || !kvm_apic_present(vcpu))
75 continue; 73 continue;
76 74
77 if (!kvm_apic_match_dest(vcpu, src, irq->shorthand, 75 if (!kvm_apic_match_dest(vcpu, src, irq->shorthand,
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)
1718static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id) 1715static 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}