Move the two checks under a common block and fix error messages. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- 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