diff -r ff1a3395024c tools/ioemu/xenstore.c --- a/tools/ioemu/xenstore.c Fri Jun 29 15:37:48 2007 -0400 +++ b/tools/ioemu/xenstore.c Fri Jun 29 16:06:13 2007 -0400 @@ -64,7 +64,7 @@ void xenstore_parse_domain_config(int do { char **e = NULL; char *buf = NULL, *path; - char *bpath = NULL, *dev = NULL, *params = NULL, *type = NULL; + char *bpath = NULL, *dev = NULL, *params = NULL, *type = NULL, *drv = NULL; int i, is_scsi; unsigned int len, num, hd_index; @@ -98,6 +98,13 @@ void xenstore_parse_domain_config(int do bpath = xs_read(xsh, XBT_NULL, buf, &len); if (bpath == NULL) continue; + /* read the driver type of the device */ + if (pasprintf(&buf, "%s/type", bpath) == -1) + continue; + free(drv); + drv = xs_read(xsh, XBT_NULL, buf, &len); + if (drv == NULL) + continue; /* read the name of the device */ if (pasprintf(&buf, "%s/dev", bpath) == -1) continue; @@ -105,6 +112,13 @@ void xenstore_parse_domain_config(int do dev = xs_read(xsh, XBT_NULL, buf, &len); if (dev == NULL) continue; + /* Force xvdN to look like hdN */ + if (!strncmp(dev, "xvd", 3)) { + fprintf(logfile, "Converting device type '%s'\n", dev); + memmove(dev, dev+1, strlen(dev)); + dev[0] = 'h'; + dev[1] = 'd'; + } is_scsi = !strncmp(dev, "sd", 2); if ((strncmp(dev, "hd", 2) && !is_scsi) || strlen(dev) != 3 ) continue; @@ -122,7 +136,15 @@ void xenstore_parse_domain_config(int do params = xs_read(xsh, XBT_NULL, buf, &len); if (params == NULL) continue; - + /* Strip off blktap sub-type prefix aio: - QEMU can autodetect this */ + if (!strcmp(drv, "tap") && params[0]) { + char *offset = strchr(params, ':'); + if (!offset) + continue; + fprintf(logfile, "Stripping blktap sub-type prefix from %s\n", params); + memmove(params, offset+1, strlen(offset+1)+1); + } + fprintf(logfile, "Creating disk '%s' with driver '%s'\n", dev, drv); bs_table[hd_index + (is_scsi ? MAX_DISKS : 0)] = bdrv_new(dev); /* check if it is a cdrom */ if (type && !strcmp(type, "cdrom")) { @@ -131,6 +153,7 @@ void xenstore_parse_domain_config(int do } /* open device now if media present */ if (params[0]) { + fprintf(logfile, "Initializing disk '%s' with media '%s'\n", dev, params); if (bdrv_open(bs_table[hd_index + (is_scsi ? MAX_DISKS : 0)], params, 0 /* snapshot */) < 0) fprintf(stderr, "qemu: could not open hard disk image '%s'\n", @@ -146,6 +169,7 @@ void xenstore_parse_domain_config(int do out: + free(drv); free(type); free(params); free(dev);