From: Jack Lange Date: Thu, 13 Jan 2011 18:23:57 +0000 (-0600) Subject: almost all deinitialization has been added X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3cd4f1c180c7a59177c7108c495a2e27af9db10;hp=aac189310cca0f5f14543d91413d3b5b58250a3e;p=palacios.git almost all deinitialization has been added --- diff --git a/palacios/include/palacios/vmm_symbiotic.h b/palacios/include/palacios/vmm_symbiotic.h index 530a5fc..0c581fd 100644 --- a/palacios/include/palacios/vmm_symbiotic.h +++ b/palacios/include/palacios/vmm_symbiotic.h @@ -57,7 +57,10 @@ struct v3_sym_core_state { int v3_init_symbiotic_vm(struct v3_vm_info * vm); +int v3_deinit_symbiotic_vm(struct v3_vm_info * vm); + int v3_init_symbiotic_core(struct guest_info * core); +int v3_deinit_symbiotic_core(struct guest_info * core); #endif diff --git a/palacios/include/palacios/vmm_symmod.h b/palacios/include/palacios/vmm_symmod.h index 526a0c5..4d28fff 100644 --- a/palacios/include/palacios/vmm_symmod.h +++ b/palacios/include/palacios/vmm_symmod.h @@ -88,6 +88,7 @@ int v3_set_symmod_loader(struct v3_vm_info * vm, struct v3_symmod_loader_ops * o int v3_load_sym_capsule(struct v3_vm_info * vm, char * mod_name); int v3_init_symmod_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg); +int v3_deinit_symmod_vm(struct v3_vm_info * vm); struct v3_sym_capsule * v3_get_sym_capsule(struct v3_vm_info * vm, char * name); diff --git a/palacios/src/devices/pci.c b/palacios/src/devices/pci.c index 04d56f3..1f4976b 100644 --- a/palacios/src/devices/pci.c +++ b/palacios/src/devices/pci.c @@ -611,8 +611,24 @@ static void init_pci_busses(struct pci_internal * pci_state) { static int pci_free(struct pci_internal * pci_state) { + int i; + + + // cleanup devices + for (i = 0; i < PCI_BUS_COUNT; i++) { + struct pci_bus * bus = &(pci_state->bus_list[i]); + struct rb_node * node = v3_rb_first(&(bus->devices)); + struct pci_device * dev = NULL; - // cleanup devices (?) + while (node) { + dev = rb_entry(node, struct pci_device, dev_tree_node); + node = v3_rb_next(node); + + v3_rb_erase(&(dev->dev_tree_node), &(bus->devices)); + V3_Free(dev); + } + + } V3_Free(pci_state); return 0; diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index 072ffac..b544074 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -537,6 +537,11 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { v3_remove_hypercall(vm, GUEST_INFO_HCALL); + +#ifdef CONFIG_SYMBIOTIC + v3_deinit_symbiotic_vm(vm); +#endif + // init SVM/VMX switch (cpu_type) { #ifdef CONFIG_SVM @@ -578,6 +583,8 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { v3_deinit_telemetry(vm); #endif + + return 0; } @@ -645,7 +652,7 @@ int v3_free_core(struct guest_info * core) { #ifdef CONFIG_SYMBIOTIC - //v3_deinit_symbiotic_core(core); + v3_deinit_symbiotic_core(core); #endif v3_deinit_decoder(core); diff --git a/palacios/src/palacios/vmm_dev_mgr.c b/palacios/src/palacios/vmm_dev_mgr.c index d41c331..f578f02 100644 --- a/palacios/src/palacios/vmm_dev_mgr.c +++ b/palacios/src/palacios/vmm_dev_mgr.c @@ -120,13 +120,16 @@ int v3_free_vm_devices(struct v3_vm_info * vm) { return 0; } +static int free_frontends(struct v3_vm_info * vm, struct vmm_dev_mgr * mgr); + int v3_deinit_dev_mgr(struct v3_vm_info * vm) { struct vmm_dev_mgr * mgr = &(vm->dev_mgr); + + // clear frontend lists + + free_frontends(vm, 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); - v3_free_htable(mgr->cons_table, 0, 0); v3_free_htable(mgr->dev_table, 0, 0); @@ -553,3 +556,45 @@ int v3_dev_connect_char(struct v3_vm_info * vm, return 0; } + + +static int free_frontends(struct v3_vm_info * vm, struct vmm_dev_mgr * mgr) { + struct char_frontend * chr = NULL; + struct char_frontend * tmp_chr = NULL; + struct cons_frontend * cons = NULL; + struct cons_frontend * tmp_cons = NULL; + struct net_frontend * net = NULL; + struct net_frontend * tmp_net = NULL; + struct blk_frontend * blk = NULL; + struct blk_frontend * tmp_blk = NULL; + + + + list_for_each_entry_safe(chr, tmp_chr, &(mgr->char_list), char_node) { + list_del(&(chr->char_node)); + V3_Free(chr); + } + + list_for_each_entry_safe(cons, tmp_cons, &(mgr->cons_list), cons_node) { + list_del(&(cons->cons_node)); + V3_Free(cons); + } + + list_for_each_entry_safe(net, tmp_net, &(mgr->net_list), net_node) { + list_del(&(net->net_node)); + V3_Free(net); + } + + list_for_each_entry_safe(blk, tmp_blk, &(mgr->blk_list), blk_node) { + list_del(&(blk->blk_node)); + V3_Free(blk); + } + + v3_free_htable(mgr->blk_table, 0, 0); + v3_free_htable(mgr->net_table, 0, 0); + v3_free_htable(mgr->char_table, 0, 0); + v3_free_htable(mgr->cons_table, 0, 0); + + + return 0; +} diff --git a/palacios/src/palacios/vmm_symbiotic.c b/palacios/src/palacios/vmm_symbiotic.c index 239efdc..7d9ea4c 100644 --- a/palacios/src/palacios/vmm_symbiotic.c +++ b/palacios/src/palacios/vmm_symbiotic.c @@ -75,6 +75,22 @@ int v3_init_symbiotic_vm(struct v3_vm_info * vm) { } +int v3_deinit_symbiotic_vm(struct v3_vm_info * vm) { + +#ifdef CONFIG_SYMMOD + if (v3_deinit_symmod_vm(vm) == -1) { + PrintError("Error deinitializing global SymMod state\n"); + return -1; + } +#endif + + v3_unhook_cpuid(vm, SYM_CPUID_NUM); + + + return 0; +} + + int v3_init_symbiotic_core(struct guest_info * core) { struct v3_sym_core_state * core_state = &(core->sym_core_state); @@ -88,3 +104,9 @@ int v3_init_symbiotic_core(struct guest_info * core) { return 0; } + + +int v3_deinit_symbiotic_core(struct guest_info * core) { + + return 0; +} diff --git a/palacios/src/palacios/vmm_symmod.c b/palacios/src/palacios/vmm_symmod.c index 7ca94d2..b037635 100644 --- a/palacios/src/palacios/vmm_symmod.c +++ b/palacios/src/palacios/vmm_symmod.c @@ -215,6 +215,22 @@ int v3_init_symmod_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { return 0; } +int v3_deinit_symmod_vm(struct v3_vm_info * vm) { + struct v3_symmod_state * symmod_state = &(vm->sym_vm_state.symmod_state); + struct v3_symbol * sym = NULL; + struct v3_symbol * tmp_sym = NULL; + + v3_remove_hypercall(vm, SYMMOD_SYMS_HCALL); + + v3_free_htable(symmod_state->capsule_table, 0, 0); + + list_for_each_entry_safe(sym, tmp_sym, &(symmod_state->v3_sym_list), sym_node) { + list_del(&(sym->sym_node)); + V3_Free(sym); + } + + return 0; +} int v3_set_symmod_loader(struct v3_vm_info * vm, struct v3_symmod_loader_ops * ops, void * priv_data) {