diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 80aaf4b033..9bf59936e5 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -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:`` Virtio transitional devices diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 6f33d1e774..26990c4d6d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -6825,6 +6825,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 818c177e72..6fcf86ba58 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e9a9298d86..1ac802feca 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2740,6 +2740,7 @@ struct _virDomainVirtioOptions { virTristateSwitch iommu; virTristateSwitch ats; virTristateSwitch packed; + virTristateSwitch page_per_vq; }; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index f023d22f23..80401cf8c7 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -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; }