提交 d4528d9a 编写于 作者: M Mark McLoughlin

Detect KVM's PCI device assignment support

PCI device assignment is only supported in KVM's fork of qemu, so we
should really detect its availability and give a nice error if its
not supported.

* src/qemu_conf.[ch]: introduce QEMUD_CMD_FLAG_PCIDEVICE indicating
  that the -pcidevice command line option is available

* tests/*: update the tests
上级 0c5b7b93
......@@ -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,
......
......@@ -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 */
......
......@@ -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");
......
......@@ -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;
......
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册