[libvirt] [PATCH libvirt] qemu: show a warning when using aio=native without cache=none

Qemu will fallback to aio=threads when the cache mode doesn't use O_DIRECT, even if aio=native was explictly set. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1086704 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/qemu/qemu_command.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fb64cda..92a6c9a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3477,6 +3477,13 @@ qemuBuildDriveStr(virConnectPtr conn, mode = qemuDiskCacheV1TypeToString(disk->cachemode); } + if (disk->iomode == VIR_DOMAIN_DISK_IO_NATIVE && + disk->cachemode != VIR_DOMAIN_DISK_CACHE_DIRECTSYNC) { + VIR_WARN("native I/O needs either no disk cache " + "or directsync cache mode, QEMU will fallback " + "to aio=threads"); + } + virBufferAsprintf(&opt, ",cache=%s", mode); } else if (disk->shared && !disk->readonly) { virBufferAddLit(&opt, ",cache=off"); -- 1.9.3

On Tue, Jul 08, 2014 at 02:08:38PM +0200, Giuseppe Scrivano wrote:
Qemu will fallback to aio=threads when the cache mode doesn't use O_DIRECT, even if aio=native was explictly set.
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1086704
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/qemu/qemu_command.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fb64cda..92a6c9a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3477,6 +3477,13 @@ qemuBuildDriveStr(virConnectPtr conn, mode = qemuDiskCacheV1TypeToString(disk->cachemode); }
+ if (disk->iomode == VIR_DOMAIN_DISK_IO_NATIVE && + disk->cachemode != VIR_DOMAIN_DISK_CACHE_DIRECTSYNC) { + VIR_WARN("native I/O needs either no disk cache " + "or directsync cache mode, QEMU will fallback " + "to aio=threads"); + }
VIR_WARN is not really appropriate for warning about things that are client application mistakes. If this combination of options does not work or is not supported then we should report an error about this. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

"Daniel P. Berrange" <berrange@redhat.com> writes:
On Tue, Jul 08, 2014 at 02:08:38PM +0200, Giuseppe Scrivano wrote:
Qemu will fallback to aio=threads when the cache mode doesn't use O_DIRECT, even if aio=native was explictly set.
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1086704
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/qemu/qemu_command.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fb64cda..92a6c9a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3477,6 +3477,13 @@ qemuBuildDriveStr(virConnectPtr conn, mode = qemuDiskCacheV1TypeToString(disk->cachemode); }
+ if (disk->iomode == VIR_DOMAIN_DISK_IO_NATIVE && + disk->cachemode != VIR_DOMAIN_DISK_CACHE_DIRECTSYNC) { + VIR_WARN("native I/O needs either no disk cache " + "or directsync cache mode, QEMU will fallback " + "to aio=threads"); + }
VIR_WARN is not really appropriate for warning about things that are client application mistakes. If this combination of options does not work or is not supported then we should report an error about this.
I didn't want to block the VM execution as anyway qemu allows this combination. I will change it to use virReportError. Thanks, Giuseppe

Qemu will fallback to aio=threads when the cache mode doesn't use O_DIRECT, even if aio=native was explictly set. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1086704 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/qemu/qemu_command.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index fb64cda..8c12cad 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3477,6 +3477,16 @@ qemuBuildDriveStr(virConnectPtr conn, mode = qemuDiskCacheV1TypeToString(disk->cachemode); } + if (disk->iomode == VIR_DOMAIN_DISK_IO_NATIVE && + disk->cachemode != VIR_DOMAIN_DISK_CACHE_DIRECTSYNC && + disk->cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("native I/O needs either no disk cache " + "or directsync cache mode, QEMU will fallback " + "to aio=threads")); + goto error; + } + virBufferAsprintf(&opt, ",cache=%s", mode); } else if (disk->shared && !disk->readonly) { virBufferAddLit(&opt, ",cache=off"); -- 1.9.3

On 07/08/2014 08:08 AM, Giuseppe Scrivano wrote:
Qemu will fallback to aio=threads when the cache mode doesn't use O_DIRECT, even if aio=native was explictly set.
oops, I meant to do s/explictly/explicitly/, but pushed too soon.
Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1086704
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> --- src/qemu/qemu_command.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
ACK and pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Giuseppe Scrivano