Olaf Hering wrote:
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.
Even though cache mode was ignored before, should we now error on
unsupported values?
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(a)aepfle.de>
---
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;
+ }
If the answer to the above is yes, this should be changed to something like
switch (cachemode) {
case VIR_DOMAIN_DISK_CACHE_DEFAULT:
break;
case VIR_DOMAIN_DISK_CACHE_DISABLE:
case VIR_DOMAIN_DISK_CACHE_WRITETHRU:
case VIR_DOMAIN_DISK_CACHE_WRITEBACK:
case VIR_DOMAIN_DISK_CACHE_UNSAFE:
case VIR_DOMAIN_DISK_CACHE_LAST:
error...
break;
case VIR_DOMAIN_DISK_CACHE_DIRECTSYNC:
#if defined(LIBXL_HAVE_DEVICE_DISK_DIRECT_IO_SAFE)
x_disk->direct_io_safe = 1;
#else
error...
#endif
break;
}
Regards,
Jim
+}
+
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;