Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Split global option processing code into a separate file
Patrick G. Bridges [Wed, 20 Feb 2013 17:54:50 +0000 (10:54 -0700)]
palacios/include/palacios/vmm_options.h [new file with mode: 0644]
palacios/src/palacios/vmm.c
palacios/src/palacios/vmm_options.c [new file with mode: 0644]

diff --git a/palacios/include/palacios/vmm_options.h b/palacios/include/palacios/vmm_options.h
new file mode 100644 (file)
index 0000000..16dab9a
--- /dev/null
@@ -0,0 +1,35 @@
+/* 
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National 
+ * Science Foundation and the Department of Energy.  
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico.  You can find out more at 
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2008, Peter Dinda <pdinda@northwestern.edu> 
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved.
+ *
+ * Author: Peter Dinda <pdinda@northwestern.edu>
+ * Author: Andy Gocke <agocke@gmail.com>
+ *
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+#ifndef __VMM_OPTIONS_H
+#define __VMM_OPTIONS_H
+
+#ifdef __V3VEE__
+
+#include <palacios/vm_guest.h>
+#include <palacios/vmm.h>
+
+
+void v3_parse_options(char *optstring);
+char *v3_lookup_option(char *option);
+
+#endif // ! __V3VEE__
+
+#endif
index 491b7de..6e32e88 100644 (file)
@@ -26,7 +26,7 @@
 #include <palacios/vmm_sprintf.h>
 #include <palacios/vmm_extensions.h>
 #include <palacios/vmm_timeout.h>
-
+#include <palacios/vmm_options.h>
 
 #ifdef V3_CONFIG_SVM
 #include <palacios/svm.h>
@@ -99,87 +99,6 @@ 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 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;
@@ -198,7 +117,7 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus, char *op
     }
 
     // Parse host-os defined options into an easily-accessed format.
-    V3_parse_options(options);
+    v3_parse_options(options);
 
     // Register all the possible device types
     V3_init_devices();
diff --git a/palacios/src/palacios/vmm_options.c b/palacios/src/palacios/vmm_options.c
new file mode 100644 (file)
index 0000000..82f12d9
--- /dev/null
@@ -0,0 +1,107 @@
+/* 
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National 
+ * Science Foundation and the Department of Energy.  
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico.  You can find out more at 
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2013, Patrick G. Bridges <bridges@cs.unm.edu> 
+ * Copyright (c) 2013, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved.
+ *
+ * Author: Patrick G. Bridges <bridges@cs.unm.edu>
+ *
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
+
+#include <palacios/vmm.h>
+#include <palacios/vmm_config.h>
+#include <palacios/vm_guest.h>
+#include <palacios/vmm_sprintf.h>
+#include <palacios/vmm_options.h>
+
+/* 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 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 == '\t')) {
+           *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));
+}