public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH]4/5 Combine kvm_init and kvm_init_x86
@ 2007-11-14  5:44 Zhang, Xiantao
       [not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FACB-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Xiantao @ 2007-11-14  5:44 UTC (permalink / raw)
  To: Avi Kivity
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA

From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Combine kvm_init and kvm_init_x86 into one function, and will be called
when arch register.
Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/kvm/kvm.h      |    4 +-
 drivers/kvm/kvm_main.c |   61
+++++++++++++++++------------------------------
 drivers/kvm/svm.c      |    4 +-
 drivers/kvm/vmx.c      |    4 +-
 4 files changed, 28 insertions(+), 45 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 6c797ea..6e1bf8c 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -493,9 +493,9 @@ void vcpu_load(struct kvm_vcpu *vcpu);
 void vcpu_put(struct kvm_vcpu *vcpu);
 
 
-int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
+int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
 		  struct module *module);
-void kvm_exit_x86(void);
+void kvm_exit(void);
 
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 6a109e8..ae7ee77 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1470,11 +1470,26 @@ static void kvm_sched_out(struct
preempt_notifier *pn,
 	kvm_arch_vcpu_put(vcpu);
 }
 
-int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
+int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
 		  struct module *module)
 {
 	int r;
 	int cpu;
+
+	r = kvm_mmu_module_init();
+	if (r)
+		goto out4;
+
+	kvm_init_debug();
+
+	kvm_arch_init();
+
+	bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+
+	if (bad_page == NULL) {
+		r = -ENOMEM;
+		goto out;
+	}
 
 	if (kvm_x86_ops) {
 		printk(KERN_ERR "kvm: already loaded the other
module\n");
@@ -1556,11 +1571,14 @@ out_free_0:
 	kvm_arch_hardware_unsetup();
 out:
 	kvm_x86_ops = NULL;
+	kvm_exit_debug();
+	kvm_mmu_module_exit();
+out4:
 	return r;
 }
-EXPORT_SYMBOL_GPL(kvm_init_x86);
+EXPORT_SYMBOL_GPL(kvm_init);
 
-void kvm_exit_x86(void)
+void kvm_exit(void)
 {
 	misc_deregister(&kvm_dev);
 	kmem_cache_destroy(kvm_vcpu_cache);
@@ -1571,43 +1589,8 @@ void kvm_exit_x86(void)
 	on_each_cpu(hardware_disable, NULL, 0, 1);
 	kvm_arch_hardware_unsetup();
 	kvm_x86_ops = NULL;
-}
-EXPORT_SYMBOL_GPL(kvm_exit_x86);
-
-static __init int kvm_init(void)
-{
-	int r;
-
-	r = kvm_mmu_module_init();
-	if (r)
-		goto out4;
-
-	kvm_init_debug();
-
-	kvm_arch_init();
-
-	bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
-
-	if (bad_page == NULL) {
-		r = -ENOMEM;
-		goto out;
-	}
-
-	return 0;
-
-out:
-	kvm_exit_debug();
-	kvm_mmu_module_exit();
-out4:
-	return r;
-}
-
-static __exit void kvm_exit(void)
-{
 	kvm_exit_debug();
 	__free_page(bad_page);
 	kvm_mmu_module_exit();
 }
-
-module_init(kvm_init)
-module_exit(kvm_exit)
+EXPORT_SYMBOL_GPL(kvm_exit);
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index f54b2ea..11a0010 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1722,13 +1722,13 @@ static struct kvm_x86_ops svm_x86_ops = {
 
 static int __init svm_init(void)
 {
-	return kvm_init_x86(&svm_x86_ops, sizeof(struct vcpu_svm),
+	return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm),
 			      THIS_MODULE);
 }
 
 static void __exit svm_exit(void)
 {
-	kvm_exit_x86();
+	kvm_exit();
 }
 
 module_init(svm_init)
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 0f48d23..ecb98c1 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -2623,7 +2623,7 @@ static int __init vmx_init(void)
 	memset(iova, 0xff, PAGE_SIZE);
 	kunmap(vmx_io_bitmap_b);
 
-	r = kvm_init_x86(&vmx_x86_ops, sizeof(struct vcpu_vmx),
THIS_MODULE);
+	r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx),
THIS_MODULE);
 	if (r)
 		goto out1;
 
@@ -2644,7 +2644,7 @@ static void __exit vmx_exit(void)
 	__free_page(vmx_io_bitmap_b);
 	__free_page(vmx_io_bitmap_a);
 
-	kvm_exit_x86();
+	kvm_exit();
 }
 
 module_init(vmx_init)
