Move QEMU caps validation of QEMU_CAPS_CHARDEV_FILE_APPEND and QEMU_CAPS_CHARDEV_LOGFILE to qemuDomainChrSourceDefValidate(). Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/qemu/qemu_command.c | 11 ----------- src/qemu/qemu_domain.c | 44 ++++++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0fa7f4693e..58409a85d9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5098,12 +5098,6 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, case VIR_DOMAIN_CHR_TYPE_FILE: virBufferAsprintf(&buf, "file,id=%s", charAlias); - if (dev->data.file.append != VIR_TRISTATE_SWITCH_ABSENT && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("append not supported in this QEMU binary")); - return NULL; - } if (qemuBuildChrChardevFileStr(flags & QEMU_BUILD_CHARDEV_FILE_LOGD ? logManager : NULL, cmd, def, &buf, @@ -5239,11 +5233,6 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, } if (dev->logfile) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_LOGFILE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("logfile not supported in this QEMU binary")); - return NULL; - } if (qemuBuildChrChardevFileStr(logManager, cmd, def, &buf, "logfile", dev->logfile, "logappend", dev->logappend) < 0) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index fe24e736e8..2b97b5f1bd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5525,7 +5525,8 @@ qemuDomainChrSourceReconnectDefValidate(const virDomainChrSourceReconnectDef *de static int -qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def) +qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def, + virQEMUCapsPtr qemuCaps) { switch ((virDomainChrType)def->type) { case VIR_DOMAIN_CHR_TYPE_TCP: @@ -5538,11 +5539,19 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def) return -1; break; + case VIR_DOMAIN_CHR_TYPE_FILE: + if (def->data.file.append != VIR_TRISTATE_SWITCH_ABSENT && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("append not supported in this QEMU binary")); + return -1; + } + break; + case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_VC: case VIR_DOMAIN_CHR_TYPE_PTY: case VIR_DOMAIN_CHR_TYPE_DEV: - case VIR_DOMAIN_CHR_TYPE_FILE: case VIR_DOMAIN_CHR_TYPE_PIPE: case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_UDP: @@ -5553,6 +5562,14 @@ qemuDomainChrSourceDefValidate(const virDomainChrSourceDef *def) break; } + if (def->logfile) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_LOGFILE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("logfile not supported in this QEMU binary")); + return -1; + } + } + return 0; } @@ -5692,9 +5709,10 @@ qemuDomainChrTargetDefValidate(const virDomainChrDef *chr) static int qemuDomainChrDefValidate(const virDomainChrDef *dev, - const virDomainDef *def) + const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { - if (qemuDomainChrSourceDefValidate(dev->source) < 0) + if (qemuDomainChrSourceDefValidate(dev->source, qemuCaps) < 0) return -1; if (qemuDomainChrTargetDefValidate(dev) < 0) @@ -5750,10 +5768,11 @@ qemuDomainChrDefValidate(const virDomainChrDef *dev, static int -qemuDomainSmartcardDefValidate(const virDomainSmartcardDef *def) +qemuDomainSmartcardDefValidate(const virDomainSmartcardDef *def, + virQEMUCapsPtr qemuCaps) { if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH && - qemuDomainChrSourceDefValidate(def->data.passthru) < 0) + qemuDomainChrSourceDefValidate(def->data.passthru, qemuCaps) < 0) return -1; return 0; @@ -5765,7 +5784,7 @@ qemuDomainRNGDefValidate(const virDomainRNGDef *def, virQEMUCapsPtr qemuCaps G_GNUC_UNUSED) { if (def->backend == VIR_DOMAIN_RNG_BACKEND_EGD && - qemuDomainChrSourceDefValidate(def->source.chardev) < 0) + qemuDomainChrSourceDefValidate(def->source.chardev, qemuCaps) < 0) return -1; return 0; @@ -5773,9 +5792,10 @@ qemuDomainRNGDefValidate(const virDomainRNGDef *def, static int -qemuDomainRedirdevDefValidate(const virDomainRedirdevDef *def) +qemuDomainRedirdevDefValidate(const virDomainRedirdevDef *def, + virQEMUCapsPtr qemuCaps) { - if (qemuDomainChrSourceDefValidate(def->source) < 0) + if (qemuDomainChrSourceDefValidate(def->source, qemuCaps) < 0) return -1; return 0; @@ -7695,11 +7715,11 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, break; case VIR_DOMAIN_DEVICE_CHR: - ret = qemuDomainChrDefValidate(dev->data.chr, def); + ret = qemuDomainChrDefValidate(dev->data.chr, def, qemuCaps); break; case VIR_DOMAIN_DEVICE_SMARTCARD: - ret = qemuDomainSmartcardDefValidate(dev->data.smartcard); + ret = qemuDomainSmartcardDefValidate(dev->data.smartcard, qemuCaps); break; case VIR_DOMAIN_DEVICE_RNG: @@ -7707,7 +7727,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, break; case VIR_DOMAIN_DEVICE_REDIRDEV: - ret = qemuDomainRedirdevDefValidate(dev->data.redirdev); + ret = qemuDomainRedirdevDefValidate(dev->data.redirdev, qemuCaps); break; case VIR_DOMAIN_DEVICE_WATCHDOG: -- 2.23.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list