mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: replace calls to virDomainPCIAddressReserveNext*() with static function
An upcoming commit will remove the "flag" argument from all the calls to reserve the next available address|slot, but I don't want to change the arguments in the hypervisor-agnostic virDomainPCIAddressReserveNext*() functions, so this patch places a simple qemu-specific wrapper around those functions - the new functions don't take a flags arg, but grab it from the device's info->pciConnectFlags.
This commit is contained in:
parent
696929e67f
commit
ab9202e431
@ -407,6 +407,27 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
|
||||
virDomainDeviceInfoPtr dev,
|
||||
virDomainPCIConnectFlags flags,
|
||||
unsigned int function,
|
||||
bool reserveEntireSlot)
|
||||
{
|
||||
return virDomainPCIAddressReserveNextAddr(addrs, dev, flags,
|
||||
function, reserveEntireSlot);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainPCIAddressReserveNextSlot(virDomainPCIAddressSetPtr addrs,
|
||||
virDomainDeviceInfoPtr dev,
|
||||
virDomainPCIConnectFlags flags)
|
||||
{
|
||||
return qemuDomainPCIAddressReserveNextAddr(addrs, dev, flags, 0, true);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||
virDomainDeviceDefPtr device,
|
||||
@ -693,10 +714,11 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
|
||||
|
||||
if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
|
||||
if (qemuDeviceVideoUsable) {
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
&primaryVideo->info,
|
||||
flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||
&primaryVideo->info,
|
||||
flags) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("PCI address 0:0:2.0 is in use, "
|
||||
@ -882,7 +904,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
|
||||
|
||||
if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
|
||||
if (qemuDeviceVideoUsable) {
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||
&primaryVideo->info,
|
||||
flags) < 0)
|
||||
goto cleanup;
|
||||
@ -919,7 +941,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
|
||||
" device will not be possible without manual"
|
||||
" intervention");
|
||||
virResetLastError();
|
||||
} else if (virDomainPCIAddressReserveSlot(addrs, &tmp_addr, flags) < 0) {
|
||||
} else if (virDomainPCIAddressReserveSlot(addrs,
|
||||
&tmp_addr, flags) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@ -1023,8 +1046,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
* controller/bus to connect it to on the upstream side.
|
||||
*/
|
||||
flags = virDomainPCIControllerModelToConnectType(model);
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
&cont->info, flags) < 0) {
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||
&cont->info, flags) < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -1043,8 +1066,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
|
||||
/* Only support VirtIO-9p-pci so far. If that changes,
|
||||
* we might need to skip devices here */
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
|
||||
flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1060,7 +1083,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
!virDeviceInfoPCIAddressWanted(&net->info)) {
|
||||
continue;
|
||||
}
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &net->info, flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &net->info, flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1078,7 +1101,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &sound->info, flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &sound->info, flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1154,17 +1177,18 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
} else {
|
||||
/* This is the first part of the controller, so need
|
||||
* to find a free slot & then reserve this function */
|
||||
if (virDomainPCIAddressReserveNextAddr(addrs, &cont->info,
|
||||
flags, addr.function,
|
||||
false) < 0) {
|
||||
if (qemuDomainPCIAddressReserveNextAddr(addrs,
|
||||
&cont->info, flags,
|
||||
addr.function,
|
||||
false) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
cont->info.addr.pci.multi = addr.multi;
|
||||
}
|
||||
} else {
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
&cont->info, flags) < 0) {
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||
&cont->info, flags) < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -1197,8 +1221,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
|
||||
flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1210,9 +1234,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||
continue;
|
||||
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
def->hostdevs[i]->info,
|
||||
flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, def->hostdevs[i]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1220,9 +1243,9 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
if (def->memballoon &&
|
||||
def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
|
||||
virDeviceInfoPCIAddressWanted(&def->memballoon->info)) {
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
&def->memballoon->info,
|
||||
flags) < 0)
|
||||
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->memballoon->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1232,8 +1255,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
!virDeviceInfoPCIAddressWanted(&def->rngs[i]->info))
|
||||
continue;
|
||||
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
&def->rngs[i]->info, flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->rngs[i]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1241,8 +1264,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
if (def->watchdog &&
|
||||
def->watchdog->model == VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB &&
|
||||
virDeviceInfoPCIAddressWanted(&def->watchdog->info)) {
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
|
||||
flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1250,16 +1273,16 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
* assigned address. */
|
||||
if (def->nvideos > 0 &&
|
||||
virDeviceInfoPCIAddressWanted(&def->videos[0]->info)) {
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->videos[0]->info,
|
||||
flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[0]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (i = 1; i < def->nvideos; i++) {
|
||||
if (!virDeviceInfoPCIAddressWanted(&def->videos[i]->info))
|
||||
continue;
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
|
||||
flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -1268,8 +1291,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
if (!virDeviceInfoPCIAddressWanted(&def->shmems[i]->info))
|
||||
continue;
|
||||
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
&def->shmems[i]->info, flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->shmems[i]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
for (i = 0; i < def->ninputs; i++) {
|
||||
@ -1277,8 +1300,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
!virDeviceInfoPCIAddressWanted(&def->inputs[i]->info))
|
||||
continue;
|
||||
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
||||
&def->inputs[i]->info, flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->inputs[i]->info,
|
||||
flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
for (i = 0; i < def->nparallels; i++) {
|
||||
@ -1291,7 +1314,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
||||
!virDeviceInfoPCIAddressWanted(&chr->info))
|
||||
continue;
|
||||
|
||||
if (virDomainPCIAddressReserveNextSlot(addrs, &chr->info, flags) < 0)
|
||||
if (qemuDomainPCIAddressReserveNextSlot(addrs, &chr->info, flags) < 0)
|
||||
goto error;
|
||||
}
|
||||
for (i = 0; i < def->nchannels; i++) {
|
||||
@ -1488,7 +1511,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
||||
*/
|
||||
if (!buses_reserved &&
|
||||
!qemuDomainMachineIsVirt(def) &&
|
||||
virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
||||
qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
|
||||
@ -1503,7 +1526,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
||||
goto cleanup;
|
||||
/* If we added a new bridge, we will need one more address */
|
||||
if (rv > 0 &&
|
||||
virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
||||
qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
nbuses = addrs->nbuses;
|
||||
|
Loading…
Reference in New Issue
Block a user