* [PATCH] Split kvm_create_vm and kvm_destory_vm to support arch
@ 2007-11-15 0:22 Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FC7B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Xiantao @ 2007-11-15 0:22 UTC (permalink / raw)
To: Avi Kivity
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
carsteno-tA70FqPdS9bQT0dZR+AlfA, Hollis Blanchard
[-- Attachment #1: Type: text/plain, Size: 195 bytes --]
KVM Portability: Add two arch hooks to handle kvm_create_vm and
kvm destroy_vm. Now, just put io_bus init and destory in common.
1. kvm_arch_create_vm
2. kvm_arch_destroy_vm
Thanks
Xiantao
[-- Attachment #2: 0001-KVM-Portability-Add-two-arch-hooks-to-handle-kvm_cr.patch --]
[-- Type: application/octet-stream, Size: 4393 bytes --]
From cecd3ec84661feab78b341e227eeb9fb4a55a777 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Thu, 15 Nov 2007 08:17:56 +0800
Subject: [PATCH] Split kvm_create_vm and kvm_destory_vm to support arch
KVM Portability: Add two arch hooks to handle kvm_create_vm and
kvm destroy_vm. Now, just put io_bus init and destory in common.
1. kvm_arch_create_vm
2. kvm_arch_destroy_vm
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
drivers/kvm/kvm.h | 4 ++++
drivers/kvm/kvm_main.c | 42 ++++++------------------------------------
drivers/kvm/x86.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 36 deletions(-)
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 96d9c7d..46c6fb9 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -668,6 +668,10 @@ int kvm_arch_hardware_setup(void);
void kvm_arch_hardware_unsetup(void);
void kvm_arch_check_processor_compat(void *rtn);
+void kvm_free_physmem(struct kvm *kvm);
+
+struct kvm *kvm_arch_create_vm(void);
+void kvm_arch_destroy_vm(struct kvm *kvm);
static inline void kvm_guest_enter(void)
{
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 2cbf662..c890e24 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -156,18 +156,18 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_uninit);
static struct kvm *kvm_create_vm(void)
{
- struct kvm *kvm = kzalloc(sizeof(struct kvm), GFP_KERNEL);
+ struct kvm *kvm = kvm_arch_create_vm();
- if (!kvm)
- return ERR_PTR(-ENOMEM);
+ if (IS_ERR(kvm))
+ goto out;
kvm_io_bus_init(&kvm->pio_bus);
mutex_init(&kvm->lock);
- INIT_LIST_HEAD(&kvm->active_mmu_pages);
kvm_io_bus_init(&kvm->mmio_bus);
spin_lock(&kvm_lock);
list_add(&kvm->vm_list, &vm_list);
spin_unlock(&kvm_lock);
+out:
return kvm;
}
@@ -188,7 +188,7 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,
free->rmap = NULL;
}
-static void kvm_free_physmem(struct kvm *kvm)
+void kvm_free_physmem(struct kvm *kvm)
{
int i;
@@ -196,32 +196,6 @@ static void kvm_free_physmem(struct kvm *kvm)
kvm_free_physmem_slot(&kvm->memslots[i], NULL);
}
-static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
-{
- vcpu_load(vcpu);
- kvm_mmu_unload(vcpu);
- vcpu_put(vcpu);
-}
-
-static void kvm_free_vcpus(struct kvm *kvm)
-{
- unsigned int i;
-
- /*
- * Unpin any mmu pages first.
- */
- for (i = 0; i < KVM_MAX_VCPUS; ++i)
- if (kvm->vcpus[i])
- kvm_unload_vcpu_mmu(kvm->vcpus[i]);
- for (i = 0; i < KVM_MAX_VCPUS; ++i) {
- if (kvm->vcpus[i]) {
- kvm_arch_vcpu_free(kvm->vcpus[i]);
- kvm->vcpus[i] = NULL;
- }
- }
-
-}
-
static void kvm_destroy_vm(struct kvm *kvm)
{
spin_lock(&kvm_lock);
@@ -229,11 +203,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
spin_unlock(&kvm_lock);
kvm_io_bus_destroy(&kvm->pio_bus);
kvm_io_bus_destroy(&kvm->mmio_bus);
- kfree(kvm->vpic);
- kfree(kvm->vioapic);
- kvm_free_vcpus(kvm);
- kvm_free_physmem(kvm);
- kfree(kvm);
+ kvm_arch_destroy_vm(kvm);
}
static int kvm_vm_release(struct inode *inode, struct file *filp)
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 8d45920..b8d6e60 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -2502,3 +2502,50 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
kvm_mmu_destroy(vcpu);
free_page((unsigned long)vcpu->pio_data);
}
+
+struct kvm *kvm_arch_create_vm(void)
+{
+ struct kvm *kvm = kzalloc(sizeof(struct kvm), GFP_KERNEL);
+
+ if (!kvm)
+ return ERR_PTR(-ENOMEM);
+
+ INIT_LIST_HEAD(&kvm->active_mmu_pages);
+
+ return kvm;
+}
+
+static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
+{
+ vcpu_load(vcpu);
+ kvm_mmu_unload(vcpu);
+ vcpu_put(vcpu);
+}
+
+static void kvm_free_vcpus(struct kvm *kvm)
+{
+ unsigned int i;
+
+ /*
+ * Unpin any mmu pages first.
+ */
+ for (i = 0; i < KVM_MAX_VCPUS; ++i)
+ if (kvm->vcpus[i])
+ kvm_unload_vcpu_mmu(kvm->vcpus[i]);
+ for (i = 0; i < KVM_MAX_VCPUS; ++i) {
+ if (kvm->vcpus[i]) {
+ kvm_arch_vcpu_free(kvm->vcpus[i]);
+ kvm->vcpus[i] = NULL;
+ }
+ }
+
+}
+
+void kvm_arch_destroy_vm(struct kvm *kvm)
+{
+ kfree(kvm->vpic);
+ kfree(kvm->vioapic);
+ kvm_free_vcpus(kvm);
+ kvm_free_physmem(kvm);
+ kfree(kvm);
+}
--
1.5.1.2
[-- Attachment #3: Type: text/plain, Size: 314 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Split kvm_create_vm and kvm_destory_vm to support arch
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FC7B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-18 10:22 ` Avi Kivity
[not found] ` <4740125F.50303-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2007-11-18 10:22 UTC (permalink / raw)
To: Zhang, Xiantao
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
carsteno-tA70FqPdS9bQT0dZR+AlfA, Hollis Blanchard
Zhang, Xiantao wrote:
> KVM Portability: Add two arch hooks to handle kvm_create_vm and
> kvm destroy_vm. Now, just put io_bus init and destory in common.
> 1. kvm_arch_create_vm
> 2. kvm_arch_destroy_vm
>
This doesn't apply. Is it against some older codebase?
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Split kvm_create_vm and kvm_destory_vm to support arch
[not found] ` <4740125F.50303-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-18 10:48 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDC9A084B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Xiantao @ 2007-11-18 10:48 UTC (permalink / raw)
To: Avi Kivity
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
carsteno-tA70FqPdS9bQT0dZR+AlfA, Hollis Blanchard
[-- Attachment #1: Type: text/plain, Size: 401 bytes --]
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> KVM Portability: Add two arch hooks to handle kvm_create_vm and
>> kvm destroy_vm. Now, just put io_bus init and destory in common.
>> 1. kvm_arch_create_vm
>> 2. kvm_arch_destroy_vm
>>
>
> This doesn't apply. Is it against some older codebase?
Maybe too old. I made it days ago. Now I rebased it. Please check
attached one.:-)
Xiantao
[-- Attachment #2: 0001-KVM-Portability-move-Add-two-hooks-to-handle-kvm_cr.patch --]
[-- Type: application/octet-stream, Size: 4271 bytes --]
From 820d51fe6af1e1999a3e8bc614d82b7105689d64 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao@vtsmp-build32.los-vmm.org>
Date: Sun, 18 Nov 2007 18:43:45 +0800
Subject: [PATCH] KVM Portability move: Add two hooks to handle kvm_create and desctroy vm
Split kvm_create_vm and kvm_destory_vm to support arch
KVM Portability: Add two arch hooks to handle kvm_create_vm and
kvm destroy_vm. Now, just put io_bus init and destory in common.
Signed-off-by: Zhang Xiantao <xiantao@vtsmp-build32.los-vmm.org>
---
drivers/kvm/kvm.h | 4 ++++
drivers/kvm/kvm_main.c | 42 ++++++------------------------------------
drivers/kvm/x86.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 36 deletions(-)
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index a7be073..e546cae 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -671,6 +671,10 @@ int kvm_arch_hardware_setup(void);
void kvm_arch_hardware_unsetup(void);
void kvm_arch_check_processor_compat(void *rtn);
+void kvm_free_physmem(struct kvm *kvm);
+
+struct kvm *kvm_arch_create_vm(void);
+void kvm_arch_destroy_vm(struct kvm *kvm);
static inline void kvm_guest_enter(void)
{
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 45b18e1..cc955bf 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -156,18 +156,18 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_uninit);
static struct kvm *kvm_create_vm(void)
{
- struct kvm *kvm = kzalloc(sizeof(struct kvm), GFP_KERNEL);
+ struct kvm *kvm = kvm_arch_create_vm();
- if (!kvm)
- return ERR_PTR(-ENOMEM);
+ if (IS_ERR(kvm))
+ goto out;
kvm_io_bus_init(&kvm->pio_bus);
mutex_init(&kvm->lock);
- INIT_LIST_HEAD(&kvm->active_mmu_pages);
kvm_io_bus_init(&kvm->mmio_bus);
spin_lock(&kvm_lock);
list_add(&kvm->vm_list, &vm_list);
spin_unlock(&kvm_lock);
+out:
return kvm;
}
@@ -188,7 +188,7 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,
free->rmap = NULL;
}
-static void kvm_free_physmem(struct kvm *kvm)
+void kvm_free_physmem(struct kvm *kvm)
{
int i;
@@ -196,32 +196,6 @@ static void kvm_free_physmem(struct kvm *kvm)
kvm_free_physmem_slot(&kvm->memslots[i], NULL);
}
-static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
-{
- vcpu_load(vcpu);
- kvm_mmu_unload(vcpu);
- vcpu_put(vcpu);
-}
-
-static void kvm_free_vcpus(struct kvm *kvm)
-{
- unsigned int i;
-
- /*
- * Unpin any mmu pages first.
- */
- for (i = 0; i < KVM_MAX_VCPUS; ++i)
- if (kvm->vcpus[i])
- kvm_unload_vcpu_mmu(kvm->vcpus[i]);
- for (i = 0; i < KVM_MAX_VCPUS; ++i) {
- if (kvm->vcpus[i]) {
- kvm_arch_vcpu_free(kvm->vcpus[i]);
- kvm->vcpus[i] = NULL;
- }
- }
-
-}
-
static void kvm_destroy_vm(struct kvm *kvm)
{
spin_lock(&kvm_lock);
@@ -229,11 +203,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
spin_unlock(&kvm_lock);
kvm_io_bus_destroy(&kvm->pio_bus);
kvm_io_bus_destroy(&kvm->mmio_bus);
- kfree(kvm->vpic);
- kfree(kvm->vioapic);
- kvm_free_vcpus(kvm);
- kvm_free_physmem(kvm);
- kfree(kvm);
+ kvm_arch_destroy_vm(kvm);
}
static int kvm_vm_release(struct inode *inode, struct file *filp)
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 6d7f384..23fa11a 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -2522,3 +2522,50 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
kvm_mmu_destroy(vcpu);
free_page((unsigned long)vcpu->pio_data);
}
+
+struct kvm *kvm_arch_create_vm(void)
+{
+ struct kvm *kvm = kzalloc(sizeof(struct kvm), GFP_KERNEL);
+
+ if (!kvm)
+ return ERR_PTR(-ENOMEM);
+
+ INIT_LIST_HEAD(&kvm->active_mmu_pages);
+
+ return kvm;
+}
+
+static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
+{
+ vcpu_load(vcpu);
+ kvm_mmu_unload(vcpu);
+ vcpu_put(vcpu);
+}
+
+static void kvm_free_vcpus(struct kvm *kvm)
+{
+ unsigned int i;
+
+ /*
+ * Unpin any mmu pages first.
+ */
+ for (i = 0; i < KVM_MAX_VCPUS; ++i)
+ if (kvm->vcpus[i])
+ kvm_unload_vcpu_mmu(kvm->vcpus[i]);
+ for (i = 0; i < KVM_MAX_VCPUS; ++i) {
+ if (kvm->vcpus[i]) {
+ kvm_arch_vcpu_free(kvm->vcpus[i]);
+ kvm->vcpus[i] = NULL;
+ }
+ }
+
+}
+
+void kvm_arch_destroy_vm(struct kvm *kvm)
+{
+ kfree(kvm->vpic);
+ kfree(kvm->vioapic);
+ kvm_free_vcpus(kvm);
+ kvm_free_physmem(kvm);
+ kfree(kvm);
+}
--
1.5.1.2
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Split kvm_create_vm and kvm_destory_vm to support arch
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDC9A084B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-18 11:15 ` Avi Kivity
[not found] ` <47401EC9.2090905-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2007-11-18 11:15 UTC (permalink / raw)
To: Zhang, Xiantao
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
carsteno-tA70FqPdS9bQT0dZR+AlfA, Hollis Blanchard
Zhang, Xiantao wrote:
> Avi Kivity wrote:
>
>> Zhang, Xiantao wrote:
>>
>>> KVM Portability: Add two arch hooks to handle kvm_create_vm and
>>> kvm destroy_vm. Now, just put io_bus init and destory in common.
>>> 1. kvm_arch_create_vm
>>> 2. kvm_arch_destroy_vm
>>>
>>>
>> This doesn't apply. Is it against some older codebase?
>>
>
> Maybe too old. I made it days ago. Now I rebased it. Please check
> attached one.:-)
>
>
Applied, but
> Signed-off-by: Zhang Xiantao <xiantao-Uk7zYEd7jPHh5HgvZiTUayK5HryEFm/a2LY78lusg7I@public.gmane.org>
Is this the right email address?!
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Split kvm_create_vm and kvm_destory_vm to support arch
[not found] ` <47401EC9.2090905-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-18 11:50 ` Zhang, Xiantao
0 siblings, 0 replies; 5+ messages in thread
From: Zhang, Xiantao @ 2007-11-18 11:50 UTC (permalink / raw)
To: Avi Kivity
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
carsteno-tA70FqPdS9bQT0dZR+AlfA, Hollis Blanchard
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> Avi Kivity wrote:
>>
>>> Zhang, Xiantao wrote:
>>>
>>>> KVM Portability: Add two arch hooks to handle kvm_create_vm and
>>>> kvm destroy_vm. Now, just put io_bus init and destory in common.
>>>> 1. kvm_arch_create_vm
>>>> 2. kvm_arch_destroy_vm
>>>>
>>>>
>>> This doesn't apply. Is it against some older codebase?
>>>
>>
>> Maybe too old. I made it days ago. Now I rebased it. Please check
>> attached one.:-)
>>
>>
> Applied, but
>
>> Signed-off-by: Zhang Xiantao <xiantao-Uk7zYEd7jPHh5HgvZiTUayK5HryEFm/a2LY78lusg7I@public.gmane.org>
>
> Is this the right email address?!
Oh, Sorry. Seems I wrongly used a internal machine mail address. I will
check it carefully next time.
Signed-off-by: Zhang Xiantao<xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-11-18 11:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-15 0:22 [PATCH] Split kvm_create_vm and kvm_destory_vm to support arch Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDC94FC7B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-18 10:22 ` Avi Kivity
[not found] ` <4740125F.50303-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-18 10:48 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDC9A084B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-18 11:15 ` Avi Kivity
[not found] ` <47401EC9.2090905-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-18 11:50 ` Zhang, Xiantao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox