[libvirt] [PATCH 0/2] Increase bound limit for virDomainGetBlockIoTune
by John Ferlan
Related to my onlist (and ACK'd) series for adding 6 new parameters
for adding length (duration) parameters to/for iotune throttling:
http://www.redhat.com/archives/libvir-list/2016-September/msg01090.html
As described in a response to the cover:
http://www.redhat.com/archives/libvir-list/2016-October/msg00053.html
for some reason I had a brain cramp and neglected to check the virsh
blkdeviotune command. These patches could then be applied before the
other (already ACK'd) series once the current release is out.
In reality they just need to go in some time before patch 8 which adds
the 6 new parameters to qemuMonitorGetBlockIoThrottle. A followup
patch to that series will enable setting the new parameters (IOW:
changes to virsh-domain.c cmdBlkdeviotune().
John Ferlan (2):
remote: Fix erroneous usage of constant
remote: Increase bound limit for virDomainGetBlockIoTune
src/remote/remote_driver.c | 4 ++--
src/remote/remote_protocol.x | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
--
2.7.4
8 years, 1 month
[libvirt] Missing blockJobInfo() method from v1.2.5 Python bindings?
by Kashyap Chamarthy
Last night I was trying to check whether blockJobInfo() method will
raise an error when it returns 'None' in v1.2.5 libvirt Python bindings.
(Eric Blake confirmed on IRC: "the python bindings have, as a general
rule, always raised a libvirtError if the C binding code returns None").
Before asking on IRC, I built the bindings and the below is what I noticed.
Let's first see what's in current Git master:
$ less build/libvirt.py
[...]
def blockJobInfo(self, path, flags=0):
"""Get progress information for a block job """
ret = libvirtmod.virDomainGetBlockJobInfo(self._o, path, flags)
if ret is None: raise libvirtError ('virDomainGetBlockJobInfo() failed', dom=self)
return ret
[...]
Now try to find out what is present in v1.2.5 by quickly building the
bindings for that tag:
$ git checkout v1.2.5
$ python setup.py build
Hmm, once built, there's no blockJobInfo() method in build/libvirt.py!
(When I mentioned this on #virt, OFTC, Cole confirmed he could reproduce
the behavior, too. Not sure if it's a regression in v1.2.5.)
However, the libvirt "glue code" for libvirt_virDomainGetBlockJobInfo()
exists in libvirt-python/libvirt-override.c, so checking there (again,
for v1.2.5), we see:
4755 if (c_ret == 0) {
4756 return dict;
4757 } else if (c_ret < 0) {
4758 Py_DECREF(dict);
4759 return VIR_PY_NONE;
4760 }
IIUC, the VIR_PY_NONE means it raises an exception (libvirtError).
--
/kashyap
8 years, 1 month
[libvirt] Some maintenance back-ports
by Martin Kletzander
I wanted to back-port commit 4372a7845acbc6974f6027ef68e7dd3eeb47f425 to
various maintenance branches due to the fact that it changes how
migration behaves and that would fix it for future uses at leas. I
found out some compilation problems (mainly because I switched to gcc
6.2.0). I wanted to make it easier for others (well, Cole) to make a
maintenance release, so I back-ported some other stuff to make various
maint branches compile. All of them were trivial build-fixers and there
were few per each branch and I think it's pretty pointless to send each
of them to the list (and I'm also lazy). But in case you're interested,
feel free to check and complain if you hate what I did, just so I know
for next time.
Have a nice day,
Martin
8 years, 1 month
[libvirt] [PATCH v3] qemu: fix command line building for iommu devices
by Daniel P. Berrange
The intel-iommu device has existed since QEMU 2.2.0, but
it was only possible to create it with -device since
QEMU 2.7.0, thanks to:
commit 621d983a1f9051f4cfc3f402569b46b77d8449fc
Author: Marcel Apfelbaum <marcel(a)redhat.com>
Date: Mon Jun 27 18:38:34 2016 +0300
hw/iommu: enable iommu with -device
Use the standard '-device intel-iommu' to create the IOMMU device.
The legacy '-machine,iommu=on' can still be used.
The libvirt capability check & command line formatting code
is thus broken for all QEMU versions 2.2.0 -> 2.6.0 inclusive.
This fixes it to use iommu=on instead.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 12 +++++++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 22 +++++++++++++
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 2 +-
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 2 +-
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 2 +-
.../qemuxml2argv-intel-iommu-machine.args | 21 ++++++++++++
.../qemuxml2argv-intel-iommu-machine.xml | 37 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 2 ++
9 files changed, 98 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index cc8ec58..da8f3d1 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -344,6 +344,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"query-hotpluggable-cpus",
"virtio-net.rx_queue_size", /* 235 */
+ "machine-iommu",
);
@@ -3804,6 +3805,17 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (virQEMUCapsProbeQMPMigrationCapabilities(qemuCaps, mon) < 0)
goto cleanup;
+ /* 'intel-iommu' shows up as a device since 2.2.0, but can
+ * not be used with -device until 2.7.0. Before that it
+ * requires -machine iommu=on. So we must clear the device
+ * capability we detected on older QEMUs
+ */
+ if (qemuCaps->version < 2007000 &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU);
+ }
+
/* GIC capabilities, eg. available GIC versions */
if ((qemuCaps->arch == VIR_ARCH_AARCH64 ||
qemuCaps->arch == VIR_ARCH_ARMV7L) &&
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index ba0ef48..51c2372 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -378,6 +378,7 @@ typedef enum {
/* 235 */
QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, /* virtio-net-*.rx_queue_size */
+ QEMU_CAPS_MACHINE_IOMMU, /* -machine iommu=on */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 529bcb1..7e52963 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6455,6 +6455,9 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
if (!def->iommu)
return 0;
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
+ return 0; /* Already handled via -machine */
+
switch (def->iommu->model) {
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
@@ -7085,6 +7088,25 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
}
}
+ /* We don't report errors on missing cap here - -device code will do that */
+ if (def->iommu &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) {
+ switch (def->iommu->model) {
+ case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+ if (!qemuDomainMachineIsQ35(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("IOMMU device: '%s' is only supported with "
+ "Q35 machines"),
+ virDomainIOMMUModelTypeToString(def->iommu->model));
+ return -1;
+ }
+ virBufferAddLit(&buf, ",iommu=on");
+ break;
+ case VIR_DOMAIN_IOMMU_MODEL_LAST:
+ break;
+ }
+ }
+
virCommandAddArgBuffer(cmd, &buf);
}
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
index db778ef..abb9c66 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
@@ -182,9 +182,9 @@
<flag name='spice-unix'/>
<flag name='drive-detect-zeroes'/>
<flag name='display'/>
- <flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='machine-iommu'/>
<version>2004000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
index fc915ad..cbf2e1e 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
@@ -187,9 +187,9 @@
<flag name='drive-detect-zeroes'/>
<flag name='tls-creds-x509'/>
<flag name='display'/>
- <flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='machine-iommu'/>
<version>2005000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
index 60f1fcf..116c506 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
@@ -193,9 +193,9 @@
<flag name='drive-detect-zeroes'/>
<flag name='tls-creds-x509'/>
<flag name='display'/>
- <flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='machine-iommu'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
new file mode 100644
index 0000000..9221b79
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
@@ -0,0 +1,21 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-machine q35,accel=tcg,iommu=on \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
new file mode 100644
index 0000000..b5b2b51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <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>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='pci' index='1' model='dmi-to-pci-bridge'>
+ <model name='i82801b11-bridge'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
+ </controller>
+ <controller type='pci' index='2' model='pci-bridge'>
+ <model name='pci-bridge'/>
+ <target chassisNr='2'/>
+ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+ </controller>
+ <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'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
+ </memballoon>
+ <iommu model='intel'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4b9ecb8..903276d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2157,6 +2157,8 @@ mymain(void)
DO_TEST("acpi-table", NONE);
DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_INTEL_IOMMU);
+ DO_TEST("intel-iommu-machine", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_MACHINE_OPT,
+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_MACHINE_IOMMU);
DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
--
2.7.4
8 years, 1 month
[libvirt] [PATCH v2 0/5] Combine various query-block json call paths
by John Ferlan
v1: http://www.redhat.com/archives/libvir-list/2016-September/msg01446.html
NOTE: Patch 1 already ACK'd
Patches 2-4 adjusted slightly to not create/use qemuMonitorJSONQueryBlockArgs
instead opting to pass all the args (also shortened helper names slightly).
Patch 5 adjusted to receive all args in qemuMonitorJSONQueryBlock and then
call one of two callbacks based on whether the table or search is being used.
I did have a version that used ATTRIBUTE_UNUSED and one generic callback, but
I thought that was uglier.
John Ferlan (5):
qemu: Create common code for JSON "query-block" call
qemu: Split out filling of JSONGetBlockInfo data
qemu: Split out filling of JSONBlockStats data
qemu: Split out filling of JSONDiskNameLookup data
qemu: Combine the various ways to call query-block
src/qemu/qemu_monitor_json.c | 356 +++++++++++++++++++++++++------------------
1 file changed, 205 insertions(+), 151 deletions(-)
For "statistical purposes" after each patch the I checked --shortstat:
Patch 1: 34 insertions, 29 deletions
Patch 2: 93 insertions, 68 deletions
Patch 3: 122 insertions, 78 deletions
Patch 4: 158 insertions, 86 deletions
Patch 5: 205 insertions, 151 deletions
Of the insertions, there's 53 lines of function header comments and
46 lines of function declarations...
--
2.7.4
8 years, 1 month
[libvirt] [PATCH v2] qemu: fix command line building for iommu devices
by Daniel P. Berrange
The intel-iommu device has existed since QEMU 2.2.0, but
it was only possible to create it with -device since
QEMU 2.7.0, thanks to:
commit 621d983a1f9051f4cfc3f402569b46b77d8449fc
Author: Marcel Apfelbaum <marcel(a)redhat.com>
Date: Mon Jun 27 18:38:34 2016 +0300
hw/iommu: enable iommu with -device
Use the standard '-device intel-iommu' to create the IOMMU device.
The legacy '-machine,iommu=on' can still be used.
The libvirt capability check & command line formatting code
is thus broken for all QEMU versions 2.2.0 -> 2.6.0 inclusive.
This fixes it to use iommu=on instead.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 13 ++++++++
src/qemu/qemu_capabilities.h | 3 ++
src/qemu/qemu_command.c | 22 +++++++++++++
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 2 +-
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 2 +-
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 2 +-
tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 2 +-
.../qemuxml2argv-intel-iommu-machine.args | 21 ++++++++++++
.../qemuxml2argv-intel-iommu-machine.xml | 37 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 2 ++
10 files changed, 102 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2ca7803..9020247 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -342,6 +342,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"smm",
"virtio-pci-disable-legacy",
"query-hotpluggable-cpus",
+
+ "machine-iommu", /* 235 */
);
@@ -3633,6 +3635,17 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (virQEMUCapsProbeQMPMigrationCapabilities(qemuCaps, mon) < 0)
goto cleanup;
+ /* 'intel-iommu' shows up as a device since 2.2.0, but can
+ * not be used with -device until 2.7.0. Before that it
+ * requires -machine iommu=on. So we must clear the device
+ * capability we detected on older QEMUs
+ */
+ if (qemuCaps->version < 2007000 &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU);
+ }
+
/* GIC capabilities, eg. available GIC versions */
if ((qemuCaps->arch == VIR_ARCH_AARCH64 ||
qemuCaps->arch == VIR_ARCH_ARMV7L) &&
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index a74d39f..ce2b01a 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -376,6 +376,9 @@ typedef enum {
QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, /* virtio-*pci.disable-legacy */
QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS, /* qmp command query-hotpluggable-cpus */
+ /* 235 */
+ QEMU_CAPS_MACHINE_IOMMU, /* -machine iommu=on */
+
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 982c33c..f2b579d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6349,6 +6349,9 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
if (!def->iommu)
return 0;
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
+ return 0; /* Already handled via -machine */
+
switch (def->iommu->model) {
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
@@ -7067,6 +7070,25 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
}
}
+ /* We don't report errors on missing cap here - -device code will do that */
+ if (def->iommu &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) {
+ switch (def->iommu->model) {
+ case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+ if (!qemuDomainMachineIsQ35(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("IOMMU device: '%s' is only supported with "
+ "Q35 machines"),
+ virDomainIOMMUModelTypeToString(def->iommu->model));
+ return -1;
+ }
+ virBufferAddLit(&buf, ",iommu=on");
+ break;
+ case VIR_DOMAIN_IOMMU_MODEL_LAST:
+ break;
+ }
+ }
+
virCommandAddArgBuffer(cmd, &buf);
}
diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
index db778ef..abb9c66 100644
--- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml
@@ -182,9 +182,9 @@
<flag name='spice-unix'/>
<flag name='drive-detect-zeroes'/>
<flag name='display'/>
- <flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='machine-iommu'/>
<version>2004000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
index fc915ad..cbf2e1e 100644
--- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml
@@ -187,9 +187,9 @@
<flag name='drive-detect-zeroes'/>
<flag name='tls-creds-x509'/>
<flag name='display'/>
- <flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='machine-iommu'/>
<version>2005000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
index 60f1fcf..116c506 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml
@@ -193,9 +193,9 @@
<flag name='drive-detect-zeroes'/>
<flag name='tls-creds-x509'/>
<flag name='display'/>
- <flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
+ <flag name='machine-iommu'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
index 7a54040..b8b79ab 100644
--- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml
@@ -190,10 +190,10 @@
<flag name='drive-detect-zeroes'/>
<flag name='tls-creds-x509'/>
<flag name='display'/>
- <flag name='intel-iommu'/>
<flag name='smm'/>
<flag name='virtio-pci-disable-legacy'/>
<flag name='query-hotpluggable-cpus'/>
+ <flag name='machine-iommu'/>
<version>2006091</version>
<kvmVersion>0</kvmVersion>
<package> (v2.7.0-rc1-52-g42e0d60)</package>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
new file mode 100644
index 0000000..9221b79
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
@@ -0,0 +1,21 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-machine q35,accel=tcg,iommu=on \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
new file mode 100644
index 0000000..b5b2b51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <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>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='pci' index='1' model='dmi-to-pci-bridge'>
+ <model name='i82801b11-bridge'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
+ </controller>
+ <controller type='pci' index='2' model='pci-bridge'>
+ <model name='pci-bridge'/>
+ <target chassisNr='2'/>
+ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+ </controller>
+ <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'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
+ </memballoon>
+ <iommu model='intel'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 39abe72..d5e21ac 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2105,6 +2105,8 @@ mymain(void)
DO_TEST("acpi-table", NONE);
DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_INTEL_IOMMU);
+ DO_TEST("intel-iommu-machine", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_MACHINE_OPT,
+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_MACHINE_IOMMU);
DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
--
2.7.4
8 years, 1 month
[libvirt] [PATCH] qemu: fix command line building for iommu devices
by Daniel P. Berrange
The intel-iommu device has existed since QEMU 2.2.0, but
it was only possible to create it with -device since
QEMU 2.7.0, thanks to:
commit 621d983a1f9051f4cfc3f402569b46b77d8449fc
Author: Marcel Apfelbaum <marcel(a)redhat.com>
Date: Mon Jun 27 18:38:34 2016 +0300
hw/iommu: enable iommu with -device
Use the standard '-device intel-iommu' to create the IOMMU device.
The legacy '-machine,iommu=on' can still be used.
The libvirt capability check & command line formatting code
is thus broken for all QEMU versions 2.2.0 -> 2.6.0 inclusive.
This fixes it to use iommu=on instead.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 13 ++++++++
src/qemu/qemu_capabilities.h | 3 ++
src/qemu/qemu_command.c | 22 +++++++++++++
.../qemuxml2argv-intel-iommu-machine.args | 21 ++++++++++++
.../qemuxml2argv-intel-iommu-machine.xml | 37 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 2 ++
6 files changed, 98 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 2ca7803..9020247 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -342,6 +342,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"smm",
"virtio-pci-disable-legacy",
"query-hotpluggable-cpus",
+
+ "machine-iommu", /* 235 */
);
@@ -3633,6 +3635,17 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (virQEMUCapsProbeQMPMigrationCapabilities(qemuCaps, mon) < 0)
goto cleanup;
+ /* 'intel-iommu' shows up as a device since 2.2.0, but can
+ * not be used with -device until 2.7.0. Before that it
+ * requires -machine iommu=on. So we must clear the device
+ * capability we detected on older QEMUs
+ */
+ if (qemuCaps->version < 2007000 &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
+ virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU);
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU);
+ }
+
/* GIC capabilities, eg. available GIC versions */
if ((qemuCaps->arch == VIR_ARCH_AARCH64 ||
qemuCaps->arch == VIR_ARCH_ARMV7L) &&
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index a74d39f..ce2b01a 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -376,6 +376,9 @@ typedef enum {
QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY, /* virtio-*pci.disable-legacy */
QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS, /* qmp command query-hotpluggable-cpus */
+ /* 235 */
+ QEMU_CAPS_MACHINE_IOMMU, /* -machine iommu=on */
+
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 982c33c..f2b579d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6349,6 +6349,9 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
if (!def->iommu)
return 0;
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU))
+ return 0; /* Already handled via -machine */
+
switch (def->iommu->model) {
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) {
@@ -7067,6 +7070,25 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
}
}
+ /* We don't report errors on missing cap here - -device code will do that */
+ if (def->iommu &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) {
+ switch (def->iommu->model) {
+ case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+ if (!qemuDomainMachineIsQ35(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("IOMMU device: '%s' is only supported with "
+ "Q35 machines"),
+ virDomainIOMMUModelTypeToString(def->iommu->model));
+ return -1;
+ }
+ virBufferAddLit(&buf, ",iommu=on");
+ break;
+ case VIR_DOMAIN_IOMMU_MODEL_LAST:
+ break;
+ }
+ }
+
virCommandAddArgBuffer(cmd, &buf);
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
new file mode 100644
index 0000000..9221b79
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.args
@@ -0,0 +1,21 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-machine q35,accel=tcg,iommu=on \
+-m 214 \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
new file mode 100644
index 0000000..b5b2b51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-machine.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <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>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='pci' index='0' model='pcie-root'/>
+ <controller type='pci' index='1' model='dmi-to-pci-bridge'>
+ <model name='i82801b11-bridge'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
+ </controller>
+ <controller type='pci' index='2' model='pci-bridge'>
+ <model name='pci-bridge'/>
+ <target chassisNr='2'/>
+ <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
+ </controller>
+ <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'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x02' slot='0x01' function='0x0'/>
+ </memballoon>
+ <iommu model='intel'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 39abe72..d5e21ac 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -2105,6 +2105,8 @@ mymain(void)
DO_TEST("acpi-table", NONE);
DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_INTEL_IOMMU);
+ DO_TEST("intel-iommu-machine", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_MACHINE_OPT,
+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_MACHINE_IOMMU);
DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
--
2.7.4
8 years, 1 month