From e063707556f53bc22e5c215acb71aba9f265bfa2 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Thu, 17 Jan 2019 12:52:35 -0500 Subject: [PATCH] qemu: Support rng model=virtio-{non-}transitional Add new model values for virtio transitional devices. Ex: ... * "virtio-transitional" maps to qemu "virtio-rng-pci-transitional" * "virtio-non-transitional" maps to qemu "virtio-rng-pci-non-transitional" Reviewed-by: Andrea Bolognani Signed-off-by: Cole Robinson --- docs/formatdomain.html.in | 4 ++++ docs/schemas/domaincommon.rng | 6 +++++- src/conf/domain_conf.c | 5 ++++- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_command.c | 6 +++++- src/qemu/qemu_domain.c | 6 ++++++ src/qemu/qemu_domain_address.c | 4 ++++ .../virtio-non-transitional.x86_64-3.1.0.args | 4 ++++ .../virtio-non-transitional.x86_64-latest.args | 3 +++ tests/qemuxml2argvdata/virtio-non-transitional.xml | 3 +++ .../virtio-transitional.x86_64-3.1.0.args | 3 +++ .../virtio-transitional.x86_64-latest.args | 2 ++ tests/qemuxml2argvdata/virtio-transitional.xml | 3 +++ tests/qemuxml2xmloutdata/virtio-non-transitional.xml | 9 +++++++++ tests/qemuxml2xmloutdata/virtio-transitional.xml | 4 ++++ tests/qemuxml2xmltest.c | 2 ++ 16 files changed, 63 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b8704d4d59..16ceae6e2b 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8027,7 +8027,11 @@ qemu-kvm -net nic,model=? /dev/null

  • 'virtio' - supported by qemu and virtio-rng kernel module
  • +
  • 'virtio-transitional' Since 5.2.0
  • +
  • 'virtio-non-transitional' Since 5.2.0
+ See Virtio transitional devices + for more details.
rate
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 0e406d81ea..b0ea8a0113 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -5469,7 +5469,11 @@ - virtio + + virtio + virtio-transitional + virtio-non-transitional + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0e5cc946e1..0b818fd8d5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -953,7 +953,10 @@ VIR_ENUM_IMPL(virDomainDiskTray, VIR_DOMAIN_DISK_TRAY_LAST, VIR_ENUM_IMPL(virDomainRNGModel, VIR_DOMAIN_RNG_MODEL_LAST, - "virtio"); + "virtio", + "virtio-transitional", + "virtio-non-transitional", +); VIR_ENUM_IMPL(virDomainRNGBackend, VIR_DOMAIN_RNG_BACKEND_LAST, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 552d3adb5b..37cc4c775c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2141,6 +2141,8 @@ struct _virBlkioDevice { typedef enum { VIR_DOMAIN_RNG_MODEL_VIRTIO, + VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL, VIR_DOMAIN_RNG_MODEL_LAST } virDomainRNGModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d4dd3b2871..b1708b7f06 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -492,6 +492,11 @@ qemuBuildVirtioDevStr(virBufferPtr buf, has_ntmodel = device.data.hostdev->source.subsys.u.scsi_host.model == VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_VHOST_MODEL_TYPE_VIRTIO_NON_TRANSITIONAL; break; + case VIR_DOMAIN_DEVICE_RNG: + has_tmodel = device.data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL; + has_ntmodel = device.data.rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL; + break; + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: case VIR_DOMAIN_DEVICE_INPUT: @@ -510,7 +515,6 @@ qemuBuildVirtioDevStr(virBufferPtr buf, case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_MEMORY: case VIR_DOMAIN_DEVICE_IOMMU: case VIR_DOMAIN_DEVICE_VSOCK: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 690a57521e..70aa0346e2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4540,6 +4540,12 @@ qemuDomainRNGDefValidate(const virDomainRNGDef *def, modelIsSupported = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG); break; + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: + modelIsSupported = (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG) && + (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY))); + break; case VIR_DOMAIN_RNG_MODEL_LAST: break; } diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 5dcc7b4d6b..e097356327 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -878,7 +878,11 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev, case VIR_DOMAIN_DEVICE_RNG: switch ((virDomainRNGModel) dev->data.rng->model) { + case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: + /* Transitional devices only work in conventional PCI slots */ + return pciFlags; case VIR_DOMAIN_RNG_MODEL_VIRTIO: + case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: return virtioFlags; case VIR_DOMAIN_RNG_MODEL_LAST: diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args index 500c03bdc3..10cc6236cb 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-3.1.0.args @@ -28,6 +28,7 @@ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci,disable-legacy=on,disable-modern=off,scsi=off,bus=pci.2,\ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -36,6 +37,9 @@ addr=0x0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ id=net0,mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ -device vhost-scsi-pci,disable-legacy=on,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.3,addr=0x0 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci,disable-legacy=on,disable-modern=off,rng=objrng0,\ +id=rng0,bus=pci.4,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args index c8dbffda65..a0fc475c2f 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args @@ -28,6 +28,7 @@ addr=0x1 \ -device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \ -device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \ -device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \ +-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \ -device virtio-blk-pci-non-transitional,scsi=off,bus=pci.2,addr=0x0,\ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ @@ -36,6 +37,8 @@ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ mac=00:11:22:33:44:55,bus=pci.1,addr=0x0 \ -device vhost-scsi-pci-non-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.3,addr=0x0 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.4,addr=0x0 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.xml b/tests/qemuxml2argvdata/virtio-non-transitional.xml index 14ff02ace6..74760e75bc 100644 --- a/tests/qemuxml2argvdata/virtio-non-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml @@ -18,6 +18,9 @@ + + /dev/urandom + diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args index d4d2b8ec35..b21a6cadd4 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-3.1.0.args @@ -35,6 +35,9 @@ bus=pci.2,addr=0x2,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ id=net0,mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ -device vhost-scsi-pci,disable-legacy=off,disable-modern=off,\ wwpn=naa.5123456789abcde0,vhostfd=3,id=hostdev0,bus=pci.2,addr=0x3 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci,disable-legacy=off,disable-modern=off,rng=objrng0,\ +id=rng0,bus=pci.2,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args index ab2c35514d..64fb4153fd 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args @@ -35,6 +35,8 @@ drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \ mac=00:11:22:33:44:55,bus=pci.2,addr=0x1 \ -device vhost-scsi-pci-transitional,wwpn=naa.5123456789abcde0,vhostfd=3,\ id=hostdev0,bus=pci.2,addr=0x3 \ +-object rng-random,id=objrng0,filename=/dev/urandom \ +-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x4 \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ resourcecontrol=deny \ -msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-transitional.xml b/tests/qemuxml2argvdata/virtio-transitional.xml index 3149803171..fa60016235 100644 --- a/tests/qemuxml2argvdata/virtio-transitional.xml +++ b/tests/qemuxml2argvdata/virtio-transitional.xml @@ -18,6 +18,9 @@ + + /dev/urandom + diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml index 2af5195dfd..4a315050ab 100644 --- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml @@ -45,6 +45,11 @@
+ + + +
+ @@ -57,5 +62,9 @@
+ + /dev/urandom +
+ diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml index 8c1baced0e..ae3789ad93 100644 --- a/tests/qemuxml2xmloutdata/virtio-transitional.xml +++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml @@ -51,5 +51,9 @@
+ + /dev/urandom +
+ diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 15f0ccffb1..b99f2d7583 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1258,11 +1258,13 @@ mymain(void) QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); DO_TEST("virtio-non-transitional", QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_PCIE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY); if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) -- GitLab