debuggers.hg
changeset 22854:6ec61438713a
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>
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>
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> |
---|---|
date | Tue Jan 25 18:06:53 2011 +0000 (2011-01-25) |
parents | 787af706dadc |
children | 1d1eec7e1fb4 |
files | tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/libxl_device.c tools/libxl/xl_cmdimpl.c |
line diff
1.1 --- a/tools/libxl/libxl.c Tue Jan 25 17:02:47 2011 +0000 1.2 +++ b/tools/libxl/libxl.c Tue Jan 25 18:06:53 2011 +0000 1.3 @@ -646,8 +646,8 @@ int libxl_event_get_disk_eject_info(libx 1.4 1.5 disk->backend_domid = 0; 1.6 disk->domid = domid; 1.7 - disk->physpath = NULL; 1.8 - disk->phystype = 0; 1.9 + disk->physpath = strdup(""); 1.10 + disk->phystype = PHYSTYPE_EMPTY; 1.11 /* this value is returned to the user: do not free right away */ 1.12 disk->virtpath = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/dev", backend)); 1.13 disk->unpluggable = 1; 1.14 @@ -882,6 +882,8 @@ int libxl_device_disk_add(libxl_ctx *ctx 1.15 device.backend_kind = DEVICE_VBD; 1.16 break; 1.17 } 1.18 + case PHYSTYPE_EMPTY: 1.19 + break; 1.20 case PHYSTYPE_FILE: 1.21 /* let's pretend is tap:aio for the moment */ 1.22 disk->phystype = PHYSTYPE_AIO; 1.23 @@ -1606,7 +1608,7 @@ static unsigned int libxl_append_disk_li 1.24 pdisk->backend_domid = 0; 1.25 pdisk->domid = domid; 1.26 physpath_tmp = xs_read(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "%s/%s/params", be_path, *dir), &len); 1.27 - if (strchr(physpath_tmp, ':')) { 1.28 + if (physpath_tmp && strchr(physpath_tmp, ':')) { 1.29 pdisk->physpath = strdup(strchr(physpath_tmp, ':') + 1); 1.30 free(physpath_tmp); 1.31 } else { 1.32 @@ -1684,7 +1686,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, u 1.33 1.34 if (!disk->physpath) { 1.35 disk->physpath = strdup(""); 1.36 - disk->phystype = PHYSTYPE_PHY; 1.37 + disk->phystype = PHYSTYPE_EMPTY; 1.38 } 1.39 disks = libxl_device_disk_list(ctx, domid, &num); 1.40 for (i = 0; i < num; i++) {
2.1 --- a/tools/libxl/libxl.h Tue Jan 25 17:02:47 2011 +0000 2.2 +++ b/tools/libxl/libxl.h Tue Jan 25 18:06:53 2011 +0000 2.3 @@ -178,6 +178,7 @@ typedef enum { 2.4 PHYSTYPE_AIO, 2.5 PHYSTYPE_FILE, 2.6 PHYSTYPE_PHY, 2.7 + PHYSTYPE_EMPTY, 2.8 } libxl_disk_phystype; 2.9 2.10 typedef enum {
3.1 --- a/tools/libxl/libxl_device.c Tue Jan 25 17:02:47 2011 +0000 3.2 +++ b/tools/libxl/libxl_device.c Tue Jan 25 18:06:53 2011 +0000 3.3 @@ -130,6 +130,7 @@ char *libxl__device_disk_string_of_physt 3.4 case PHYSTYPE_AIO: return "aio"; 3.5 case PHYSTYPE_FILE: return "file"; 3.6 case PHYSTYPE_PHY: return "phy"; 3.7 + case PHYSTYPE_EMPTY: return "file"; 3.8 default: return NULL; 3.9 } 3.10 } 3.11 @@ -143,6 +144,7 @@ char *libxl__device_disk_backend_type_of 3.12 case PHYSTYPE_AIO: return "tap"; 3.13 /* let's pretend file is tap:aio */ 3.14 case PHYSTYPE_FILE: return "tap"; 3.15 + case PHYSTYPE_EMPTY: return "tap"; 3.16 case PHYSTYPE_PHY: return "phy"; 3.17 default: return NULL; 3.18 }
4.1 --- a/tools/libxl/xl_cmdimpl.c Tue Jan 25 17:02:47 2011 +0000 4.2 +++ b/tools/libxl/xl_cmdimpl.c Tue Jan 25 18:06:53 2011 +0000 4.3 @@ -457,6 +457,11 @@ static int parse_disk_config(libxl_devic 4.4 return 0; 4.5 } 4.6 tok = p + 1; 4.7 + } else if (*p == ',') { 4.8 + state = DSTATE_VIRTPATH; 4.9 + disk->phystype = PHYSTYPE_EMPTY; 4.10 + disk->physpath = strdup(""); 4.11 + tok = p + 1; 4.12 } 4.13 break; 4.14 case DSTATE_TAP: 4.15 @@ -1834,8 +1839,8 @@ static void cd_insert(const char *dom, c 4.16 libxl_string_to_phystype(&ctx, phys, &disk.phystype); 4.17 } 4.18 } else { 4.19 - disk.physpath = NULL; 4.20 - disk.phystype = 0; 4.21 + disk.physpath = strdup(""); 4.22 + disk.phystype = PHYSTYPE_EMPTY; 4.23 } 4.24 disk.virtpath = (char*)virtdev; 4.25 disk.unpluggable = 1;