ia64/xen-unstable

changeset 16133:2372f89c0447

ioemu: Allow blktap to be able to be booted as system volume for PV-on-HVM

- All xvdN disk is looked like hdN.
- All tap disks are checked.(tap:aio, tap:sync, tap:vmdk, etc.)

Signed-off-by: Takanori Kasai <kasai.takanori@jp.fujitsu.com>
author Keir Fraser <keir@xensource.com>
date Mon Oct 15 12:24:35 2007 +0100 (2007-10-15)
parents c19c51317eeb
children 07c8b97ee1af
files tools/ioemu/xenstore.c
line diff
     1.1 --- a/tools/ioemu/xenstore.c	Mon Oct 15 12:20:43 2007 +0100
     1.2 +++ b/tools/ioemu/xenstore.c	Mon Oct 15 12:24:35 2007 +0100
     1.3 @@ -82,7 +82,7 @@ void xenstore_parse_domain_config(int do
     1.4      char **e = NULL;
     1.5      char *buf = NULL, *path;
     1.6      char *fpath = NULL, *bpath = NULL,
     1.7 -        *dev = NULL, *params = NULL, *type = NULL;
     1.8 +        *dev = NULL, *params = NULL, *type = NULL, *drv = NULL;
     1.9      int i, is_scsi;
    1.10      unsigned int len, num, hd_index;
    1.11  
    1.12 @@ -123,6 +123,14 @@ void xenstore_parse_domain_config(int do
    1.13          dev = xs_read(xsh, XBT_NULL, buf, &len);
    1.14          if (dev == NULL)
    1.15              continue;
    1.16 +        /* Change xvdN to look like hdN */
    1.17 +        if (!strncmp(dev, "xvd", 3 )) {
    1.18 +            fprintf(logfile, "Change xvd%c to look like hd%c\n",
    1.19 +                    dev[3], dev[3]);
    1.20 +            memmove(dev, dev+1, strlen(dev));
    1.21 +            dev[0] = 'h';
    1.22 +            dev[1] = 'd';
    1.23 +        }
    1.24          is_scsi = !strncmp(dev, "sd", 2);
    1.25          if ((strncmp(dev, "hd", 2) && !is_scsi) || strlen(dev) != 3 )
    1.26              continue;
    1.27 @@ -140,6 +148,22 @@ void xenstore_parse_domain_config(int do
    1.28          params = xs_read(xsh, XBT_NULL, buf, &len);
    1.29          if (params == NULL)
    1.30              continue;
    1.31 +        /* read the name of the device */
    1.32 +        if (pasprintf(&buf, "%s/type", bpath) == -1)
    1.33 +            continue;
    1.34 +        free(drv);
    1.35 +        drv = xs_read(xsh, XBT_NULL, buf, &len);
    1.36 +        if (drv == NULL)
    1.37 +            continue;
    1.38 +        /* Strip off blktap sub-type prefix aio: - QEMU can autodetect this */
    1.39 +        if (!strcmp(drv, "tap") && params[0]) {
    1.40 +            char *offset = strchr(params, ':'); 
    1.41 +            if (!offset)
    1.42 +                continue ;
    1.43 +            memmove(params, offset+1, strlen(offset+1)+1 );
    1.44 +            fprintf(logfile, "Strip off blktap sub-type prefix to %s\n", params); 
    1.45 +        }
    1.46 +
    1.47          /* 
    1.48           * check if device has a phantom vbd; the phantom is hooked
    1.49           * to the frontend device (for ease of cleanup), so lookup 
    1.50 @@ -202,6 +226,7 @@ void xenstore_parse_domain_config(int do
    1.51      free(buf);
    1.52      free(path);
    1.53      free(e);
    1.54 +    free(drv);
    1.55      return;
    1.56  }
    1.57