diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 02f9d16f63..45eb0dc976 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -420,6 +420,8 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot);
if (info->addr.pci.function != 0)
virBufferAsprintf(buf, ".0x%x", info->addr.pci.function);
+ if (info->acpiIndex != 0)
+ virBufferAsprintf(buf, ",acpi-index=%u", info->acpiIndex);
}
break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 09778085a8..27afcab9aa 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1069,6 +1069,32 @@ qemuValidateDomainDefPanic(const virDomainDef *def,
}
+static int
+qemuValidateDomainDeviceInfo(virDomainDefPtr def G_GNUC_UNUSED,
+ virDomainDeviceDefPtr dev G_GNUC_UNUSED,
+ virDomainDeviceInfoPtr info,
+ void *opaque)
+{
+ virQEMUCapsPtr qemuCaps = opaque;
+
+ if (info->acpiIndex) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_INDEX)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ACPI index is not supported with this QEMU"));
+ return -1;
+ }
+
+ if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
+ info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ACPI index is only supported for PCI devices"));
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
int
qemuValidateDomainDef(const virDomainDef *def,
void *opaque,
@@ -1235,6 +1261,15 @@ qemuValidateDomainDef(const virDomainDef *def,
return -1;
}
+ /* Explicitly discarding 'const' from 'def' is ok because
+ * we know our callback qemuValidateDomainDeviceInfo will
+ * not modify it
+ */
+ if (virDomainDeviceInfoIterate((virDomainDefPtr)def,
+ qemuValidateDomainDeviceInfo,
+ qemuCaps) < 0)
+ return -1;
+
return 0;
}
diff --git a/tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args b/tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args
new file mode 100644
index 0000000000..07a8b0d189
--- /dev/null
+++ b/tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args
@@ -0,0 +1,57 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-fdr-br \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-fdr-br/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-fdr-br/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-fdr-br/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=fdr-br,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw",\
+"file":"/tmp/lib/domain--1-fdr-br/master-key.aes"}' \
+-machine pc-i440fx-5.0,accel=tcg,usb=off,dump-guest-core=off,\
+memory-backend=pc.ram \
+-cpu qemu64 \
+-m 2048 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":2147483648}' \
+-overcommit mem-lock=off \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid 3ec6cbe1-b5a2-4515-b800-31a61855df41 \
+-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 piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test.img",\
+"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw",\
+"file":"libvirt-2-storage"}' \
+-device virtio-blk-pci,bus=pci.0,addr=0x3,acpi-index=1,drive=libvirt-2-format,\
+id=virtio-disk0,bootindex=1 \
+-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test1.img",\
+"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw",\
+"file":"libvirt-1-storage"}' \
+-device virtio-blk-pci,bus=pci.0,addr=0x4,acpi-index=42,drive=libvirt-1-format,\
+id=virtio-disk1 \
+-netdev user,id=hostnet0 \
+-device virtio-net-pci,netdev=hostnet0,id=net0,mac=00:11:22:33:44:55,bus=pci.0,\
+addr=0x5,acpi-index=100 \
+-netdev user,id=hostnet1 \
+-device virtio-net-pci,netdev=hostnet1,id=net1,mac=00:11:22:33:44:55,bus=pci.0,\
+addr=0x7,acpi-index=200 \
+-netdev user,id=hostnet2 \
+-device virtio-net-pci,netdev=hostnet2,id=net2,mac=00:11:22:33:44:55,bus=pci.0,\
+addr=0x8,acpi-index=300 \
+-audiodev id=audio1,driver=none \
+-device cirrus-vga,id=video0,bus=pci.0,addr=0x2,acpi-index=1729 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/devices-acpi-index.xml b/tests/qemuxml2argvdata/devices-acpi-index.xml
new file mode 100644
index 0000000000..5d0176e7fe
--- /dev/null
+++ b/tests/qemuxml2argvdata/devices-acpi-index.xml
@@ -0,0 +1,62 @@
+
+ fdr-br
+ 3ec6cbe1-b5a2-4515-b800-31a61855df41
+ 2097152
+ 2097152
+ 2
+
+ hvm
+
+
+
+
+
+
+
+
+ destroy
+ restart
+ restart
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ea98f0e6a8..83dd6a7756 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -3611,6 +3611,8 @@ mymain(void)
DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
DO_TEST_CAPS_LATEST("virtio-9p-createmode");
+ DO_TEST_CAPS_LATEST("devices-acpi-index");
+
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);
diff --git a/tests/qemuxml2xmloutdata/devices-acpi-index.x86_64-latest.xml b/tests/qemuxml2xmloutdata/devices-acpi-index.x86_64-latest.xml
new file mode 100644
index 0000000000..3c6b384e8a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/devices-acpi-index.x86_64-latest.xml
@@ -0,0 +1,73 @@
+
+ fdr-br
+ 3ec6cbe1-b5a2-4515-b800-31a61855df41
+ 2097152
+ 2097152
+ 2
+
+ hvm
+
+
+
+
+
+
+
+
+ qemu64
+
+
+ destroy
+ restart
+ restart
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index c92e1dd0cf..70a4a57df1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1522,6 +1522,8 @@ mymain(void)
driver.config->nogfxAllowHostAudio = false;
g_unsetenv("QEMU_AUDIO_DRV");
+ DO_TEST_CAPS_LATEST("devices-acpi-index");
+
cleanup:
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);