aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm.h
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-07-27 03:16:56 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:20 -0400
commitfb3f0f51d92d1496f9628ca6f0fb06a48dc9ed2a (patch)
tree38da1073dae5f30fd8f162669bb5a86959f8ace5 /drivers/kvm/kvm.h
parenta2fa3e9f52d875f7d4ca98434603b8756be71ba8 (diff)
KVM: Dynamically allocate vcpus
This patch converts the vcpus array in "struct kvm" to a pointer array, and changes the "vcpu_create" and "vcpu_setup" hooks into one "vcpu_create" call which does the allocation and initialization of the vcpu (calling back into the kvm_vcpu_init core helper). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm.h')
-rw-r--r--drivers/kvm/kvm.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 954a14089605..e92c84b04c1f 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -300,10 +300,8 @@ void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
300 struct kvm_io_device *dev); 300 struct kvm_io_device *dev);
301 301
302struct kvm_vcpu { 302struct kvm_vcpu {
303 int valid;
304 struct kvm *kvm; 303 struct kvm *kvm;
305 int vcpu_id; 304 int vcpu_id;
306 void *_priv;
307 struct mutex mutex; 305 struct mutex mutex;
308 int cpu; 306 int cpu;
309 u64 host_tsc; 307 u64 host_tsc;
@@ -404,8 +402,7 @@ struct kvm {
404 struct list_head active_mmu_pages; 402 struct list_head active_mmu_pages;
405 int n_free_mmu_pages; 403 int n_free_mmu_pages;
406 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES]; 404 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
407 int nvcpus; 405 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
408 struct kvm_vcpu vcpus[KVM_MAX_VCPUS];
409 int memory_config_version; 406 int memory_config_version;
410 int busy; 407 int busy;
411 unsigned long rmap_overflow; 408 unsigned long rmap_overflow;
@@ -428,7 +425,8 @@ struct kvm_arch_ops {
428 int (*hardware_setup)(void); /* __init */ 425 int (*hardware_setup)(void); /* __init */
429 void (*hardware_unsetup)(void); /* __exit */ 426 void (*hardware_unsetup)(void); /* __exit */
430 427
431 int (*vcpu_create)(struct kvm_vcpu *vcpu); 428 /* Create, but do not attach this VCPU */
429 struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
432 void (*vcpu_free)(struct kvm_vcpu *vcpu); 430 void (*vcpu_free)(struct kvm_vcpu *vcpu);
433 431
434 void (*vcpu_load)(struct kvm_vcpu *vcpu); 432 void (*vcpu_load)(struct kvm_vcpu *vcpu);
@@ -470,7 +468,6 @@ struct kvm_arch_ops {
470 void (*inject_gp)(struct kvm_vcpu *vcpu, unsigned err_code); 468 void (*inject_gp)(struct kvm_vcpu *vcpu, unsigned err_code);
471 469
472 int (*run)(struct kvm_vcpu *vcpu, struct kvm_run *run); 470 int (*run)(struct kvm_vcpu *vcpu, struct kvm_run *run);
473 int (*vcpu_setup)(struct kvm_vcpu *vcpu);
474 void (*skip_emulated_instruction)(struct kvm_vcpu *vcpu); 471 void (*skip_emulated_instruction)(struct kvm_vcpu *vcpu);
475 void (*patch_hypercall)(struct kvm_vcpu *vcpu, 472 void (*patch_hypercall)(struct kvm_vcpu *vcpu,
476 unsigned char *hypercall_addr); 473 unsigned char *hypercall_addr);
@@ -481,6 +478,9 @@ extern struct kvm_arch_ops *kvm_arch_ops;
481#define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt) 478#define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt)
482#define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt) 479#define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt)
483 480
481int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
482void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
483
484int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module); 484int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module);
485void kvm_exit_arch(void); 485void kvm_exit_arch(void);
486 486