[PATCH 6/6] qemu: Support rng model=virtio-{non-}transitional

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add new <rng> model values for virtio transitional devices

* "virtio-transitional" maps to qemu "virtio-rng-pci-transitional"
* "virtio-non-transitional" maps to qemu "virtio-rng-pci-non-transitional"

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 docs/formatdomain.html.in                            |  2 ++
 docs/schemas/domaincommon.rng                        |  6 +++++-
 src/conf/domain_conf.c                               |  4 +++-
 src/conf/domain_conf.h                               |  2 ++
 src/qemu/qemu_capabilities.c                         |  6 ++++++
 src/qemu/qemu_capabilities.h                         |  4 ++++
 src/qemu/qemu_command.c                              | 12 +++++++++---
 src/qemu/qemu_domain_address.c                       |  6 ++++--
 tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml     |  2 ++
 .../virtio-non-transitional.x86_64-latest.args       |  2 ++
 tests/qemuxml2argvdata/virtio-non-transitional.xml   |  3 +++
 .../virtio-transitional.x86_64-latest.args           |  3 +++
 tests/qemuxml2argvdata/virtio-transitional.xml       |  3 +++
 tests/qemuxml2xmloutdata/virtio-non-transitional.xml |  4 ++++
 tests/qemuxml2xmloutdata/virtio-transitional.xml     |  9 +++++++++
 15 files changed, 61 insertions(+), 7 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5220e19417..5765f31048 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7966,6 +7966,8 @@ qemu-kvm -net nic,model=? /dev/null
         </p>
         <ul>
           <li>'virtio' - supported by qemu and virtio-rng kernel module</li>
+          <li>'virtio-transitional' <span class='since'>Since 5.1.0</span></li>
+          <li>'virtio-non-transitional' <span class='since'>Since 5.1.0</span></li>
         </ul>
       </dd>
       <dt><code>rate</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 425d7f851a..d247170aeb 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5442,7 +5442,11 @@
   <define name="rng">
     <element name="rng">
       <attribute name="model">
-        <value>virtio</value>
+        <choice>
+          <value>virtio</value>
+          <value>virtio-transitional</value>
+          <value>virtio-non-transitional</value>
+        </choice>
       </attribute>
       <interleave>
         <ref name="rng-backend"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f847fb0487..ec3cb226c1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -851,7 +851,9 @@ 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 0c1879da0f..0b8b49ec30 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2112,6 +2112,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_capabilities.c b/src/qemu/qemu_capabilities.c
index 24031579cd..84e8bc7863 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -522,6 +522,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "nvdimm.unarmed",
               "virtio-blk-pci-transitional",
               "virtio-blk-pci-non-transitional",
+              "virtio-rng-pci-transitional",
+
+              /* 330 */
+              "virtio-rng-pci-non-transitional",
     );
 
 
