mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
libxl: add discard support to libxl_device_disk
Translate libvirt discard settings into libxl-4.5 discard settings. Signed-off-by: Olaf Hering <olaf@aepfle.de>
This commit is contained in:
parent
0c04906fa8
commit
4e7e5e9f7b
@ -715,6 +715,35 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
|
||||||
|
{
|
||||||
|
if (!x_disk->readwrite)
|
||||||
|
return 0;
|
||||||
|
#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE)
|
||||||
|
switch ((enum virDomainDiskDiscard)discard) {
|
||||||
|
case VIR_DOMAIN_DISK_DISCARD_DEFAULT:
|
||||||
|
case VIR_DOMAIN_DISK_DISCARD_LAST:
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_DISCARD_UNMAP:
|
||||||
|
libxl_defbool_set(&x_disk->discard_enable, true);
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_DISCARD_IGNORE:
|
||||||
|
libxl_defbool_set(&x_disk->discard_enable, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
|
||||||
|
return 0;
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("This version of libxenlight does not support "
|
||||||
|
"disk 'discard' option passing"));
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
|
libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
|
||||||
{
|
{
|
||||||
@ -829,6 +858,8 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
|
|||||||
x_disk->removable = 1;
|
x_disk->removable = 1;
|
||||||
x_disk->readwrite = !l_disk->src->readonly;
|
x_disk->readwrite = !l_disk->src->readonly;
|
||||||
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
|
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
|
||||||
|
if (libxlDiskSetDiscard(x_disk, l_disk->discard) < 0)
|
||||||
|
return -1;
|
||||||
/* An empty CDROM must have the empty format, otherwise libxl fails. */
|
/* An empty CDROM must have the empty format, otherwise libxl fails. */
|
||||||
if (x_disk->is_cdrom && !x_disk->pdev_path)
|
if (x_disk->is_cdrom && !x_disk->pdev_path)
|
||||||
x_disk->format = LIBXL_DISK_FORMAT_EMPTY;
|
x_disk->format = LIBXL_DISK_FORMAT_EMPTY;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user