2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2013, Patrick G. Bridges <bridges@cs.unm.edu>
11 * Copyright (c) 2013, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Patrick G. Bridges <bridges@cs.unm.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <palacios/vmm.h>
22 #include <palacios/vmm_config.h>
23 #include <palacios/vm_guest.h>
24 #include <palacios/vmm_sprintf.h>
25 #include <palacios/vmm_options.h>
27 /* Options are space-separated values of the form "X=Y", for example
28 * scheduler=EDF CPUs=1,2,3,4
29 * THe following code pushes them into a hashtable for each of access
30 * by other code. Storage is allocated for keys and values as part
31 * of this process. XXX Need a way to deallocate this storage if the
32 * module is removed XXX
34 static char *option_storage;
35 static struct hashtable *option_table;
36 static char *truevalue = "true";
38 static uint_t option_hash_fn(addr_t key) {
39 char * name = (char *)key;
40 return v3_hash_buffer((uint8_t *)name, strlen(name));
42 static int option_eq_fn(addr_t key1, addr_t key2) {
43 char * name1 = (char *)key1;
44 char * name2 = (char *)key2;
46 return (strcmp(name1, name2) == 0);
49 void v3_parse_options(char *options)
51 char *currKey = NULL, *currVal = NULL;
56 option_table = v3_create_htable(0, option_hash_fn, option_eq_fn);
62 len = strlen(options);
63 option_storage = V3_Malloc(len + 1);
64 strcpy(option_storage, options);
76 v3_htable_insert(option_table, (addr_t)currKey, (addr_t)currVal);
82 } else if (parseKey) {
91 } else /* !parseKey */ {
102 v3_htable_insert(option_table, (addr_t)currKey, (addr_t)currVal);
107 char *v3_lookup_option(char *key) {
108 return (char *)v3_htable_search(option_table, (addr_t)(key));