@@ -1112,6 +1116,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "memory-backend-memfd", QEMU_CAPS_OBJECT_MEMORY_MEMFD },
     {"virtio-blk-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL},
     {"virtio-blk-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL},
+    {"virtio-rng-pci-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL},
+    {"virtio-rng-pci-non-transitional", QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL},
 };
 
 static struct virQEMUCapsStringFlags virQEMUCapsDevicePropsVirtioBalloon[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 34265d7cc0..86be890beb 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -506,6 +506,10 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
     QEMU_CAPS_DEVICE_NVDIMM_UNARMED, /* -device nvdimm,unarmed= */
     QEMU_CAPS_DEVICE_VIRTIO_BLK_TRANSITIONAL, /* -device virtio-blk-pci-transitional */
     QEMU_CAPS_DEVICE_VIRTIO_BLK_NON_TRANSITIONAL, /* -device virtio-blk-pci-non-transitional */
+    QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL, /* -device virtio-blk-rng-transitional */
+
+    /* 330 */
+    QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL, /* -device virtio-rng-pci-non-transitional */
 
     QEMU_CAPS_LAST /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ca6abea227..3f6f63f33d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5916,8 +5916,12 @@ qemuBuildRNGDevStr(const virDomainDef *def,
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
-    if (dev->model != VIR_DOMAIN_RNG_MODEL_VIRTIO ||
-        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) {
+    if (!((dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO &&
+           virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) ||
+          (dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL &&
+           virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG_TRANSITIONAL)) ||
+          (dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL &&
+           virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG_NON_TRANSITIONAL)))) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("this qemu doesn't support RNG device type '%s'"),
                        virDomainRNGModelTypeToString(dev->model));
@@ -5928,7 +5932,9 @@ qemuBuildRNGDevStr(const virDomainDef *def,
                                               dev->source.file))
         goto error;
 
-    if (qemuBuildVirtioDevStr(&buf, "virtio-rng", dev->info.type) < 0)
+    if (qemuBuildVirtioTransitional(&buf, "virtio-rng", dev->info.type,
+                                    dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
+                                    dev->model == VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL) < 0)
         goto error;
 
     virBufferAsprintf(&buf, ",rng=obj%s,id=%s",
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 1a77b74ad1..cbf7a0556b 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -856,7 +856,10 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDefPtr dev,
     case VIR_DOMAIN_DEVICE_RNG:
         switch ((virDomainRNGModel) dev->data.rng->model) {
         case VIR_DOMAIN_RNG_MODEL_VIRTIO:
+        case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL:
             return virtioFlags;
+        case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL:
+            return pciFlags;
 
         case VIR_DOMAIN_RNG_MODEL_LAST:
             return 0;
@@ -2285,8 +2288,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
 
     /* VirtIO RNG */
     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/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
index 8cf9083035..35cb40c24c 100644
--- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml
@@ -214,6 +214,8 @@
   <flag name='nvdimm.unarmed'/>
   <flag name='virtio-blk-pci-transitional'/>
   <flag name='virtio-blk-pci-non-transitional'/>
+  <flag name='virtio-rng-pci-transitional'/>
+  <flag name='virtio-rng-pci-non-transitional'/>
   <version>3001050</version>
   <kvmVersion>0</kvmVersion>
   <microcodeVersion>446361</microcodeVersion>
diff --git a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
index a8f878c99c..805b564ee2 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.x86_64-latest.args
@@ -30,6 +30,8 @@ addr=0x1 \
 -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=0x1,\
 drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
+-object rng-random,id=objrng0,filename=/dev/urandom \
+-device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x2 \
 -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 2b9b82f473..1d131a6255 100644
--- a/tests/qemuxml2argvdata/virtio-non-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-non-transitional.xml
@@ -19,6 +19,9 @@
       <target dev='vda' bus='virtio'/>
     </disk>
     <controller type='usb' index='0' model='none'/>
+    <rng model='virtio-non-transitional'>
+      <backend model='random'>/dev/urandom</backend>
+    </rng>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <memballoon model='none'/>
diff --git a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
index 7730b177e7..803b4042ca 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/virtio-transitional.x86_64-latest.args
@@ -26,9 +26,12 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
 -device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
 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 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-virtio-disk0 \
 -device virtio-blk-pci-transitional,scsi=off,bus=pci.1,addr=0x0,\
 drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
+-object rng-random,id=objrng0,filename=/dev/urandom \
+-device virtio-rng-pci-transitional,rng=objrng0,id=rng0,bus=pci.2,addr=0x0 \
 -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 c6b3fca760..aca4f9f8fa 100644
--- a/tests/qemuxml2argvdata/virtio-transitional.xml
+++ b/tests/qemuxml2argvdata/virtio-transitional.xml
@@ -19,6 +19,9 @@
       <target dev='vda' bus='virtio'/>
     </disk>
     <controller type='usb' index='0' model='none'/>
+    <rng model='virtio-transitional'>
+      <backend model='random'>/dev/urandom</backend>
+    </rng>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <memballoon model='none'/>
diff --git a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
index a64a84d145..47ed1a65a6 100644
--- a/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
+++ b/tests/qemuxml2xmloutdata/virtio-non-transitional.xml
@@ -42,5 +42,9 @@
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <memballoon model='none'/>
+    <rng model='virtio-non-transitional'>
+      <backend model='random'>/dev/urandom</backend>
+      <address type='pci' domain='0x0000' bus='0x02' slot='0x02' function='0x0'/>
+    </rng>
   </devices>
 </domain>
diff --git a/tests/qemuxml2xmloutdata/virtio-transitional.xml b/tests/qemuxml2xmloutdata/virtio-transitional.xml
index 87d8ff4a25..4f84f09ccc 100644
--- a/tests/qemuxml2xmloutdata/virtio-transitional.xml
+++ b/tests/qemuxml2xmloutdata/virtio-transitional.xml
@@ -35,8 +35,17 @@
       <target chassis='2' port='0x9'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
     </controller>
+    <controller type='pci' index='3' model='pcie-root-port'>
+      <model name='pcie-root-port'/>
+      <target chassis='3' port='0xa'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+    </controller>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <memballoon model='none'/>
+    <rng model='virtio-transitional'>
+      <backend model='random'>/dev/urandom</backend>
+      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
+    </rng>
   </devices>
 </domain>
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux