qemu: Support booting from hostdev PCI devices

This commit is contained in:
Jiri Denemark 2011-02-03 15:09:17 +01:00
parent 83e335f9d2
commit 963a9460b6
3 changed files with 22 additions and 1 deletions

View File

@ -1088,8 +1088,11 @@ qemuCapsParseDeviceStr(const char *str, unsigned long long *flags)
/* Features of given devices. */
if (strstr(str, "pci-assign.configfd"))
*flags |= QEMUD_CMD_FLAG_PCI_CONFIGFD;
if (strstr(str, "virtio-blk-pci.bootindex"))
if (strstr(str, "virtio-blk-pci.bootindex")) {
*flags |= QEMUD_CMD_FLAG_BOOTINDEX;
if (strstr(str, "pci-assign.bootindex"))
*flags |= QEMUD_CMD_FLAG_PCI_BOOTINDEX;
}
return 0;
}

View File

@ -87,6 +87,7 @@ enum qemuCapsFlags {
QEMUD_CMD_FLAG_HDA_DUPLEX = (1LL << 50), /* -device hda-duplex */
QEMUD_CMD_FLAG_DRIVE_AIO = (1LL << 51), /* -drive aio= supported */
QEMUD_CMD_FLAG_PCI_MULTIBUS = (1LL << 52), /* bus=pci.0 vs bus=pci */
QEMUD_CMD_FLAG_PCI_BOOTINDEX = (1LL << 53), /* pci-assign.bootindex */
};
virCapsPtr qemuCapsInit(virCapsPtr old_caps);

View File

@ -1917,6 +1917,8 @@ qemuBuildPCIHostdevDevStr(virDomainHostdevDefPtr dev, const char *configfd,
virBufferVSprintf(&buf, ",id=%s", dev->info.alias);
if (configfd && *configfd)
virBufferVSprintf(&buf, ",configfd=%s", configfd);
if (dev->bootIndex)
virBufferVSprintf(&buf, ",bootindex=%d", dev->bootIndex);
if (qemuBuildDeviceAddressStr(&buf, &dev->info, qemuCmdFlags) < 0)
goto error;
@ -3980,6 +3982,21 @@ qemuBuildCommandLine(virConnectPtr conn,
virDomainHostdevDefPtr hostdev = def->hostdevs[i];
char *devstr;
if (hostdev->bootIndex) {
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("booting from assigned devices is only"
" supported for PCI devices"));
goto error;
} else if (!(qemuCmdFlags & QEMUD_CMD_FLAG_PCI_BOOTINDEX)) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("booting from assigned PCI devices is not"
" supported with this version of qemu"));
goto error;
}
}
/* USB */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {