[PATCH 0/2] disk iomode validation cleanups

Peter Krempa (2): qemuValidateDomainDeviceDefDiskFrontend: Fix error message if io='native' is unsupported qemuValidateDomainDeviceDefDiskFrontend: Aggregate disk iomode validation src/qemu/qemu_validate.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) -- 2.31.1

The error is a hard error, so the part about fallback doesn't make sense. Spell the attribute the same way as it's in XML. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 1de6e05101..4ec3d18c52 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2865,9 +2865,7 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, 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")); + _("io='native' needs either no disk cache or directsync cache mode")); return -1; } -- 2.31.1

On a Tuesday in 2021, Peter Krempa wrote:
The error is a hard error, so the part about fallback doesn't make sense. Spell the attribute the same way as it's in XML.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Move the two checks under a common block and fix error messages. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 4ec3d18c52..29b01495ad 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2861,12 +2861,28 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, } } - 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", - _("io='native' needs either no disk cache or directsync cache mode")); - return -1; + switch (disk->iomode) { + case VIR_DOMAIN_DISK_IO_NATIVE: + if (disk->cachemode != VIR_DOMAIN_DISK_CACHE_DIRECTSYNC && + disk->cachemode != VIR_DOMAIN_DISK_CACHE_DISABLE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("io='native' needs either no disk cache or directsync cache mode")); + return -1; + } + break; + + case VIR_DOMAIN_DISK_IO_URING: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_AIO_IO_URING)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("io uring is not supported by this QEMU binary")); + return -1; + } + break; + + case VIR_DOMAIN_DISK_IO_THREADS: + case VIR_DOMAIN_DISK_IO_DEFAULT: + case VIR_DOMAIN_DISK_IO_LAST: + break; } if (disk->serial && @@ -2892,14 +2908,6 @@ qemuValidateDomainDeviceDefDiskFrontend(const virDomainDiskDef *disk, return -1; } - if (disk->iomode == VIR_DOMAIN_DISK_IO_URING) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_AIO_IO_URING)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("io uring is not supported by this QEMU binary")); - return -1; - } - } - if (disk->serial && qemuValidateDomainDeviceDefDiskSerial(disk->serial) < 0) return -1; -- 2.31.1

On a Tuesday in 2021, Peter Krempa wrote:
Move the two checks under a common block and fix error messages.
d/ and fix error messages/ The error messages are untouched by this patch.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_validate.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa