support multifunction PCI device
If qemu supports multi function PCI device, the format of the PCI address passed to qemu is "bus=pci.0,multifunction=on,addr=slot.function". If qemu does not support multi function PCI device, the format of the PCI address passed to qemu is "bus=pci.0,addr=slot".
This commit is contained in:
parent
6fe678cdaf
commit
9f8baf646e
@ -1312,6 +1312,9 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
|
|||||||
|
|
||||||
int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr)
|
int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr)
|
||||||
{
|
{
|
||||||
|
/* PCI bus has 32 slots and 8 functions per slot */
|
||||||
|
if (addr->slot >= 32 || addr->function >= 8)
|
||||||
|
return 0;
|
||||||
return addr->domain || addr->bus || addr->slot;
|
return addr->domain || addr->bus || addr->slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1252,10 +1252,20 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
|
|||||||
_("Only PCI device addresses with bus=0 are supported"));
|
_("Only PCI device addresses with bus=0 are supported"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (info->addr.pci.function != 0) {
|
if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIFUNCTION)) {
|
||||||
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
if (info->addr.pci.function > 7) {
|
||||||
_("Only PCI device addresses with function=0 are supported"));
|
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
return -1;
|
_("The function of PCI device addresses must "
|
||||||
|
"less than 8"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (info->addr.pci.function != 0) {
|
||||||
|
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
|
_("Only PCI device addresses with function=0 "
|
||||||
|
"are supported"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX
|
/* XXX
|
||||||
@ -1265,9 +1275,14 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
|
|||||||
* to pciNN.0 where NN is the domain number
|
* to pciNN.0 where NN is the domain number
|
||||||
*/
|
*/
|
||||||
if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS))
|
if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS))
|
||||||
virBufferAsprintf(buf, ",bus=pci.0,addr=0x%x", info->addr.pci.slot);
|
virBufferAsprintf(buf, ",bus=pci.0");
|
||||||
else
|
else
|
||||||
virBufferAsprintf(buf, ",bus=pci,addr=0x%x", info->addr.pci.slot);
|
virBufferAsprintf(buf, ",bus=pci");
|
||||||
|
if (qemuCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIFUNCTION))
|
||||||
|
virBufferAsprintf(buf, ",multifunction=on,addr=0x%x.0x%x",
|
||||||
|
info->addr.pci.slot, info->addr.pci.function);
|
||||||
|
else
|
||||||
|
virBufferAsprintf(buf, ",addr=0x%x", info->addr.pci.slot);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user