diff options
author | Avi Kivity <avi@qumranet.com> | 2007-02-12 03:54:44 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-12 12:48:40 -0500 |
commit | 133de9021d2988f3fbdad84c2d26484c7a757526 (patch) | |
tree | dc56020026f28b91d2304aa355c8b6cf859a7223 /drivers/kvm/kvm_main.c | |
parent | 47e627bc8c9a70392d2049e6af5bd55fae61fe53 (diff) |
[PATCH] KVM: Add a global list of all virtual machines
This will allow us to iterate over all vcpus and see which cpus they are
running on.
[akpm@osdl.org: use standard (ugly) initialisers]
Signed-off-by: Avi Kivity <avi@qumranet.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r-- | drivers/kvm/kvm_main.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 9b79d3451f6f..a6cd1c1fe29a 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -41,6 +41,9 @@ | |||
41 | MODULE_AUTHOR("Qumranet"); | 41 | MODULE_AUTHOR("Qumranet"); |
42 | MODULE_LICENSE("GPL"); | 42 | MODULE_LICENSE("GPL"); |
43 | 43 | ||
44 | static DEFINE_SPINLOCK(kvm_lock); | ||
45 | static LIST_HEAD(vm_list); | ||
46 | |||
44 | struct kvm_arch_ops *kvm_arch_ops; | 47 | struct kvm_arch_ops *kvm_arch_ops; |
45 | struct kvm_stat kvm_stat; | 48 | struct kvm_stat kvm_stat; |
46 | EXPORT_SYMBOL_GPL(kvm_stat); | 49 | EXPORT_SYMBOL_GPL(kvm_stat); |
@@ -230,9 +233,13 @@ static int kvm_dev_open(struct inode *inode, struct file *filp) | |||
230 | struct kvm_vcpu *vcpu = &kvm->vcpus[i]; | 233 | struct kvm_vcpu *vcpu = &kvm->vcpus[i]; |
231 | 234 | ||
232 | mutex_init(&vcpu->mutex); | 235 | mutex_init(&vcpu->mutex); |
236 | vcpu->cpu = -1; | ||
233 | vcpu->kvm = kvm; | 237 | vcpu->kvm = kvm; |
234 | vcpu->mmu.root_hpa = INVALID_PAGE; | 238 | vcpu->mmu.root_hpa = INVALID_PAGE; |
235 | INIT_LIST_HEAD(&vcpu->free_pages); | 239 | INIT_LIST_HEAD(&vcpu->free_pages); |
240 | spin_lock(&kvm_lock); | ||
241 | list_add(&kvm->vm_list, &vm_list); | ||
242 | spin_unlock(&kvm_lock); | ||
236 | } | 243 | } |
237 | filp->private_data = kvm; | 244 | filp->private_data = kvm; |
238 | return 0; | 245 | return 0; |
@@ -292,6 +299,9 @@ static int kvm_dev_release(struct inode *inode, struct file *filp) | |||
292 | { | 299 | { |
293 | struct kvm *kvm = filp->private_data; | 300 | struct kvm *kvm = filp->private_data; |
294 | 301 | ||
302 | spin_lock(&kvm_lock); | ||
303 | list_del(&kvm->vm_list); | ||
304 | spin_unlock(&kvm_lock); | ||
295 | kvm_free_vcpus(kvm); | 305 | kvm_free_vcpus(kvm); |
296 | kvm_free_physmem(kvm); | 306 | kvm_free_physmem(kvm); |
297 | kfree(kvm); | 307 | kfree(kvm); |
@@ -546,7 +556,6 @@ static int kvm_dev_ioctl_create_vcpu(struct kvm *kvm, int n) | |||
546 | FX_IMAGE_ALIGN); | 556 | FX_IMAGE_ALIGN); |
547 | vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE; | 557 | vcpu->guest_fx_image = vcpu->host_fx_image + FX_IMAGE_SIZE; |
548 | 558 | ||
549 | vcpu->cpu = -1; /* First load will set up TR */ | ||
550 | r = kvm_arch_ops->vcpu_create(vcpu); | 559 | r = kvm_arch_ops->vcpu_create(vcpu); |
551 | if (r < 0) | 560 | if (r < 0) |
552 | goto out_free_vcpus; | 561 | goto out_free_vcpus; |