In my recent commit of 5216304bfe I've moved RNG model check
from domain capabilities validator into qemu validator. During
that I had to basically duplicate RNG model to qemuCaps checks.
Problem with this approach is that after my commit qemu validator
and domCaps are disconnected and thus domCaps might report (in
general) different set of supported RNG models.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 2 +-
src/qemu/qemu_capabilities.h | 2 ++
src/qemu/qemu_validate.c | 30 ++++++++----------------------
3 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 78d3b965c6..58ab1beba6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -6068,7 +6068,7 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
}
-static void
+void
virQEMUCapsFillDomainDeviceRNGCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsDeviceRNGPtr rng)
{
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 22b3da3e63..0b28c9b635 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -742,6 +742,8 @@ int virQEMUCapsFillDomainCaps(virQEMUCapsPtr qemuCaps,
void virQEMUCapsFillDomainDeviceVideoCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsDeviceVideoPtr dev);
+void virQEMUCapsFillDomainDeviceRNGCaps(virQEMUCapsPtr qemuCaps,
+ virDomainCapsDeviceRNGPtr rng);
bool virQEMUCapsGuestIsNative(virArch host,
virArch guest);
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 6e1db2715d..7e2fe81e08 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1845,6 +1845,8 @@ static int
qemuValidateDomainRNGDef(const virDomainRNGDef *def,
virQEMUCapsPtr qemuCaps)
{
+ virDomainCapsDeviceRNG rngCaps = { 0 };
+
switch ((virDomainRNGBackend) def->backend) {
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_RANDOM)) {
@@ -1883,29 +1885,13 @@ qemuValidateDomainRNGDef(const virDomainRNGDef *def,
return -1;
}
- switch ((virDomainRNGModel) def->model) {
- case VIR_DOMAIN_RNG_MODEL_VIRTIO:
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("domain configuration does not support rng model
'%s'"),
- virDomainRNGModelTypeToString(def->model));
- return -1;
- }
- break;
+ virQEMUCapsFillDomainDeviceRNGCaps(qemuCaps, &rngCaps);
- case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL:
- case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL:
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("domain configuration does not support rng model
'%s'"),
- virDomainRNGModelTypeToString(def->model));
- return -1;
- }
- break;
-
- case VIR_DOMAIN_RNG_MODEL_LAST:
- break;
+ if (!VIR_DOMAIN_CAPS_ENUM_IS_SET(rngCaps.model, def->model)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("domain configuration does not support rng model
'%s'"),
+ virDomainRNGModelTypeToString(def->model));
+ return -1;
}
if (qemuValidateDomainVirtioOptions(def->virtio, qemuCaps) < 0)
--
2.26.2