[PATCH] libxl: add support for cache=directsync to to libxl_device_disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Up to now xend and libxl did not have any way and need to specify a cache=
mode for block devices. At least the libxl driver did just ignore the
cachemode value.

With xen-4.5 a new knob was added to libxl which instructs qemu to use
threads=native cache=directsync in the qdisk driver. This mode was disabled
early due to a pvops kernel bug. As a workaround cache=writeback was set as
default. The kernel bug is long fixed. I assume the forward ported xenlinux
kernel never had this bug.

This change exposes the knob to libvirt. If cache=directsync is set qemu is
instructed to use native AIO.

This change also lays the ground work to set cache=unsafe at some point.
It is currently under investigation whether libxl should expose such knob.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
---
 src/libxl/libxl_conf.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4cb062e..79f4a82 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -739,6 +739,20 @@ libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
 #endif
 }
 
+static void
+libxlDiskSetCacheMode(libxl_device_disk *x_disk, int cachemode)
+{
+    switch (cachemode) {
+#if defined(LIBXL_HAVE_DEVICE_DISK_DIRECT_IO_SAFE)
+    case VIR_DOMAIN_DISK_CACHE_DIRECTSYNC:
+        x_disk->direct_io_safe = 1;
+        break;
+#endif
+    default:
+        break;
+    }
+}
+
 
 int
 libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
@@ -855,6 +869,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
     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);
+    libxlDiskSetCacheMode(x_disk, l_disk->cachemode);
     /* An empty CDROM must have the empty format, otherwise libxl fails. */
     if (x_disk->is_cdrom && !x_disk->pdev_path)
         x_disk->format = LIBXL_DISK_FORMAT_EMPTY;

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]