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
|
static int
|
||||||
qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||||
virDomainDeviceDefPtr device,
|
virDomainDeviceDefPtr device,
|
||||||
@ -693,10 +714,11 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
|
|||||||
|
|
||||||
if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
|
if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
|
||||||
if (qemuDeviceVideoUsable) {
|
if (qemuDeviceVideoUsable) {
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
&primaryVideo->info,
|
&primaryVideo->info,
|
||||||
flags) < 0)
|
flags) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("PCI address 0:0:2.0 is in use, "
|
_("PCI address 0:0:2.0 is in use, "
|
||||||
@ -882,7 +904,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
|
|||||||
|
|
||||||
if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
|
if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
|
||||||
if (qemuDeviceVideoUsable) {
|
if (qemuDeviceVideoUsable) {
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
&primaryVideo->info,
|
&primaryVideo->info,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -919,7 +941,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
|
|||||||
" device will not be possible without manual"
|
" device will not be possible without manual"
|
||||||
" intervention");
|
" intervention");
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
} else if (virDomainPCIAddressReserveSlot(addrs, &tmp_addr, flags) < 0) {
|
} else if (virDomainPCIAddressReserveSlot(addrs,
|
||||||
|
&tmp_addr, flags) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1023,7 +1046,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
* controller/bus to connect it to on the upstream side.
|
* controller/bus to connect it to on the upstream side.
|
||||||
*/
|
*/
|
||||||
flags = virDomainPCIControllerModelToConnectType(model);
|
flags = virDomainPCIControllerModelToConnectType(model);
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
&cont->info, flags) < 0) {
|
&cont->info, flags) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1043,7 +1066,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
|
|
||||||
/* Only support VirtIO-9p-pci so far. If that changes,
|
/* Only support VirtIO-9p-pci so far. If that changes,
|
||||||
* we might need to skip devices here */
|
* we might need to skip devices here */
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1060,7 +1083,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
!virDeviceInfoPCIAddressWanted(&net->info)) {
|
!virDeviceInfoPCIAddressWanted(&net->info)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &net->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &net->info, flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1078,7 +1101,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &sound->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &sound->info, flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1154,8 +1177,9 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
} else {
|
} else {
|
||||||
/* This is the first part of the controller, so need
|
/* This is the first part of the controller, so need
|
||||||
* to find a free slot & then reserve this function */
|
* to find a free slot & then reserve this function */
|
||||||
if (virDomainPCIAddressReserveNextAddr(addrs, &cont->info,
|
if (qemuDomainPCIAddressReserveNextAddr(addrs,
|
||||||
flags, addr.function,
|
&cont->info, flags,
|
||||||
|
addr.function,
|
||||||
false) < 0) {
|
false) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1163,7 +1187,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
cont->info.addr.pci.multi = addr.multi;
|
cont->info.addr.pci.multi = addr.multi;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
&cont->info, flags) < 0) {
|
&cont->info, flags) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1197,7 +1221,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1210,8 +1234,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, def->hostdevs[i]->info,
|
||||||
def->hostdevs[i]->info,
|
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1220,8 +1243,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
if (def->memballoon &&
|
if (def->memballoon &&
|
||||||
def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
|
def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
|
||||||
virDeviceInfoPCIAddressWanted(&def->memballoon->info)) {
|
virDeviceInfoPCIAddressWanted(&def->memballoon->info)) {
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
|
||||||
&def->memballoon->info,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->memballoon->info,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1232,8 +1255,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
!virDeviceInfoPCIAddressWanted(&def->rngs[i]->info))
|
!virDeviceInfoPCIAddressWanted(&def->rngs[i]->info))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->rngs[i]->info,
|
||||||
&def->rngs[i]->info, flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1241,7 +1264,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
if (def->watchdog &&
|
if (def->watchdog &&
|
||||||
def->watchdog->model == VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB &&
|
def->watchdog->model == VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB &&
|
||||||
virDeviceInfoPCIAddressWanted(&def->watchdog->info)) {
|
virDeviceInfoPCIAddressWanted(&def->watchdog->info)) {
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1250,7 +1273,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
* assigned address. */
|
* assigned address. */
|
||||||
if (def->nvideos > 0 &&
|
if (def->nvideos > 0 &&
|
||||||
virDeviceInfoPCIAddressWanted(&def->videos[0]->info)) {
|
virDeviceInfoPCIAddressWanted(&def->videos[0]->info)) {
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->videos[0]->info,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[0]->info,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1258,7 +1281,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
for (i = 1; i < def->nvideos; i++) {
|
for (i = 1; i < def->nvideos; i++) {
|
||||||
if (!virDeviceInfoPCIAddressWanted(&def->videos[i]->info))
|
if (!virDeviceInfoPCIAddressWanted(&def->videos[i]->info))
|
||||||
continue;
|
continue;
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
|
||||||
flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -1268,8 +1291,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
if (!virDeviceInfoPCIAddressWanted(&def->shmems[i]->info))
|
if (!virDeviceInfoPCIAddressWanted(&def->shmems[i]->info))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->shmems[i]->info,
|
||||||
&def->shmems[i]->info, flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
for (i = 0; i < def->ninputs; i++) {
|
for (i = 0; i < def->ninputs; i++) {
|
||||||
@ -1277,8 +1300,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
!virDeviceInfoPCIAddressWanted(&def->inputs[i]->info))
|
!virDeviceInfoPCIAddressWanted(&def->inputs[i]->info))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs,
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->inputs[i]->info,
|
||||||
&def->inputs[i]->info, flags) < 0)
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
for (i = 0; i < def->nparallels; i++) {
|
for (i = 0; i < def->nparallels; i++) {
|
||||||
@ -1291,7 +1314,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
!virDeviceInfoPCIAddressWanted(&chr->info))
|
!virDeviceInfoPCIAddressWanted(&chr->info))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (virDomainPCIAddressReserveNextSlot(addrs, &chr->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &chr->info, flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
for (i = 0; i < def->nchannels; i++) {
|
for (i = 0; i < def->nchannels; i++) {
|
||||||
@ -1488,7 +1511,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
*/
|
*/
|
||||||
if (!buses_reserved &&
|
if (!buses_reserved &&
|
||||||
!qemuDomainMachineIsVirt(def) &&
|
!qemuDomainMachineIsVirt(def) &&
|
||||||
virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
|
if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
|
||||||
@ -1503,7 +1526,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
/* If we added a new bridge, we will need one more address */
|
/* If we added a new bridge, we will need one more address */
|
||||||
if (rv > 0 &&
|
if (rv > 0 &&
|
||||||
virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
nbuses = addrs->nbuses;
|
nbuses = addrs->nbuses;
|
||||||
|
Loading…
Reference in New Issue
Block a user