From: Jack Lange Date: Wed, 12 Jan 2011 04:23:46 +0000 (-0600) Subject: restructured device manager deinitialization X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=4a13fd6e61111133266b79ec8ff1f84258f953f4;p=palacios.git restructured device manager deinitialization --- diff --git a/palacios/include/palacios/vmm_dev_mgr.h b/palacios/include/palacios/vmm_dev_mgr.h index 3e52d9a..ea45784 100644 --- a/palacios/include/palacios/vmm_dev_mgr.h +++ b/palacios/include/palacios/vmm_dev_mgr.h @@ -88,14 +88,18 @@ struct vm_device * v3_find_dev(struct v3_vm_info * info, const char * dev_name); int v3_init_dev_mgr(struct v3_vm_info * vm); -int v3_dev_mgr_deinit(struct v3_vm_info * vm); +int v3_deinit_dev_mgr(struct v3_vm_info * vm); +int v3_free_vm_devices(struct v3_vm_info * vm); -int v3_init_devices(); + + +int V3_init_devices(); + struct v3_device_ops { diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index aa42528..92d206f 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -542,15 +542,15 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { #ifdef CONFIG_SVM case V3_SVM_CPU: case V3_SVM_REV3_CPU: - v3_init_svm_io_map(vm); - v3_init_svm_msr_map(vm); + v3_deinit_svm_io_map(vm); + v3_deinit_svm_msr_map(vm); break; #endif #ifdef CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: - v3_init_vmx_io_map(vm); - v3_init_vmx_msr_map(vm); + v3_deinit_vmx_io_map(vm); + v3_deinit_vmx_msr_map(vm); break; #endif default: @@ -558,6 +558,8 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { return -1; } + v3_deinit_dev_mgr(vm); + return 0; } diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index d67509c..580a514 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -82,7 +82,7 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { } // Register all the possible device types - v3_init_devices(); + V3_init_devices(); // Register all shadow paging handlers V3_init_shdw_paging(); @@ -300,7 +300,7 @@ int v3_free_vm(struct v3_vm_info * vm) { int i = 0; // deinitialize guest (free memory, etc...) - v3_dev_mgr_deinit(vm); + v3_free_vm_devices(vm); for (i = 0; i < vm->num_cores; i++) { // free cores diff --git a/palacios/src/palacios/vmm_dev_mgr.c b/palacios/src/palacios/vmm_dev_mgr.c index 6f80ba9..d41c331 100644 --- a/palacios/src/palacios/vmm_dev_mgr.c +++ b/palacios/src/palacios/vmm_dev_mgr.c @@ -44,7 +44,7 @@ static int dev_eq_fn(addr_t key1, addr_t key2) { } -int v3_init_devices() { +int V3_init_devices() { extern struct v3_device_info __start__v3_devices[]; extern struct v3_device_info __stop__v3_devices[]; struct v3_device_info * tmp_dev = __start__v3_devices; @@ -108,15 +108,21 @@ int v3_init_dev_mgr(struct v3_vm_info * vm) { } -int v3_dev_mgr_deinit(struct v3_vm_info * vm) { - struct vm_device * dev; +int v3_free_vm_devices(struct v3_vm_info * vm) { struct vmm_dev_mgr * mgr = &(vm->dev_mgr); + struct vm_device * dev; struct vm_device * tmp; list_for_each_entry_safe(dev, tmp, &(mgr->dev_list), dev_link) { v3_remove_device(dev); } + return 0; +} + +int v3_deinit_dev_mgr(struct v3_vm_info * vm) { + struct vmm_dev_mgr * mgr = &(vm->dev_mgr); + v3_free_htable(mgr->blk_table, 0, 0); v3_free_htable(mgr->net_table, 0, 0); v3_free_htable(mgr->char_table, 0, 0);