On Mon, Sep 14, 2026 at 16:29:02 +0800, Zhenzhong Duan wrote:
> Add svm attribute to iommu to enable/disable shared virtual memory
> capability for intel-iommu.
>
> Signed-off-by: Zhenzhong Duan <[email protected]>
> ---
> docs/formatdomain.rst | 6 +++
> src/conf/domain_conf.c | 16 ++++++++
> src/conf/domain_conf.h | 1 +
> src/conf/domain_validate.c | 26 +++++++++++++
> src/conf/schemas/domaincommon.rng | 5 +++
> src/qemu/qemu_command.c | 1 +
> src/qemu/qemu_validate.c | 6 +++
> .../intel-iommu-svm.x86_64-latest.args | 34 +++++++++++++++++
> .../intel-iommu-svm.x86_64-latest.xml | 37 +++++++++++++++++++
> tests/qemuxmlconfdata/intel-iommu-svm.xml | 37 +++++++++++++++++++
> tests/qemuxmlconftest.c | 1 +
> 11 files changed, 170 insertions(+)
> create mode 100644 tests/qemuxmlconfdata/intel-iommu-svm.x86_64-latest.args
> create mode 100644 tests/qemuxmlconfdata/intel-iommu-svm.x86_64-latest.xml
> create mode 100644 tests/qemuxmlconfdata/intel-iommu-svm.xml
>
> diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
> index 76ce8f88c3..69efa2e23b 100644
> --- a/docs/formatdomain.rst
> +++ b/docs/formatdomain.rst
> @@ -9495,6 +9495,12 @@ Examples:
> Max supported value is 20 according to PCI spec, pasid is disabled if
> 0.
> :since:`Since 12.8.0` (QEMU/KVM and ``intel`` model only)
>
> + ``svm``
> + Enable shared virtual memory. It exposes the necessary hardware
> + capabilities to the guest operating system so that devices can share
> + the exact same virtual address space as user-space applications.
> + :since:`Since 12.8.0` (QEMU/KVM and ``intel`` model only)
12.10.0; (updated in patch soon-to-be-pushed)
> +
> In case of ``virtio`` IOMMU device, the ``driver`` element can optionally
> contain ``granule`` subelement that allows to choose which granule will be
> used by default. It is useful when running guests with different page size
> +
> + if (iommu->svm == VIR_TRISTATE_SWITCH_ON) {
> + if (iommu->iotlb != VIR_TRISTATE_SWITCH_ON) {
> + virReportError(VIR_ERR_XML_ERROR,
> + _("iommu model '%1$s' 'svm' requires 'iotlb'
> to be 'on'"),
> +
> virDomainIOMMUModelTypeToString(iommu->model));
> + return -1;
> + }
> +
> + if (iommu->fsts != VIR_TRISTATE_SWITCH_ON) {
> + virReportError(VIR_ERR_XML_ERROR,
> + _("iommu model '%1$s' 'svm' requires 'fsts'
> to be 'on'"),
> +
> virDomainIOMMUModelTypeToString(iommu->model));
> + return -1;
> + }
> +
> + if (iommu->pasid_bits == 0) {
> + virReportError(VIR_ERR_XML_ERROR,
> + _("iommu model '%1$s' 'svm' requires
> 'pasid_bits' to be configured (> 0)"),
> +
> virDomainIOMMUModelTypeToString(iommu->model));
Conditions missing from docs
Reviewed-by: Peter Krempa <[email protected]>