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
This commit is contained in:
Mark McLoughlin 2009-08-14 08:31:11 +01:00
parent 0c5b7b93a3
commit d4528d9ac2
5 changed files with 16 additions and 4 deletions

View File

@ -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,

View File

@ -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 */

View File

@ -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");

View File

@ -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;

View File

@ -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");