Signed-off-by: Han Han <hhan@redhat.com>
---
docs/formatdomain.rst | 9 +++++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 16 ++++++++++++++++
src/conf/domain_conf.h | 1 +
src/conf/domain_validate.c | 7 +++++++
5 files changed, 38 insertions(+)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 479a3acfbb..961676ac6b 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -3546,6 +3546,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`
+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
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 11fa24f398..fb97364e15 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -6789,6 +6789,11 @@
<ref name="virOnOff"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="page_per_vq">
+ <ref name="virOnOff"/>
+ </attribute>
+ </optional>
</define>
<define name="usbmaster">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6127513117..1abfe29dd9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1629,6 +1629,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;
}
@@ -6311,6 +6315,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));
+ }
}
@@ -20699,6 +20707,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 c7e6df7981..e21683a71f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2725,6 +2725,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 60f7ccdddd..f22f952464 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -134,6 +134,13 @@ 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;
}
--
2.31.1
On Mon, Sep 6, 2021 at 9:07 AM Han Han <hhan@redhat.com> wrote:
>
> Signed-off-by: Han Han <hhan@redhat.com>
> ---
> docs/formatdomain.rst | 9 +++++++++
> docs/schemas/domaincommon.rng | 5 +++++
> src/conf/domain_conf.c | 16 ++++++++++++++++
> src/conf/domain_conf.h | 1 +
> src/conf/domain_validate.c | 7 +++++++
> 5 files changed, 38 insertions(+)
>
> diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
> index 479a3acfbb..961676ac6b 100644
> --- a/docs/formatdomain.rst
> +++ b/docs/formatdomain.rst
> @@ -3546,6 +3546,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
Minor quibble: "This optional attribute" should be "The optional
attribute"
> +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`
> +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
> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 11fa24f398..fb97364e15 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -6789,6 +6789,11 @@
> <ref name="virOnOff"/>
> </attribute>
> </optional>
> + <optional>
> + <attribute name="page_per_vq">
> + <ref name="virOnOff"/>
> + </attribute>
> + </optional>
> </define>
>
> <define name="usbmaster">
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 6127513117..1abfe29dd9 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -1629,6 +1629,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;
> }
>
> @@ -6311,6 +6315,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));
> + }
> }
>
>
> @@ -20699,6 +20707,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 c7e6df7981..e21683a71f 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -2725,6 +2725,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 60f7ccdddd..f22f952464 100644
> --- a/src/conf/domain_validate.c
> +++ b/src/conf/domain_validate.c
> @@ -134,6 +134,13 @@ 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;
> }
>
> --
> 2.31.1
>
© 2016 - 2026 Red Hat, Inc.