ia64/xen-unstable

changeset 17233:3d6d042144d7

stubdom: add support for reading the command line from the config
file, and merge the dmargs with it in the case of qemu.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 18 11:27:05 2008 +0000 (2008-03-18)
parents 312053c2da89
children 14b2319d6126
files extras/mini-os/main.c tools/python/xen/xend/image.py
line diff
     1.1 --- a/extras/mini-os/main.c	Tue Mar 18 11:26:43 2008 +0000
     1.2 +++ b/extras/mini-os/main.c	Tue Mar 18 11:27:05 2008 +0000
     1.3 @@ -42,6 +42,9 @@ void _fini(void)
     1.4  static void call_main(void *p)
     1.5  {
     1.6      char *args, /**path,*/ *msg, *c;
     1.7 +#ifdef CONFIG_QEMU
     1.8 +    char *domargs;
     1.9 +#endif
    1.10      int argc;
    1.11      char **argv;
    1.12      char *envp[] = { NULL };
    1.13 @@ -63,14 +66,12 @@ static void call_main(void *p)
    1.14      }
    1.15  
    1.16      /* Fetch argc, argv from XenStore */
    1.17 -    char domid_s[10];
    1.18      int domid;
    1.19      domid = xenbus_read_integer("target");
    1.20      if (domid == -1) {
    1.21          printk("Couldn't read target\n");
    1.22          do_exit();
    1.23      }
    1.24 -    snprintf(domid_s, sizeof(domid_s), "%d", domid);
    1.25  
    1.26      snprintf(path, sizeof(path), "/local/domain/%d/vm", domid);
    1.27      msg = xenbus_read(XBT_NIL, path, &vm);
    1.28 @@ -78,59 +79,64 @@ static void call_main(void *p)
    1.29          printk("Couldn't read vm path\n");
    1.30          do_exit();
    1.31      }
    1.32 -    printk("vm is at %s\n", vm);
    1.33 -#else
    1.34 +    printk("dom vm is at %s\n", vm);
    1.35 +
    1.36 +    snprintf(path, sizeof(path), "%s/image/dmargs", vm);
    1.37 +    free(vm);
    1.38 +    msg = xenbus_read(XBT_NIL, path, &domargs);
    1.39 +
    1.40 +    if (msg) {
    1.41 +        printk("Couldn't get stubdom args: %s\n", msg);
    1.42 +        domargs = strdup("");
    1.43 +    }
    1.44 +#endif
    1.45 +
    1.46      msg = xenbus_read(XBT_NIL, "vm", &vm);
    1.47      if (msg) {
    1.48          printk("Couldn't read vm path\n");
    1.49          do_exit();
    1.50      }
    1.51 -#endif
    1.52  
    1.53 -    snprintf(path, sizeof(path), "%s/image/dmargs", vm);
    1.54 +    printk("my vm is at %s\n", vm);
    1.55 +    snprintf(path, sizeof(path), "%s/image/cmdline", vm);
    1.56      free(vm);
    1.57      msg = xenbus_read(XBT_NIL, path, &args);
    1.58  
    1.59      if (msg) {
    1.60 -        printk("Couldn't get stubdom args: %s\n", msg);
    1.61 +        printk("Couldn't get my args: %s\n", msg);
    1.62          args = strdup("");
    1.63      }
    1.64  
    1.65      argc = 1;
    1.66 +
    1.67 +#define PARSE_ARGS(ARGS,START,END) \
    1.68 +    c = ARGS; \
    1.69 +    while (*c) { \
    1.70 +	if (*c != ' ') { \
    1.71 +	    START; \
    1.72 +	    while (*c && *c != ' ') \
    1.73 +		c++; \
    1.74 +	} else { \
    1.75 +            END; \
    1.76 +	    while (*c == ' ') \
    1.77 +		c++; \
    1.78 +	} \
    1.79 +    }
    1.80 +
    1.81 +    PARSE_ARGS(args, argc++, );
    1.82  #ifdef CONFIG_QEMU
    1.83 -    argc += 2;
    1.84 +    PARSE_ARGS(domargs, argc++, );
    1.85  #endif
    1.86 -    c = args;
    1.87 -    while (*c) {
    1.88 -	if (*c != ' ') {
    1.89 -	    argc++;
    1.90 -	    while (*c && *c != ' ')
    1.91 -		c++;
    1.92 -	} else {
    1.93 -	    while (*c == ' ')
    1.94 -		c++;
    1.95 -	}
    1.96 -    }
    1.97 +
    1.98      argv = alloca((argc + 1) * sizeof(char *));
    1.99      argv[0] = "main";
   1.100      argc = 1;
   1.101 +
   1.102 +    PARSE_ARGS(args, argv[argc++] = c, *c++ = 0)
   1.103  #ifdef CONFIG_QEMU
   1.104 -    argv[1] = "-d";
   1.105 -    argv[2] = domid_s;
   1.106 -    argc += 2;
   1.107 +    PARSE_ARGS(domargs, argv[argc++] = c, *c++ = 0)
   1.108  #endif
   1.109 -    c = args;
   1.110 -    while (*c) {
   1.111 -	if (*c != ' ') {
   1.112 -	    argv[argc++] = c;
   1.113 -	    while (*c && *c != ' ')
   1.114 -		c++;
   1.115 -	} else {
   1.116 -	    *c++ = 0;
   1.117 -	    while (*c == ' ')
   1.118 -		c++;
   1.119 -	}
   1.120 -    }
   1.121 +
   1.122      argv[argc] = NULL;
   1.123  
   1.124      for (i = 0; i < argc; i++)
     2.1 --- a/tools/python/xen/xend/image.py	Tue Mar 18 11:26:43 2008 +0000
     2.2 +++ b/tools/python/xen/xend/image.py	Tue Mar 18 11:27:05 2008 +0000
     2.3 @@ -90,6 +90,7 @@ class ImageHandler:
     2.4                          ("image/kernel", self.kernel),
     2.5                          ("image/cmdline", self.cmdline),
     2.6                          ("image/ramdisk", self.ramdisk))
     2.7 +        self.vm.permissionsVm("image/cmdline", { 'dom': self.vm.getDomid(), 'read': True } )
     2.8  
     2.9          self.device_model = vmConfig['platform'].get('device_model')
    2.10