``model``
Supported values are ``intel`` (for Q35 guests) ``smmuv3``
- (:since:`since 5.5.0`, for ARM virt guests), and ``virtio``
- (:since:`since 8.3.0`, for Q35 and ARM virt guests).
+ (:since:`since 5.5.0`, for ARM virt guests), ``virtio``
+ (:since:`since 8.3.0`, for Q35 and ARM virt guests) and
+ ``amd`` (:since:`since 11.5.0`).
``driver``
The ``driver`` subelement can be used to configure additional options, some
"intel",
"smmuv3",
"virtio",
+ "amd",
);
VIR_ENUM_IMPL(virDomainVsockModel,
VIR_DOMAIN_IOMMU_MODEL_INTEL,
VIR_DOMAIN_IOMMU_MODEL_SMMUV3,
VIR_DOMAIN_IOMMU_MODEL_VIRTIO,
+ VIR_DOMAIN_IOMMU_MODEL_AMD,
VIR_DOMAIN_IOMMU_MODEL_LAST
} virDomainIOMMUModel;
}
break;
+ case VIR_DOMAIN_IOMMU_MODEL_AMD:
+ if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT ||
+ iommu->eim != VIR_TRISTATE_SWITCH_ABSENT ||
+ iommu->aw_bits != 0 ||
+ iommu->dma_translation != VIR_TRISTATE_SWITCH_ABSENT) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("iommu model '%1$s' doesn't support some additional attributes"),
+ virDomainIOMMUModelTypeToString(iommu->model));
+ return -1;
+ }
+ break;
+
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
case VIR_DOMAIN_IOMMU_MODEL_LAST:
break;
break;
case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
+ case VIR_DOMAIN_IOMMU_MODEL_AMD:
case VIR_DOMAIN_IOMMU_MODEL_LAST:
break;
}
<value>intel</value>
<value>smmuv3</value>
<value>virtio</value>
+ <value>amd</value>
</choice>
</attribute>
<interleave>
virQEMUCaps *qemuCaps)
{
g_autoptr(virJSONValue) props = NULL;
+ g_autoptr(virJSONValue) wrapperProps = NULL;
const virDomainIOMMUDef *iommu = def->iommu;
if (!iommu)
/* There is no -device for SMMUv3, so nothing to be done here */
return 0;
+ case VIR_DOMAIN_IOMMU_MODEL_AMD:
+ if (virJSONValueObjectAdd(&wrapperProps,
+ "s:driver", "AMDVI-PCI",
+ "s:id", iommu->info.alias,
+ NULL) < 0)
+ return -1;
+
+ if (qemuBuildDeviceAddressProps(wrapperProps, def, &iommu->info) < 0)
+ return -1;
+
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, wrapperProps, def, qemuCaps) < 0)
+ return -1;
+
+ if (virJSONValueObjectAdd(&props,
+ "s:driver", "amd-iommu",
+ "s:pci-id", iommu->info.alias,
+ "S:intremap", qemuOnOffAuto(iommu->intremap),
+ "T:device-iotlb", iommu->iotlb,
+ NULL) < 0)
+ return -1;
+
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
+ return -1;
+
+ return 0;
+
case VIR_DOMAIN_IOMMU_MODEL_LAST:
default:
virReportEnumRangeError(virDomainIOMMUModel, iommu->model);
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
+ case VIR_DOMAIN_IOMMU_MODEL_AMD:
/* These IOMMUs are formatted in qemuBuildIOMMUCommandLine */
break;
case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
return virtioFlags | VIR_PCI_CONNECT_INTEGRATED;
+ case VIR_DOMAIN_IOMMU_MODEL_AMD:
+ return pciFlags | VIR_PCI_CONNECT_INTEGRATED;
+
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
case VIR_DOMAIN_IOMMU_MODEL_LAST:
switch (iommu->model) {
case VIR_DOMAIN_IOMMU_MODEL_VIRTIO:
+ case VIR_DOMAIN_IOMMU_MODEL_AMD:
if (virDeviceInfoPCIAddressIsWanted(&iommu->info) &&
qemuDomainPCIAddressReserveNextAddr(addrs, &iommu->info) < 0) {
return -1;
}
break;
+ case VIR_DOMAIN_IOMMU_MODEL_AMD:
+ if (!qemuDomainIsQ35(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("IOMMU device: '%1$s' is only supported with Q35 machines"),
+ virDomainIOMMUModelTypeToString(iommu->model));
+ return -1;
+ }
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_AMD_IOMMU_PCI_ID)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("IOMMU device: '%1$s' is not supported with this QEMU binary"),
+ virDomainIOMMUModelTypeToString(iommu->model));
+ return -1;
+ }
+ if (iommu->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ iommu->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("IOMMU device: '%1$s' needs a PCI address"),
+ virDomainIOMMUModelTypeToString(iommu->model));
+ return -1;
+ }
+ break;
+
case VIR_DOMAIN_IOMMU_MODEL_LAST:
default:
virReportEnumRangeError(virDomainIOMMUModel, iommu->model);
--- /dev/null
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
+-machine q35,usb=off,kernel_irqchip=split,dump-guest-core=off,memory-backend=pc.ram,acpi=on \
+-accel kvm \
+-cpu qemu64 \
+-m size=219136k \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-device '{"driver":"AMDVI-PCI","id":"iommu0","bus":"pcie.0","addr":"0x1"}' \
+-device '{"driver":"amd-iommu","pci-id":"iommu0","intremap":"on","device-iotlb":true}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-global ICH9-LPC.noreboot=off \
+-watchdog-action reset \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
--- /dev/null
+amd-iommu.xml
\ No newline at end of file
--- /dev/null
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ <ioapic driver='qemu'/>
+ </features>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='none'/>
+ <watchdog model='itco' action='reset'/>
+ <memballoon model='none'/>
+ <iommu model='amd'>
+ <driver intremap='on' iotlb='on'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+ </iommu>
+ </devices>
+</domain>
DO_TEST_CAPS_LATEST("acpi-table");
DO_TEST_CAPS_LATEST("acpi-table-many");
+ DO_TEST_CAPS_LATEST("amd-iommu");
+
DO_TEST_CAPS_LATEST("intel-iommu");
DO_TEST_CAPS_LATEST("intel-iommu-caching-mode");
DO_TEST_CAPS_LATEST("intel-iommu-eim");