aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorZhang Xiantao <xiantao.zhang@intel.com>2007-11-14 07:39:31 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:53:02 -0500
commitcb498ea2ce1d3f3c0bc0a2522241dca10263e437 (patch)
tree255eeaa3581a79ceb77772c1350faa95ce4706a6 /drivers/kvm/kvm_main.c
parente9b11c17552afe684e9e5d0444309a3ddf410116 (diff)
KVM: Portability: Combine kvm_init and kvm_init_x86
Will be called once arch module registers itself. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Acked-by: Carsten Otte <cotte@de.ibm.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c61
1 files changed, 22 insertions, 39 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 7fdfed52dbe..2b3736e7483 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1434,12 +1434,27 @@ static void kvm_sched_out(struct preempt_notifier *pn,
1434 kvm_arch_vcpu_put(vcpu); 1434 kvm_arch_vcpu_put(vcpu);
1435} 1435}
1436 1436
1437int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size, 1437int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
1438 struct module *module) 1438 struct module *module)
1439{ 1439{
1440 int r; 1440 int r;
1441 int cpu; 1441 int cpu;
1442 1442
1443 r = kvm_mmu_module_init();
1444 if (r)
1445 goto out4;
1446
1447 kvm_init_debug();
1448
1449 kvm_arch_init();
1450
1451 bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
1452
1453 if (bad_page == NULL) {
1454 r = -ENOMEM;
1455 goto out;
1456 }
1457
1443 if (kvm_x86_ops) { 1458 if (kvm_x86_ops) {
1444 printk(KERN_ERR "kvm: already loaded the other module\n"); 1459 printk(KERN_ERR "kvm: already loaded the other module\n");
1445 return -EEXIST; 1460 return -EEXIST;
@@ -1520,11 +1535,14 @@ out_free_0:
1520 kvm_arch_hardware_unsetup(); 1535 kvm_arch_hardware_unsetup();
1521out: 1536out:
1522 kvm_x86_ops = NULL; 1537 kvm_x86_ops = NULL;
1538 kvm_exit_debug();
1539 kvm_mmu_module_exit();
1540out4:
1523 return r; 1541 return r;
1524} 1542}
1525EXPORT_SYMBOL_GPL(kvm_init_x86); 1543EXPORT_SYMBOL_GPL(kvm_init);
1526 1544
1527void kvm_exit_x86(void) 1545void kvm_exit(void)
1528{ 1546{
1529 misc_deregister(&kvm_dev); 1547 misc_deregister(&kvm_dev);
1530 kmem_cache_destroy(kvm_vcpu_cache); 1548 kmem_cache_destroy(kvm_vcpu_cache);
@@ -1535,43 +1553,8 @@ void kvm_exit_x86(void)
1535 on_each_cpu(hardware_disable, NULL, 0, 1); 1553 on_each_cpu(hardware_disable, NULL, 0, 1);
1536 kvm_arch_hardware_unsetup(); 1554 kvm_arch_hardware_unsetup();
1537 kvm_x86_ops = NULL; 1555 kvm_x86_ops = NULL;
1538}
1539EXPORT_SYMBOL_GPL(kvm_exit_x86);
1540
1541static __init int kvm_init(void)
1542{
1543 int r;
1544
1545 r = kvm_mmu_module_init();
1546 if (r)
1547 goto out4;
1548
1549 kvm_init_debug();
1550
1551 kvm_arch_init();
1552
1553 bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
1554
1555 if (bad_page == NULL) {
1556 r = -ENOMEM;
1557 goto out;
1558 }
1559
1560 return 0;
1561
1562out:
1563 kvm_exit_debug();
1564 kvm_mmu_module_exit();
1565out4:
1566 return r;
1567}
1568
1569static __exit void kvm_exit(void)
1570{
1571 kvm_exit_debug(); 1556 kvm_exit_debug();
1572 __free_page(bad_page); 1557 __free_page(bad_page);
1573 kvm_mmu_module_exit(); 1558 kvm_mmu_module_exit();
1574} 1559}
1575 1560EXPORT_SYMBOL_GPL(kvm_exit);
1576module_init(kvm_init)
1577module_exit(kvm_exit)