]> xenbits.xensource.com Git - people/tklengyel/xen.git/commitdiff
xl: add "device_model_args" to pass arbitrary extra arguments to device model
authorIan Campbell <ian.campbell@citrix.com>
Thu, 3 Mar 2011 17:07:40 +0000 (17:07 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 3 Mar 2011 17:07:40 +0000 (17:07 +0000)
The libxl support was already in place so simply plumb it through.
This allows for passing debug options to the device model and provides
a method to work around missing toolstack functionality.

e.g. xl does not current support floppy disks but adding:
     device_model_args = [ "-fda", "/scratch/fdboot.img" ]
allowed me to boot FreeDOS from a floppy image.

I was unable to find any equivalent functionality in xend so this is a
new xl feature.

Moved xmalloc/xrealloc earlier to allow use from parse_config_data.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c

index 2dd0f29e710ec7ebdb064da2c0469be2f5319892..de7230dd53d933257efcc6c2a678a4007f4865c0 100644 (file)
@@ -244,6 +244,26 @@ release_lock:
     return rc;
 }
 
+static void *xmalloc(size_t sz) {
+    void *r;
+    r = malloc(sz);
+    if (!r) { fprintf(stderr,"xl: Unable to malloc %lu bytes.\n",
+                      (unsigned long)sz); exit(-ERROR_FAIL); }
+    return r;
+}
+
+static void *xrealloc(void *ptr, size_t sz) {
+    void *r;
+    if (!sz) { free(ptr); return 0; }
+      /* realloc(non-0, 0) has a useless return value;
+       * but xrealloc(anything, 0) is like free
+       */
+    r = realloc(ptr, sz);
+    if (!r) { fprintf(stderr,"xl: Unable to realloc to %lu bytes.\n",
+                      (unsigned long)sz); exit(-ERROR_FAIL); }
+    return r;
+}
+
 #define LOG(_f, _a...)   dolog(__FILE__, __LINE__, __func__, _f "\n", ##_a)
 
 static void dolog(const char *file, int line, const char *func, char *fmt, ...)
@@ -1087,6 +1107,9 @@ skip_vfb:
     }
 
     if (c_info->hvm == 1) {
+        XLU_ConfigList *dmargs;
+        int nr_dmargs = 0;
+
         /* init dm from c and b */
         libxl_init_dm_info(dm_info, c_info, b_info);
 
@@ -1119,6 +1142,17 @@ skip_vfb:
         xlu_cfg_replace_string (config, "soundhw", &dm_info->soundhw);
         if (!xlu_cfg_get_long (config, "xen_platform_pci", &l))
             dm_info->xen_platform_pci = l;
+
+        if (!xlu_cfg_get_list(config, "device_model_args", &dmargs, &nr_dmargs, 0))
+        {
+            int i;
+            dm_info->extra = xmalloc(sizeof(char *) * (nr_dmargs + 1));
+            dm_info->extra[nr_dmargs] = NULL;
+            for (i=0; i<nr_dmargs; i++) {
+                const char *a = xlu_cfg_get_listitem(dmargs, i);
+                dm_info->extra[i] = a ? strdup(a) : NULL;
+            }
+        }
     }
 
     dm_info->type = c_info->hvm ? XENFV : XENPV;
@@ -1126,26 +1160,6 @@ skip_vfb:
     xlu_cfg_destroy(config);
 }
 
-static void *xmalloc(size_t sz) {
-    void *r;
-    r = malloc(sz);
-    if (!r) { fprintf(stderr,"xl: Unable to malloc %lu bytes.\n",
-                      (unsigned long)sz); exit(-ERROR_FAIL); }
-    return r;
-}
-
-static void *xrealloc(void *ptr, size_t sz) {
-    void *r;
-    if (!sz) { free(ptr); return 0; }
-      /* realloc(non-0, 0) has a useless return value;
-       * but xrealloc(anything, 0) is like free
-       */
-    r = realloc(ptr, sz);
-    if (!r) { fprintf(stderr,"xl: Unable to realloc to %lu bytes.\n",
-                      (unsigned long)sz); exit(-ERROR_FAIL); }
-    return r;
-}
-
 /* Returns 1 if domain should be restarted, 2 if domain should be renamed then restarted  */
 static int handle_domain_death(libxl_ctx *ctx, uint32_t domid, libxl_event *event,
                                libxl_domain_config *d_config, libxl_dominfo *info)