From 77b1ee94c3a95ce8ddac42779ac569099909240e Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 15 Oct 2007 12:24:35 +0100 Subject: [PATCH] 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 --- tools/ioemu/xenstore.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/ioemu/xenstore.c b/tools/ioemu/xenstore.c index 80ba5f40a9..115b1a2b1e 100644 --- a/tools/ioemu/xenstore.c +++ b/tools/ioemu/xenstore.c @@ -82,7 +82,7 @@ void xenstore_parse_domain_config(int domid) char **e = NULL; char *buf = NULL, *path; char *fpath = NULL, *bpath = NULL, - *dev = NULL, *params = NULL, *type = NULL; + *dev = NULL, *params = NULL, *type = NULL, *drv = NULL; int i, is_scsi; unsigned int len, num, hd_index; @@ -123,6 +123,14 @@ void xenstore_parse_domain_config(int domid) dev = xs_read(xsh, XBT_NULL, buf, &len); if (dev == NULL) continue; + /* Change xvdN to look like hdN */ + if (!strncmp(dev, "xvd", 3 )) { + fprintf(logfile, "Change xvd%c to look like hd%c\n", + dev[3], dev[3]); + 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; @@ -140,6 +148,22 @@ void xenstore_parse_domain_config(int domid) params = xs_read(xsh, XBT_NULL, buf, &len); if (params == NULL) continue; + /* read the name 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; + /* Strip off blktap sub-type prefix aio: - QEMU can autodetect this */ + if (!strcmp(drv, "tap") && params[0]) { + char *offset = strchr(params, ':'); + if (!offset) + continue ; + memmove(params, offset+1, strlen(offset+1)+1 ); + fprintf(logfile, "Strip off blktap sub-type prefix to %s\n", params); + } + /* * check if device has a phantom vbd; the phantom is hooked * to the frontend device (for ease of cleanup), so lookup @@ -202,6 +226,7 @@ void xenstore_parse_domain_config(int domid) free(buf); free(path); free(e); + free(drv); return; } -- 2.39.5