]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Add page_per_vq for driver element
authorHan Han <hhan@redhat.com>
Fri, 15 Oct 2021 06:09:29 +0000 (14:09 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Oct 2021 07:40:55 +0000 (09:40 +0200)
Signed-off-by: Han Han <hhan@redhat.com>
Signed-off-by: Gavi Teitz <gavi@nvidia.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.rst
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/domain_validate.c

index 80aaf4b0339c3e3619abbaacf167c100165090b6..9bf59936e580d643897c22899399518ba10f7f77 100644 (file)
@@ -3577,6 +3577,15 @@ virtqueues are actually used depends on the feature negotiation between QEMU,
 vhost backends and guest drivers. Possible values are ``on`` or ``off``.
 :since:`Since 6.3.0 (QEMU and KVM only)`
 
+This optional attribute ``page_per_vq`` controls the layout of the notification
+capabilities exposed to the guest. When enabled, each virtio queue will have a
+dedicated page on the device BAR exposed to the guest. It is recommended to be
+used when vDPA is enabled on the hypervisor, as it enables mapping the
+notification area to the physical device, which is only supported in page
+granularity. The default is determined by QEMU. :since:`Since 7.8.0 (QEMU 2.8)`
+Note: In general you should leave this option alone, unless you are very certain
+you know what you are doing.
+
 :anchor:`<a id="elementsVirtioTransitional"/>`
 
 Virtio transitional devices
index 6f33d1e774aadd3df67a4b5fb52ce322bb723065..26990c4d6d69e9b1e1860f20cc796cbbb36231e4 100644 (file)
         <ref name="virOnOff"/>
       </attribute>
     </optional>
+    <optional>
+      <attribute name="page_per_vq">
+        <ref name="virOnOff"/>
+      </attribute>
+    </optional>
   </define>
 
   <define name="usbmaster">
index 818c177e725b0ff541d12d3a703e65cd6ac814bb..6fcf86ba5872405e504785a60492c5fcabaeaf17 100644 (file)
@@ -1636,6 +1636,10 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver,
                                  &(*virtio)->packed) < 0)
         return -1;
 
+    if (virXMLPropTristateSwitch(driver, "page_per_vq", VIR_XML_PROP_NONE,
+                                 &(*virtio)->page_per_vq) < 0)
+        return -1;
+
     return 0;
 }
 
@@ -6321,6 +6325,10 @@ virDomainVirtioOptionsFormat(virBuffer *buf,
         virBufferAsprintf(buf, " packed='%s'",
                           virTristateSwitchTypeToString(virtio->packed));
     }
+    if (virtio->page_per_vq != VIR_TRISTATE_SWITCH_ABSENT) {
+        virBufferAsprintf(buf, " page_per_vq='%s'",
+                          virTristateSwitchTypeToString(virtio->page_per_vq));
+    }
 }
 
 
@@ -20816,6 +20824,14 @@ virDomainVirtioOptionsCheckABIStability(virDomainVirtioOptions *src,
                        virTristateSwitchTypeToString(src->packed));
         return false;
     }
+    if (src->page_per_vq != dst->page_per_vq) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Target device page_per_vq option '%s' does not "
+                         "match source '%s'"),
+                       virTristateSwitchTypeToString(dst->page_per_vq),
+                       virTristateSwitchTypeToString(src->page_per_vq));
+        return false;
+    }
     return true;
 }
 
index e9a9298d861c6a15e96c2e57d663cf46d89e0d22..1ac802feca592eac9725b9fb4442272ee389d3e5 100644 (file)
@@ -2740,6 +2740,7 @@ struct _virDomainVirtioOptions {
     virTristateSwitch iommu;
     virTristateSwitch ats;
     virTristateSwitch packed;
+    virTristateSwitch page_per_vq;
 };
 
 
index f023d22f2364a9d4b47bc9672a8b070bf421678e..80401cf8c737692f16ede020fd920789a1813008 100644 (file)
@@ -135,6 +135,12 @@ virDomainCheckVirtioOptionsAreAbsent(virDomainVirtioOptions *virtio)
                          "for virtio devices"));
         return -1;
     }
+
+    if (virtio->page_per_vq != VIR_TRISTATE_SWITCH_ABSENT) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("page_per_vq option is only supported for virtio devices"));
+        return -1;
+    }
     return 0;
 }