debuggers.hg
changeset 22882:2831c5c08df9
libxl: when using pygrub, do not segfault if no blktap
Running xl create configfile where configfile includes the lines
bootloader = "/usr/bin/pygrub"
disk = [ 'file:/dev/mapper/vg0-partname,xvda1,w' ]
then xl segfaults at the line
ret = strdup(dev);
of libxl_device_disk_local_attach() in tools/libxl/libxl.c . The
problem is that dev is not set if libxl__blktap_enabled(&gc) is false
or if phystype isn't recognized. In the latter case we want to skip
that line and return NULL, but if libxl__blktap_enabled(&gc) is false
we should be returning something, at least in the cases where the
device has a name in the host which we can just refer to.
Also improve the error message when QCOW or QCOW2 are specified, and
avoid using an uninitialised value of "ret".
Signed-off-by: M A Young <m.a.young@durham.ac.uk>
Signed-off-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Running xl create configfile where configfile includes the lines
bootloader = "/usr/bin/pygrub"
disk = [ 'file:/dev/mapper/vg0-partname,xvda1,w' ]
then xl segfaults at the line
ret = strdup(dev);
of libxl_device_disk_local_attach() in tools/libxl/libxl.c . The
problem is that dev is not set if libxl__blktap_enabled(&gc) is false
or if phystype isn't recognized. In the latter case we want to skip
that line and return NULL, but if libxl__blktap_enabled(&gc) is false
we should be returning something, at least in the cases where the
device has a name in the host which we can just refer to.
Also improve the error message when QCOW or QCOW2 are specified, and
avoid using an uninitialised value of "ret".
Signed-off-by: M A Young <m.a.young@durham.ac.uk>
Signed-off-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author | Stefano Stabellini <Stefano.Stabellini@eu.citrix.com> |
---|---|
date | Fri Jan 28 16:54:13 2011 +0000 (2011-01-28) |
parents | 4fea7664a6fb |
children | b58c9dd4ba90 |
files | tools/libxl/libxl.c |
line diff
1.1 --- a/tools/libxl/libxl.c Fri Jan 28 16:43:53 2011 +0000 1.2 +++ b/tools/libxl/libxl.c Fri Jan 28 16:54:13 2011 +0000 1.3 @@ -1021,7 +1021,7 @@ char * libxl_device_disk_local_attach(li 1.4 { 1.5 libxl__gc gc = LIBXL_INIT_GC(ctx); 1.6 const char *dev = NULL; 1.7 - char *ret; 1.8 + char *ret = NULL; 1.9 int phystype = disk->phystype; 1.10 switch (phystype) { 1.11 case PHYSTYPE_PHY: { 1.12 @@ -1033,18 +1033,27 @@ char * libxl_device_disk_local_attach(li 1.13 /* let's pretend is tap:aio for the moment */ 1.14 phystype = PHYSTYPE_AIO; 1.15 case PHYSTYPE_AIO: 1.16 - case PHYSTYPE_QCOW: 1.17 - case PHYSTYPE_QCOW2: 1.18 + if (!libxl__blktap_enabled(&gc)) { 1.19 + dev = disk->physpath; 1.20 + break; 1.21 + } 1.22 case PHYSTYPE_VHD: 1.23 if (libxl__blktap_enabled(&gc)) 1.24 dev = libxl__blktap_devpath(&gc, disk->physpath, phystype); 1.25 + else 1.26 + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "tapdisk2 is required to open a vhd disk\n"); 1.27 + break; 1.28 + case PHYSTYPE_QCOW: 1.29 + case PHYSTYPE_QCOW2: 1.30 + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "cannot locally attach a qcow or qcow2 disk image\n"); 1.31 break; 1.32 1.33 default: 1.34 LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "unrecognized disk physical type: %d\n", phystype); 1.35 break; 1.36 } 1.37 - ret = strdup(dev); 1.38 + if (dev != NULL) 1.39 + ret = strdup(dev); 1.40 libxl__free_all(&gc); 1.41 return ret; 1.42 }