X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_extensions.c;h=fb5d6e01e46619b3b319e4c351dde8e7cf8281b7;hb=e2a6eba59e9be18cbf5095df4da4d716cf1cf141;hp=ee16ca0ead46229203fbee36379fd40d3d4ea11c;hpb=c900a49cfd8ff982a35bb7385fbd927e961569a0;p=palacios.git diff --git a/palacios/src/palacios/vmm_extensions.c b/palacios/src/palacios/vmm_extensions.c index ee16ca0..fb5d6e0 100644 --- a/palacios/src/palacios/vmm_extensions.c +++ b/palacios/src/palacios/vmm_extensions.c @@ -58,15 +58,26 @@ int V3_init_extensions() { ext_table = v3_create_htable(0, ext_hash_fn, ext_eq_fn); while (tmp_ext != __stop__v3_extensions) { - V3_Print("Registering Extension (%s)\n", (*tmp_ext)->name); + + if (!(*tmp_ext)) { + PrintError(VM_NONE, VCORE_NONE, "Impossible extension\n"); + return -1; + } + + if ((*tmp_ext)->init && ((*tmp_ext)->init() != 0)) { + PrintError(VM_NONE, VCORE_NONE, "Could not initialize extension (%s)\n", (*tmp_ext)->name); + return -1; + } + + V3_Print(VM_NONE, VCORE_NONE, "Registering Extension (%s)\n", (*tmp_ext)->name); if (v3_htable_search(ext_table, (addr_t)((*tmp_ext)->name))) { - PrintError("Multiple instances of Extension (%s)\n", (*tmp_ext)->name); + PrintError(VM_NONE, VCORE_NONE, "Multiple instances of Extension (%s)\n", (*tmp_ext)->name); return -1; } if (v3_htable_insert(ext_table, (addr_t)((*tmp_ext)->name), (addr_t)(*tmp_ext)) == 0) { - PrintError("Could not register Extension (%s)\n", (*tmp_ext)->name); + PrintError(VM_NONE, VCORE_NONE, "Could not register Extension (%s)\n", (*tmp_ext)->name); return -1; } @@ -109,23 +120,25 @@ int v3_deinit_ext_manager(struct v3_vm_info * vm) { list_for_each_entry_safe(ext, tmp, &(ext_state->extensions), node) { - V3_Print("Cleaning up Extension (%s)\n", ext->impl->name); - if ((ext->impl) && (ext->impl->deinit)) { - if (ext->impl->deinit(vm, ext->priv_data) == -1) { - PrintError("Error cleaning up extension (%s)\n", ext->impl->name); - return -1; + V3_Print(vm, VCORE_NONE, "Cleaning up Extension (%s)\n", ext->impl->name); + if (ext->impl) { + if (ext->impl->vm_deinit) { + if (ext->impl->vm_deinit(vm, ext->priv_data) == -1) { + PrintError(vm, VCORE_NONE, "Error cleaning up extension (%s)\n", ext->impl->name); + return -1; + } } - } - - if (ext->impl->on_exit) - list_del(&ext->exit_node); - - if (ext->impl->on_entry) - list_del(&ext->entry_node); - - list_del(&ext->node); - V3_Free(ext); + if (ext->impl->on_exit) + list_del(&ext->exit_node); + + if (ext->impl->on_entry) + list_del(&ext->entry_node); + } + + list_del(&ext->node); + V3_Free(ext); + } return 0; @@ -141,25 +154,25 @@ int v3_add_extension(struct v3_vm_info * vm, const char * name, v3_cfg_tree_t * impl = (void *)v3_htable_search(ext_table, (addr_t)name); if (impl == NULL) { - PrintError("Could not find requested extension (%s)\n", name); + PrintError(vm, VCORE_NONE, "Could not find requested extension (%s)\n", name); return -1; } - V3_ASSERT(impl->init); + V3_ASSERT(vm, VCORE_NONE, impl->vm_init); /* this allows each extension to track its own per-core state */ ext_size = sizeof(struct v3_extension) + (sizeof(void *) * vm->num_cores); ext = V3_Malloc(ext_size); if (!ext) { - PrintError("Could not allocate extension\n"); + PrintError(vm, VCORE_NONE, "Could not allocate extension\n"); return -1; } ext->impl = impl; - if (impl->init(vm, cfg, &(ext->priv_data)) == -1) { - PrintError("Error initializing Extension (%s)\n", name); + if (impl->vm_init(vm, cfg, &(ext->priv_data)) == -1) { + PrintError(vm, VCORE_NONE, "Error initializing Extension (%s)\n", name); V3_Free(ext); return -1; } @@ -184,7 +197,7 @@ int v3_init_core_extensions(struct guest_info * core) { list_for_each_entry(ext, &(core->vm_info->extensions.extensions), node) { if ((ext->impl) && (ext->impl->core_init)) { if (ext->impl->core_init(core, ext->priv_data, &(ext->core_ext_priv_data[cpuid])) == -1) { - PrintError("Error configuring per core extension %s on core %d\n", + PrintError(core->vm_info, core, "Error configuring per core extension %s on core %d\n", ext->impl->name, core->vcpu_id); return -1; } @@ -204,7 +217,7 @@ int v3_deinit_core_extensions (struct guest_info * core) { list_for_each_entry_safe(ext, tmp, &(vm->extensions.extensions), node) { if ((ext->impl) && (ext->impl->core_deinit)) { if (ext->impl->core_deinit(core, ext->priv_data, ext->core_ext_priv_data[cpuid]) == -1) { - PrintError("Error tearing down per core extension %s on core %d\n", + PrintError(core->vm_info, core, "Error tearing down per core extension %s on core %d\n", ext->impl->name, cpuid); return -1; }