X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_cpu_mapper.c;h=88256dd435b6aa060c4fbd5545a192f7eeb97e22;hb=210c49c1f9b523ff94fd5b6791961d242d5bbae4;hp=b99c626cf1da328d1ab85398551761fdef3b836e;hpb=40b983b217e8b8d0881309a9440195abbfdcce57;p=palacios.git diff --git a/palacios/src/palacios/vmm_cpu_mapper.c b/palacios/src/palacios/vmm_cpu_mapper.c index b99c626..88256dd 100644 --- a/palacios/src/palacios/vmm_cpu_mapper.c +++ b/palacios/src/palacios/vmm_cpu_mapper.c @@ -32,6 +32,7 @@ static char default_strategy[] = "default"; static struct hashtable * master_cpu_mapper_table = NULL; static int create_default_cpu_mapper(); +static int destroy_default_cpu_mapper(); static struct vm_cpu_mapper_impl *cpu_mapper = NULL; @@ -56,6 +57,16 @@ int V3_init_cpu_mapper() { } +int V3_deinit_cpu_mapper() { + + destroy_default_cpu_mapper(); + // we must leave the keys and values unfreed + // since we have no idea whether they are heap or otherwise + // the user must have done appropriate unregisters before this + v3_free_htable(master_cpu_mapper_table, 0, 0); + return 0; +} + int v3_register_cpu_mapper(struct vm_cpu_mapper_impl *s) { PrintDebug(VM_NONE, VCORE_NONE,"Registering cpu_mapper (%s)\n", s->name); @@ -75,6 +86,21 @@ int v3_register_cpu_mapper(struct vm_cpu_mapper_impl *s) { return 0; } +struct vm_cpu_mapper_impl *v3_unregister_cpu_mapper(char *name) { + + PrintDebug(VM_NONE, VCORE_NONE,"Unregistering cpu_mapper (%s)\n",name); + + struct vm_cpu_mapper_impl *f = (struct vm_cpu_mapper_impl *) v3_htable_remove(master_cpu_mapper_table,(addr_t)(name),0); + + if (!f) { + PrintError(VM_NONE,VCORE_NONE,"Could not find cpu_mapper (%s)\n",name); + return NULL; + } else { + return f; + } +} + + struct vm_cpu_mapper_impl *v3_cpu_mapper_lookup(char *name) { return (struct vm_cpu_mapper_impl *)v3_htable_search(master_cpu_mapper_table, (addr_t)(name)); @@ -108,17 +134,26 @@ int V3_enable_cpu_mapper() { } } -int v3_cpu_mapper_register_vm(struct v3_vm_info *vm,unsigned int cpu_mask) { +int V3_disable_cpu_mapper() +{ + if (cpu_mapper->deinit) { + return cpu_mapper->deinit(); + } else { + return 0; + } +} + +int v3_cpu_mapper_register_vm(struct v3_vm_info *vm) { if (cpu_mapper->vm_init) { - return cpu_mapper->vm_init(vm,cpu_mask); + return cpu_mapper->vm_init(vm); } else { return 0; } } -int v3_cpu_mapper_admit_vm(struct v3_vm_info *vm) { +int v3_cpu_mapper_admit_vm(struct v3_vm_info *vm, unsigned int cpu_mask) { if (cpu_mapper->admit) { - return cpu_mapper->admit(vm); + return cpu_mapper->admit(vm,cpu_mask); } else { return 0; } @@ -133,12 +168,16 @@ int v3_cpu_mapper_admit_core(struct v3_vm_info * vm, int vcore_id, int target_cp } } +int default_mapper_vm_init(struct v3_vm_info *vm){ + return 0; +} +int default_mapper_admit_core(struct v3_vm_info * vm, int vcore_id, int target_cpu){ + return 0; +} -int default_mapper_vm_init(struct v3_vm_info *vm, unsigned int cpu_mask) -{ - PrintDebug(vm, VCORE_NONE,"mapper. default_mapper_init\n"); +int default_mapper_admit(struct v3_vm_info *vm, unsigned int cpu_mask){ uint32_t i; int vcore_id = 0; @@ -155,6 +194,7 @@ int default_mapper_vm_init(struct v3_vm_info *vm, unsigned int cpu_mask) if (specified_cpu != NULL) { core_idx = atoi(specified_cpu); + // unsigned comparison with 0 if (core_idx < 0) { PrintError(vm, VCORE_NONE, "Target CPU out of bounds (%d) \n", core_idx); } @@ -181,26 +221,16 @@ int default_mapper_vm_init(struct v3_vm_info *vm, unsigned int cpu_mask) } - core->pcpu_id = core_idx; - vcore_id--; + core->pcpu_id = core_idx; + vcore_id--; } - if (vcore_id >= 0) { - v3_stop_vm(vm); - return -1; - } + // if (vcore_id >= 0) { // dead code... + //v3_stop_vm(vm); + //return -1; + //} return 0; - -} - -int default_mapper_admit_core(struct v3_vm_info * vm, int vcore_id, int target_cpu){ - return 0; -} - - -int default_mapper_admit(struct v3_vm_info *vm){ - return 0; } @@ -220,3 +250,10 @@ static int create_default_cpu_mapper() v3_register_cpu_mapper(&default_mapper_impl); return 0; } + +static int destroy_default_cpu_mapper() +{ + v3_unregister_cpu_mapper(default_mapper_impl.name); + // note - is not deleted since it's a global... + return 0; +}