From a5ed18b7c4665b585815c5f734e0575857b0abcf Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 16 Oct 2007 09:40:08 +0100 Subject: [PATCH] ioemu: Allow xvd* to co-exist with hd*. - Whether hdN is defined first is checked. - If hdN is defined, xvdN is not replaced with hdN. Signed-off-by: Takanori Kasai --- tools/ioemu/xenstore.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/ioemu/xenstore.c b/tools/ioemu/xenstore.c index 115b1a2b1e..eed10e27c7 100644 --- a/tools/ioemu/xenstore.c +++ b/tools/ioemu/xenstore.c @@ -83,7 +83,7 @@ void xenstore_parse_domain_config(int domid) char *buf = NULL, *path; char *fpath = NULL, *bpath = NULL, *dev = NULL, *params = NULL, *type = NULL, *drv = NULL; - int i, is_scsi; + int i, is_scsi, is_hdN = 0; unsigned int len, num, hd_index; for(i = 0; i < MAX_DISKS + MAX_SCSI_DISKS; i++) @@ -108,6 +108,27 @@ void xenstore_parse_domain_config(int domid) if (e == NULL) goto out; + for (i = 0; i < num; i++) { + /* read the backend path */ + if (pasprintf(&buf, "%s/device/vbd/%s/backend", path, e[i]) == -1) + continue; + free(bpath); + bpath = xs_read(xsh, XBT_NULL, buf, &len); + if (bpath == NULL) + continue; + /* read the name of the device */ + if (pasprintf(&buf, "%s/dev", bpath) == -1) + continue; + free(dev); + dev = xs_read(xsh, XBT_NULL, buf, &len); + if (dev == NULL) + continue; + if (!strncmp(dev, "hd", 2)) { + is_hdN = 1; + break; + } + } + for (i = 0; i < num; i++) { /* read the backend path */ if (pasprintf(&buf, "%s/device/vbd/%s/backend", path, e[i]) == -1) @@ -124,7 +145,7 @@ void xenstore_parse_domain_config(int domid) if (dev == NULL) continue; /* Change xvdN to look like hdN */ - if (!strncmp(dev, "xvd", 3 )) { + if (!is_hdN && !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)); -- 2.39.5