diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2d05b4a93bbe7439c45e17d0f03d7e1ad777a4d7..bbc85e75f06dc54e6c4de97f7c8f2362bcd31863 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5871,14 +5871,6 @@ qemuBuildRNGDevStr(const virDomainDef *def, { virBuffer buf = VIR_BUFFER_INITIALIZER; - if (dev->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("this qemu doesn't support RNG device type '%s'"), - virDomainRNGModelTypeToString(dev->model)); - goto error; - } - if (!qemuDomainCheckCCWS390AddressSupport(def, dev->info, qemuCaps, dev->source.file)) goto error; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a0ab55d5dbecb9c93730f3338af6a724f067957c..f42903a34304e9c34db72d2d673c5679e34c5e57 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4536,12 +4536,31 @@ qemuDomainSmartcardDefValidate(const virDomainSmartcardDef *def) static int -qemuDomainRNGDefValidate(const virDomainRNGDef *def) +qemuDomainRNGDefValidate(const virDomainRNGDef *def, + virQEMUCapsPtr qemuCaps) { + bool modelIsSupported = false; + if (def->backend == VIR_DOMAIN_RNG_BACKEND_EGD && qemuDomainChrSourceDefValidate(def->source.chardev) < 0) return -1; + switch ((virDomainRNGModel) def->model) { + case VIR_DOMAIN_RNG_MODEL_VIRTIO: + modelIsSupported = virQEMUCapsGet(qemuCaps, + QEMU_CAPS_DEVICE_VIRTIO_RNG); + break; + case VIR_DOMAIN_RNG_MODEL_LAST: + break; + } + + if (!modelIsSupported) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("this qemu doesn't support RNG device type '%s'"), + virDomainRNGModelTypeToString(def->model)); + return -1; + } + return 0; } @@ -6073,7 +6092,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, break; case VIR_DOMAIN_DEVICE_RNG: - ret = qemuDomainRNGDefValidate(dev->data.rng); + ret = qemuDomainRNGDefValidate(dev->data.rng, qemuCaps); break; case VIR_DOMAIN_DEVICE_REDIRDEV: diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 1802c36b86418a37c8599c7c1caccf8351b42c40..d50744a952e6a1f4deb6c8546f2473f7562c1450 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -364,8 +364,8 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, def->memballoon->info.type = type; for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model == VIR_DOMAIN_RNG_MODEL_VIRTIO && - def->rngs[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) + /* All devices accepted by the qemu driver are virtio */ + if (def->rngs[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def->rngs[i]->info.type = type; } @@ -2276,10 +2276,9 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, goto error; } - /* VirtIO RNG */ + /* the qemu driver only accepts virtio rng devices */ for (i = 0; i < def->nrngs; i++) { - if (def->rngs[i]->model != VIR_DOMAIN_RNG_MODEL_VIRTIO || - !virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) + if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info)) continue; if (qemuDomainPCIAddressReserveNextAddr(addrs, &def->rngs[i]->info) < 0) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 82e2c0ee0fc2ce468627e54017c4601fcfdc059f..b2c0c8505d4869812cd5dc0b48d478198bc349f6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -585,8 +585,10 @@ mymain(void) DO_TEST("disk-serial", NONE); - DO_TEST("virtio-rng-random", NONE); - DO_TEST("virtio-rng-egd", NONE); + DO_TEST("virtio-rng-random", + QEMU_CAPS_DEVICE_VIRTIO_RNG); + DO_TEST("virtio-rng-egd", + QEMU_CAPS_DEVICE_VIRTIO_RNG); DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE); @@ -1019,7 +1021,8 @@ mymain(void) DO_TEST("disk-backing-chains-index", NONE); DO_TEST("disk-backing-chains-noindex", NONE); - DO_TEST("chardev-label", NONE); + DO_TEST("chardev-label", + QEMU_CAPS_DEVICE_VIRTIO_RNG); DO_TEST("cpu-numa1", NONE); DO_TEST("cpu-numa2", NONE);