aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>2011-01-25 18:06:53 +0000
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>2011-01-25 18:06:53 +0000
commit62c2a1d0989f67827868171e52ecd4b916a496b3 (patch)
tree8d451b55eec056dc9c901976dce002b5ee064b25
parentb6c307fa49d929b65273793d7c5c89ef74972337 (diff)
downloadxen-62c2a1d0989f67827868171e52ecd4b916a496b3.tar.gz
xen-62c2a1d0989f67827868171e52ecd4b916a496b3.tar.bz2
xen-62c2a1d0989f67827868171e52ecd4b916a496b3.zip
libxl/xl: support empty disk paths (ejected cdroms)
Support empty disk paths, including in domain config files, for compatibility with xend. This allows a domain to be created with a cdrom which is initially in the "ejected" (no cd present) state. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r--tools/libxl/libxl.c10
-rw-r--r--tools/libxl/libxl.h1
-rw-r--r--tools/libxl/libxl_device.c2
-rw-r--r--tools/libxl/xl_cmdimpl.c9
4 files changed, 16 insertions, 6 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index c4477c7c52..93a22d2024 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -646,8 +646,8 @@ int libxl_event_get_disk_eject_info(libxl_ctx *ctx, uint32_t domid, libxl_event
disk->backend_domid = 0;
disk->domid = domid;
- disk->physpath = NULL;
- disk->phystype = 0;
+ disk->physpath = strdup("");
+ disk->phystype = PHYSTYPE_EMPTY;
/* this value is returned to the user: do not free right away */
disk->virtpath = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/dev", backend));
disk->unpluggable = 1;
@@ -882,6 +882,8 @@ int libxl_device_disk_add(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *dis
device.backend_kind = DEVICE_VBD;
break;
}
+ case PHYSTYPE_EMPTY:
+ break;
case PHYSTYPE_FILE:
/* let's pretend is tap:aio for the moment */
disk->phystype = PHYSTYPE_AIO;
@@ -1606,7 +1608,7 @@ static unsigned int libxl_append_disk_list_of_type(libxl_ctx *ctx,
pdisk->backend_domid = 0;
pdisk->domid = domid;
physpath_tmp = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "%s/%s/params", be_path, *dir), &len);
- if (strchr(physpath_tmp, ':')) {
+ if (physpath_tmp && strchr(physpath_tmp, ':')) {
pdisk->physpath = strdup(strchr(physpath_tmp, ':') + 1);
free(physpath_tmp);
} else {
@@ -1684,7 +1686,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk)
if (!disk->physpath) {
disk->physpath = strdup("");
- disk->phystype = PHYSTYPE_PHY;
+ disk->phystype = PHYSTYPE_EMPTY;
}
disks = libxl_device_disk_list(ctx, domid, &num);
for (i = 0; i < num; i++) {
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index cf97b7c3b3..1160de3c8c 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -178,6 +178,7 @@ typedef enum {
PHYSTYPE_AIO,
PHYSTYPE_FILE,
PHYSTYPE_PHY,
+ PHYSTYPE_EMPTY,
} libxl_disk_phystype;
typedef enum {
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 2d430b7ffe..cf694d2f82 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -130,6 +130,7 @@ char *libxl__device_disk_string_of_phystype(libxl_disk_phystype phystype)
case PHYSTYPE_AIO: return "aio";
case PHYSTYPE_FILE: return "file";
case PHYSTYPE_PHY: return "phy";
+ case PHYSTYPE_EMPTY: return "file";
default: return NULL;
}
}
@@ -143,6 +144,7 @@ char *libxl__device_disk_backend_type_of_phystype(libxl_disk_phystype phystype)
case PHYSTYPE_AIO: return "tap";
/* let's pretend file is tap:aio */
case PHYSTYPE_FILE: return "tap";
+ case PHYSTYPE_EMPTY: return "tap";
case PHYSTYPE_PHY: return "phy";
default: return NULL;
}
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 5f2cab299a..ba2bc29e4b 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -457,6 +457,11 @@ static int parse_disk_config(libxl_device_disk *disk, char *buf2)
return 0;
}
tok = p + 1;
+ } else if (*p == ',') {
+ state = DSTATE_VIRTPATH;
+ disk->phystype = PHYSTYPE_EMPTY;
+ disk->physpath = strdup("");
+ tok = p + 1;
}
break;
case DSTATE_TAP:
@@ -1834,8 +1839,8 @@ static void cd_insert(const char *dom, const char *virtdev, char *phys)
libxl_string_to_phystype(&ctx, phys, &disk.phystype);
}
} else {
- disk.physpath = NULL;
- disk.phystype = 0;
+ disk.physpath = strdup("");
+ disk.phystype = PHYSTYPE_EMPTY;
}
disk.virtpath = (char*)virtdev;
disk.unpluggable = 1;