From 60f4c4137765b09a682df2a7d31ca9fa5a30b9d1 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Fri, 17 May 2019 13:23:16 +0200 Subject: [PATCH] conf: Parse and format SMMUv3 IOMMU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SMMUv3 is an IOMMU implementation for ARM virt guests. Signed-off-by: Andrea Bolognani Reviewed-by: Ján Tomko --- docs/formatdomain.html.in | 7 +++-- docs/schemas/domaincommon.rng | 5 ++- src/conf/domain_conf.c | 1 + src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 7 +++++ src/qemu/qemu_domain.c | 3 ++ .../iommu-smmuv3.aarch64-latest.args | 31 +++++++++++++++++++ tests/qemuxml2argvdata/iommu-smmuv3.xml | 15 +++++++++ tests/qemuxml2argvtest.c | 1 + .../iommu-smmuv3.aarch64-latest.xml | 25 +++++++++++++++ tests/qemuxml2xmltest.c | 1 + 11 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/iommu-smmuv3.aarch64-latest.args create mode 100644 tests/qemuxml2argvdata/iommu-smmuv3.xml create mode 100644 tests/qemuxml2xmloutdata/iommu-smmuv3.aarch64-latest.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c843b1d667..22ddcb71d3 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -8675,14 +8675,17 @@ qemu-kvm -net nic,model=? /dev/null
model

- Currently only the intel model is supported. + Supported values are intel (for Q35 guests) and, + since 5.5.0, smmuv3 (for + ARM virt guests).

driver

The driver subelement can be used to configure - additional options: + additional options, some of which might only be available for + certain IOMMU models:

intremap
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 111b85c36f..4bd75e3055 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4375,7 +4375,10 @@ - intel + + intel + smmuv3 + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 006920e954..97ba8bd53a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1122,6 +1122,7 @@ VIR_ENUM_IMPL(virDomainTPMVersion, VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST, "intel", + "smmuv3", ); VIR_ENUM_IMPL(virDomainVsockModel, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index fa0756b634..4c3ab07062 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2296,6 +2296,7 @@ struct _virDomainSEVDef { typedef enum { VIR_DOMAIN_IOMMU_MODEL_INTEL, + VIR_DOMAIN_IOMMU_MODEL_SMMUV3, VIR_DOMAIN_IOMMU_MODEL_LAST } virDomainIOMMUModel; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b2b9bef772..a11b6d40da 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6967,6 +6967,9 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd, break; } + case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: + break; + case VIR_DOMAIN_IOMMU_MODEL_LAST: default: virReportEnumRangeError(virDomainIOMMUModel, iommu->model); @@ -7612,6 +7615,10 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) virBufferAddLit(&buf, ",iommu=on"); break; + + case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: + break; + case VIR_DOMAIN_IOMMU_MODEL_LAST: default: virReportEnumRangeError(virDomainIOMMUModel, def->iommu->model); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 366ebe1604..9802952046 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6135,6 +6135,9 @@ qemuDomainDeviceDefValidateIOMMU(const virDomainIOMMUDef *iommu, } break; + case VIR_DOMAIN_IOMMU_MODEL_SMMUV3: + break; + case VIR_DOMAIN_IOMMU_MODEL_LAST: default: virReportEnumRangeError(virDomainIOMMUModel, iommu->model); diff --git a/tests/qemuxml2argvdata/iommu-smmuv3.aarch64-latest.args b/tests/qemuxml2argvdata/iommu-smmuv3.aarch64-latest.args new file mode 100644 index 0000000000..a96669078b --- /dev/null +++ b/tests/qemuxml2argvdata/iommu-smmuv3.aarch64-latest.args @@ -0,0 +1,31 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-guest \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-guest/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-guest/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-guest/.config \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-aarch64 \ +-name guest=guest,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-guest/master-key.aes \ +-machine virt,accel=tcg,usb=off,dump-guest-core=off,gic-version=2 \ +-m 1024 \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/iommu-smmuv3.xml b/tests/qemuxml2argvdata/iommu-smmuv3.xml new file mode 100644 index 0000000000..2683ce6459 --- /dev/null +++ b/tests/qemuxml2argvdata/iommu-smmuv3.xml @@ -0,0 +1,15 @@ + + guest + 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 + 1048576 + 1 + + hvm + + + /usr/bin/qemu-system-aarch64 + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ec58074798..49220733ae 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2813,6 +2813,7 @@ mymain(void) DO_TEST_CAPS_LATEST("intel-iommu-eim"); DO_TEST_CAPS_LATEST("intel-iommu-device-iotlb"); DO_TEST_PARSE_ERROR("intel-iommu-wrong-machine", NONE); + DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64"); DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS); DO_TEST_PARSE_ERROR("cpu-hotplug-granularity", diff --git a/tests/qemuxml2xmloutdata/iommu-smmuv3.aarch64-latest.xml b/tests/qemuxml2xmloutdata/iommu-smmuv3.aarch64-latest.xml new file mode 100644 index 0000000000..93e8566dea --- /dev/null +++ b/tests/qemuxml2xmloutdata/iommu-smmuv3.aarch64-latest.xml @@ -0,0 +1,25 @@ + + guest + 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 + 1048576 + 1048576 + 1 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-aarch64 + + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index d1e7fe1015..06d1ad5ec0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1207,6 +1207,7 @@ mymain(void) DO_TEST_CAPS_LATEST("intel-iommu-caching-mode"); DO_TEST_CAPS_LATEST("intel-iommu-eim"); DO_TEST_CAPS_LATEST("intel-iommu-device-iotlb"); + DO_TEST_CAPS_ARCH_LATEST("iommu-smmuv3", "aarch64"); DO_TEST("cpu-check-none", NONE); DO_TEST("cpu-check-partial", NONE);