diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 6b0b4048fe52098efb81de4f04f01c8284aff8e4..1b160c9c5aa06eff18cb8dfb383c0b326b57da45 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -771,6 +771,9 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_VGA; if (strstr(help, "boot=on")) flags |= QEMUD_CMD_FLAG_DRIVE_BOOT; + if (strstr(help, "-pcidevice")) + flags |= QEMUD_CMD_FLAG_PCIDEVICE; + if (version >= 9000) flags |= QEMUD_CMD_FLAG_VNC_COLON; @@ -2070,6 +2073,11 @@ int qemudBuildCommandLine(virConnectPtr conn, /* PCI */ if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) { + if (!(qemuCmdFlags & QEMUD_CMD_FLAG_PCIDEVICE)) { + qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SUPPORT, "%s", + _("PCI device assignment is not supported by this version of qemu")); + goto error; + } ret = virAsprintf(&pcidev, "host=%.2x:%.2x.%.1x", hostdev->source.subsys.u.pci.bus, hostdev->source.subsys.u.pci.slot, diff --git a/src/qemu_conf.h b/src/qemu_conf.h index 517626ab4078d75a8533e78560f494be5f660675..aea9843e74fa792882dd91efaa250d72ace74be2 100644 --- a/src/qemu_conf.h +++ b/src/qemu_conf.h @@ -64,6 +64,8 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_0_10 = (1 << 16), QEMUD_CMD_FLAG_NET_NAME = QEMUD_CMD_FLAG_0_10, /* -net ...,name=str */ QEMUD_CMD_FLAG_HOST_NET_ADD = QEMUD_CMD_FLAG_0_10, /* host_net_add monitor command */ + + QEMUD_CMD_FLAG_PCIDEVICE = (1 << 17), /* PCI device assignment only supported by qemu-kvm */ }; /* Main driver state */ diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index f2537b7c11fc13e88bb3a328478ee424c427474c..7861520e68a8d466599d4a36a66fe74220904d81 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -216,7 +216,7 @@ mymain(int argc, char **argv) DO_TEST("hostdev-usb-product", 0); DO_TEST("hostdev-usb-address", 0); - DO_TEST("hostdev-pci-address", 0); + DO_TEST("hostdev-pci-address", QEMUD_CMD_FLAG_PCIDEVICE); DO_TEST_FULL("restore-v1", QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO, "stdio"); DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "stdio"); diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 1948bd1ed6480667b93eb195d6d802ee30480e83..ad2045fa5ef3841ce852c0e655e52632d6e147b5 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -135,7 +135,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_KVM | QEMUD_CMD_FLAG_DRIVE_FORMAT | QEMUD_CMD_FLAG_VGA | - QEMUD_CMD_FLAG_0_10, + QEMUD_CMD_FLAG_0_10 | + QEMUD_CMD_FLAG_PCIDEVICE, 10005, 1, 0); DO_TEST("kvm-86", QEMUD_CMD_FLAG_VNC_COLON | @@ -151,7 +152,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_KVM | QEMUD_CMD_FLAG_DRIVE_FORMAT | QEMUD_CMD_FLAG_VGA | - QEMUD_CMD_FLAG_0_10, + QEMUD_CMD_FLAG_0_10 | + QEMUD_CMD_FLAG_PCIDEVICE, 10050, 1, 0); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 73a6709eed4300b4ac595d10cc9e73c177aef80f..6f25e7d77fb65bd3c88c6b2849909cf1bce3d453 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -263,7 +263,7 @@ mymain(int argc, char **argv) DO_TEST("hostdev-usb-product", 0); DO_TEST("hostdev-usb-address", 0); - DO_TEST("hostdev-pci-address", 0); + DO_TEST("hostdev-pci-address", QEMUD_CMD_FLAG_PCIDEVICE); DO_TEST_FULL("restore-v1", QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO, "stdio"); DO_TEST_FULL("restore-v2", QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, "stdio");