-- 
1.5.1.2

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH]4/5 Combine kvm_init and kvm_init_x86
       [not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FACB-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-14 11:59   ` Carsten Otte
  0 siblings, 0 replies; 2+ messages in thread
From: Carsten Otte @ 2007-11-14 11:59 UTC (permalink / raw)
  To: Zhang, Xiantao
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	carsteno-tA70FqPdS9bQT0dZR+AlfA, Avi Kivity

Acked-by: Carsten Otte <cotte-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Zhang, Xiantao wrote:
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Combine kvm_init and kvm_init_x86 into one function, and will be called
> when arch register.
> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/kvm/kvm.h      |    4 +-
>  drivers/kvm/kvm_main.c |   61
> +++++++++++++++++------------------------------
>  drivers/kvm/svm.c      |    4 +-
>  drivers/kvm/vmx.c      |    4 +-
>  4 files changed, 28 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
> index 6c797ea..6e1bf8c 100644
> --- a/drivers/kvm/kvm.h
> +++ b/drivers/kvm/kvm.h
> @@ -493,9 +493,9 @@ void vcpu_load(struct kvm_vcpu *vcpu);
>  void vcpu_put(struct kvm_vcpu *vcpu);
>  
>  
> -int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
> +int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
>  		  struct module *module);
> -void kvm_exit_x86(void);
> +void kvm_exit(void);
>  
>  int kvm_mmu_module_init(void);
>  void kvm_mmu_module_exit(void);
> diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
> index 6a109e8..ae7ee77 100644
> --- a/drivers/kvm/kvm_main.c
> +++ b/drivers/kvm/kvm_main.c
> @@ -1470,11 +1470,26 @@ static void kvm_sched_out(struct
> preempt_notifier *pn,
>  	kvm_arch_vcpu_put(vcpu);
>  }
>  
> -int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
> +int kvm_init(struct kvm_x86_ops *ops, unsigned int vcpu_size,
>  		  struct module *module)
>  {
>  	int r;
>  	int cpu;
> +
> +	r = kvm_mmu_module_init();
> +	if (r)
> +		goto out4;
> +
> +	kvm_init_debug();
> +
> +	kvm_arch_init();
> +
> +	bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
> +
> +	if (bad_page == NULL) {
> +		r = -ENOMEM;
> +		goto out;
> +	}
>  
>  	if (kvm_x86_ops) {
>  		printk(KERN_ERR "kvm: already loaded the other
> module\n");
> @@ -1556,11 +1571,14 @@ out_free_0:
>  	kvm_arch_hardware_unsetup();
>  out:
>  	kvm_x86_ops = NULL;
> +	kvm_exit_debug();
> +	kvm_mmu_module_exit();
> +out4:
>  	return r;
>  }
> -EXPORT_SYMBOL_GPL(kvm_init_x86);
> +EXPORT_SYMBOL_GPL(kvm_init);
>  
> -void kvm_exit_x86(void)
> +void kvm_exit(void)
>  {
>  	misc_deregister(&kvm_dev);
>  	kmem_cache_destroy(kvm_vcpu_cache);
> @@ -1571,43 +1589,8 @@ void kvm_exit_x86(void)
>  	on_each_cpu(hardware_disable, NULL, 0, 1);
>  	kvm_arch_hardware_unsetup();
>  	kvm_x86_ops = NULL;
> -}
> -EXPORT_SYMBOL_GPL(kvm_exit_x86);
> -
> -static __init int kvm_init(void)
> -{
> -	int r;
> -
> -	r = kvm_mmu_module_init();
> -	if (r)
> -		goto out4;
> -
> -	kvm_init_debug();
> -
> -	kvm_arch_init();
> -
> -	bad_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
> -
> -	if (bad_page == NULL) {
> -		r = -ENOMEM;
> -		goto out;
> -	}
> -
> -	return 0;
> -
> -out:
> -	kvm_exit_debug();
> -	kvm_mmu_module_exit();
> -out4:
> -	return r;
> -}
> -
> -static __exit void kvm_exit(void)
> -{
>  	kvm_exit_debug();
>  	__free_page(bad_page);
>  	kvm_mmu_module_exit();
>  }
> -
> -module_init(kvm_init)
> -module_exit(kvm_exit)
> +EXPORT_SYMBOL_GPL(kvm_exit);
> diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
> index f54b2ea..11a0010 100644
> --- a/drivers/kvm/svm.c
> +++ b/drivers/kvm/svm.c
> @@ -1722,13 +1722,13 @@ static struct kvm_x86_ops svm_x86_ops = {
>  
>  static int __init svm_init(void)
>  {
> -	return kvm_init_x86(&svm_x86_ops, sizeof(struct vcpu_svm),
> +	return kvm_init(&svm_x86_ops, sizeof(struct vcpu_svm),
>  			      THIS_MODULE);
>  }
>  
>  static void __exit svm_exit(void)
>  {
> -	kvm_exit_x86();
> +	kvm_exit();
>  }
>  
>  module_init(svm_init)
> diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
> index 0f48d23..ecb98c1 100644
> --- a/drivers/kvm/vmx.c
> +++ b/drivers/kvm/vmx.c
> @@ -2623,7 +2623,7 @@ static int __init vmx_init(void)
>  	memset(iova, 0xff, PAGE_SIZE);
>  	kunmap(vmx_io_bitmap_b);
>  
> -	r = kvm_init_x86(&vmx_x86_ops, sizeof(struct vcpu_vmx),
> THIS_MODULE);
> +	r = kvm_init(&vmx_x86_ops, sizeof(struct vcpu_vmx),
> THIS_MODULE);
>  	if (r)
>  		goto out1;
>  
> @@ -2644,7 +2644,7 @@ static void __exit vmx_exit(void)
>  	__free_page(vmx_io_bitmap_b);
>  	__free_page(vmx_io_bitmap_a);
>  
> -	kvm_exit_x86();
> +	kvm_exit();
>  }
>  
>  module_init(vmx_init)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-11-14 11:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-14  5:44 [PATCH]4/5 Combine kvm_init and kvm_init_x86 Zhang, Xiantao
     [not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FACB-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-14 11:59   ` Carsten Otte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox