mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: move PCI slot assignment for PIIX3, Q35 into a separate function
In order to be able to test for fully reserved PCI buses, assignment of PCI slots for integrated devices needs to be moved to a separate function. This also might be a good preparation if we decide to add support for other chipsets as well.
This commit is contained in:
parent
3fb2a69284
commit
a3ecd63e92
@ -1874,6 +1874,27 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuValidateDevicePCISlotsChipsets(virDomainDefPtr def,
|
||||||
|
virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainPCIAddressSetPtr addrs)
|
||||||
|
{
|
||||||
|
if ((STRPREFIX(def->os.machine, "pc-0.") ||
|
||||||
|
STRPREFIX(def->os.machine, "pc-1.") ||
|
||||||
|
STRPREFIX(def->os.machine, "pc-i440") ||
|
||||||
|
STREQ(def->os.machine, "pc") ||
|
||||||
|
STRPREFIX(def->os.machine, "rhel")) &&
|
||||||
|
qemuValidateDevicePCISlotsPIIX3(def, qemuCaps, addrs) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qemuDomainMachineIsQ35(def) &&
|
||||||
|
qemuDomainValidateDevicePCISlotsQ35(def, qemuCaps, addrs) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
||||||
@ -1907,7 +1928,11 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
/* 1st pass to figure out how many PCI bridges we need */
|
/* 1st pass to figure out how many PCI bridges we need */
|
||||||
if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, true)))
|
if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, true)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
|
|
||||||
|
if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuAssignDevicePCISlots(def, addrs) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < addrs->nbuses; i++) {
|
for (i = 0; i < addrs->nbuses; i++) {
|
||||||
@ -1946,7 +1971,10 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuDomainSupportsPCI(def)) {
|
if (qemuDomainSupportsPCI(def)) {
|
||||||
if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
|
if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuAssignDevicePCISlots(def, addrs) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1990,6 +2018,9 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
* - PIIX3 ISA bridge, IDE controller, something else unknown, USB controller (slot 1)
|
* - PIIX3 ISA bridge, IDE controller, something else unknown, USB controller (slot 1)
|
||||||
* - Video (slot 2)
|
* - Video (slot 2)
|
||||||
*
|
*
|
||||||
|
* - These integrated devices were already added by
|
||||||
|
* qemuValidateDevicePCISlotsChipsets invoked right before this function
|
||||||
|
*
|
||||||
* Incrementally assign slots from 3 onwards:
|
* Incrementally assign slots from 3 onwards:
|
||||||
*
|
*
|
||||||
* - Net
|
* - Net
|
||||||
@ -2007,27 +2038,12 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
qemuAssignDevicePCISlots(virDomainDefPtr def,
|
qemuAssignDevicePCISlots(virDomainDefPtr def,
|
||||||
virQEMUCapsPtr qemuCaps,
|
|
||||||
virDomainPCIAddressSetPtr addrs)
|
virDomainPCIAddressSetPtr addrs)
|
||||||
{
|
{
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
virDomainPCIConnectFlags flags;
|
virDomainPCIConnectFlags flags;
|
||||||
virDevicePCIAddress tmp_addr;
|
virDevicePCIAddress tmp_addr;
|
||||||
|
|
||||||
if ((STRPREFIX(def->os.machine, "pc-0.") ||
|
|
||||||
STRPREFIX(def->os.machine, "pc-1.") ||
|
|
||||||
STRPREFIX(def->os.machine, "pc-i440") ||
|
|
||||||
STREQ(def->os.machine, "pc") ||
|
|
||||||
STRPREFIX(def->os.machine, "rhel")) &&
|
|
||||||
qemuValidateDevicePCISlotsPIIX3(def, qemuCaps, addrs) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuDomainMachineIsQ35(def) &&
|
|
||||||
qemuDomainValidateDevicePCISlotsQ35(def, qemuCaps, addrs) < 0) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PCI controllers */
|
/* PCI controllers */
|
||||||
for (i = 0; i < def->ncontrollers; i++) {
|
for (i = 0; i < def->ncontrollers; i++) {
|
||||||
if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
|
if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
|
||||||
|
@ -249,7 +249,6 @@ virDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
|
|||||||
bool dryRun);
|
bool dryRun);
|
||||||
|
|
||||||
int qemuAssignDevicePCISlots(virDomainDefPtr def,
|
int qemuAssignDevicePCISlots(virDomainDefPtr def,
|
||||||
virQEMUCapsPtr qemuCaps,
|
|
||||||
virDomainPCIAddressSetPtr addrs);
|
virDomainPCIAddressSetPtr addrs);
|
||||||
|
|
||||||
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
|
int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps);
|
||||||
|
Loading…
Reference in New Issue
Block a user