Translate libvirt discard settings into libxl-4.5 discard settings. It makes use of upcoming changes for xen-4.5: http://lists.xenproject.org/archives/html/xen-devel/2014-01/msg02632.html This patch is not compile tested. How is a config file supposed to look like to make use of a discard=on|off flag for a given disk image? Signed-off-by: Olaf Hering <olaf@xxxxxxxxx> Cc: Jim Fehlig <jfehlig@xxxxxxxx> --- src/libxl/libxl_conf.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 4cefadf..8fc5e75 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -707,6 +707,26 @@ error: return -1; } +static void +libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard) +{ + if (!x_disk->readwrite) + return; +#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE) + /* libxl 4.5 */ + switch (discard) { + case VIR_DOMAIN_DISK_DISCARD_DEFAULT: + case VIR_DOMAIN_DISK_DISCARD_UNMAP: + x_disk->discard_enable = 1; + break; + default: + case VIR_DOMAIN_DISK_DISCARD_IGNORE: + x_disk->discard_enable = 0; + break; + } +#endif +} + int libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk) { @@ -817,6 +837,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk) x_disk->removable = 1; x_disk->readwrite = !l_disk->readonly; x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0; + libxlDiskSetDiscard(x_disk, l_disk->discard); if (l_disk->transient) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("libxenlight does not support transient disks")); -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list