From: Patrick G. Bridges Date: Tue, 19 Feb 2013 19:19:03 +0000 (-0700) Subject: Merge branch 'devel' of ssh://newskysaw.cs.northwestern.edu/home/palacios/palacios... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1ea936272cd584e26b3a2be63d549fafd44e6dd;hp=cdaef2158977795b123c9dba6816eb6e9d54810d;p=palacios.git Merge branch 'devel' of ssh://newskysaw.cs.northwestern.edu/home/palacios/palacios into devel --- diff --git a/linux_module/main.c b/linux_module/main.c index 6996bfa..296d01b 100644 --- a/linux_module/main.c +++ b/linux_module/main.c @@ -39,10 +39,14 @@ int cpu_list_len = 0; module_param_array(cpu_list, int, &cpu_list_len, 0644); MODULE_PARM_DESC(cpu_list, "Comma-delimited list of CPUs that Palacios will run on"); +// Palacios options parameter +static char *options; +module_param(options, charp, 0); +MODULE_PARM_DESC(options, "Generic options to internal Palacios modules"); + int mod_allocs = 0; int mod_frees = 0; - static int v3_major_num = 0; static struct v3_guest * guest_map[MAX_VMS] = {[0 ... MAX_VMS - 1] = 0}; @@ -336,7 +340,7 @@ static int __init v3_init(void) { palacios_init_mm(); // Initialize Palacios - palacios_vmm_init(); + palacios_vmm_init(options); // initialize extensions diff --git a/linux_module/palacios-stubs.c b/linux_module/palacios-stubs.c index 92b3767..ec58c04 100644 --- a/linux_module/palacios-stubs.c +++ b/linux_module/palacios-stubs.c @@ -710,7 +710,7 @@ static struct v3_os_hooks palacios_os_hooks = { -int palacios_vmm_init( void ) +int palacios_vmm_init( char *options ) { int num_cpus = num_online_cpus(); char * cpu_mask = NULL; @@ -752,7 +752,7 @@ int palacios_vmm_init( void ) INFO("palacios_init starting - calling init_v3\n"); - Init_V3(&palacios_os_hooks, cpu_mask, num_cpus); + Init_V3(&palacios_os_hooks, cpu_mask, num_cpus, options); return 0; diff --git a/linux_module/palacios.h b/linux_module/palacios.h index a172adb..99ef5ef 100644 --- a/linux_module/palacios.h +++ b/linux_module/palacios.h @@ -114,7 +114,7 @@ struct v3_guest { -int palacios_vmm_init( void ); +int palacios_vmm_init( char *options ); int palacios_vmm_exit( void ); diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index 8e6c6de..083644e 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -374,7 +374,8 @@ struct v3_vm_state { struct v3_vcore_state vcore[0]; }; -void Init_V3(struct v3_os_hooks * hooks, char * cpus, int num_cpus); +char *v3_lookup_option(char *name); +void Init_V3(struct v3_os_hooks * hooks, char * cpus, int num_cpus, char *options); void Shutdown_V3( void ); diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 5f164b7..491b7de 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -99,8 +99,88 @@ static void deinit_cpu(void * arg) { } } +/* Options are space-separated values of the form "X=Y", for example + * scheduler=EDF CPUs=1,2,3,4 + * THe following code pushes them into a hashtable for each of access + * by other code. Storage is allocated for keys and values as part + * of this process. XXX Need a way to deallocate this storage if the + * module is removed XXX + */ +static char *option_storage; +static struct hashtable *option_table; +static char *truevalue = "true"; + +static uint_t option_hash_fn(addr_t key) { + char * name = (char *)key; + return v3_hash_buffer((uint8_t *)name, strlen(name)); +} +static int option_eq_fn(addr_t key1, addr_t key2) { + char * name1 = (char *)key1; + char * name2 = (char *)key2; + + return (strcmp(name1, name2) == 0); +} -void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus) { +void V3_parse_options(char *options) +{ + char *currKey = NULL, *currVal = NULL; + int parseKey = 1; + int len; + char *c; + if (!options) { + return; + } + + len = strlen(options); + option_storage = V3_Malloc(len + 1); + strcpy(option_storage, options); + c = option_storage; + + option_table = v3_create_htable(0, option_hash_fn, option_eq_fn); + while (c && *c) { + /* Skip whitespace */ + if (*c == ' ') { + *c = 0; + if (currKey) { + if (!currVal) { + currVal = truevalue; + } + v3_htable_insert(option_table, (addr_t)currKey, (addr_t)currVal); + parseKey = 1; + currKey = NULL; + currVal = NULL; + } + c++; + } else if (parseKey) { + if (!currKey) { + currKey = c; + } + if (*c == '=') { + parseKey = 0; + *c = 0; + } + c++; + } else /* !parseKey */ { + if (!currVal) { + currVal = c; + } + c++; + } + } + if (currKey) { + if (!currVal) { + currVal = truevalue; + } + v3_htable_insert(option_table, (addr_t)currKey, (addr_t)currVal); + } + return; +} + +char *v3_lookup_option(char *key) { + return (char *)v3_htable_search(option_table, (addr_t)(key)); +} + +void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus, char *options) { int i = 0; int minor = 0; int major = 0; @@ -117,6 +197,9 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus) { v3_cpu_types[i] = V3_INVALID_CPU; } + // Parse host-os defined options into an easily-accessed format. + V3_parse_options(options); + // Register all the possible device types V3_init_devices();