return NULL;
}
-/* check whether the slot is used by the other device
- * Return 0 if the slot is not used by the other device, or -1 if the slot
- * is used by the other device.
+/*
+ * Check if the PCI slot is used by another device.
*/
-static int qemuDomainPCIAddressCheckSlot(qemuDomainPCIAddressSetPtr addrs,
- virDevicePCIAddressPtr addr)
+static bool qemuDomainPCIAddressSlotInUse(qemuDomainPCIAddressSetPtr addrs,
+ virDevicePCIAddressPtr addr)
{
- return addrs->used[addr->bus][addr->slot] ? -1 : 0;
+ return !!addrs->used[addr->bus][addr->slot];
}
int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
if (!(addr = qemuPCIAddressAsString(&tmp_addr)))
return -1;
- if (qemuDomainPCIAddressCheckSlot(addrs, &tmp_addr) < 0) {
+ if (qemuDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
VIR_DEBUG("PCI addr %s already in use", addr);
VIR_FREE(addr);
continue;
primaryVideo->info.addr.pci.function = 0;
addrptr = &primaryVideo->info.addr.pci;
- if (qemuDomainPCIAddressCheckSlot(addrs, addrptr) < 0) {
+ if (qemuDomainPCIAddressSlotInUse(addrs, addrptr)) {
if (qemuDeviceVideoUsable) {
virResetLastError();
if (qemuDomainPCIAddressSetNextAddr(addrs, &primaryVideo->info) < 0)
memset(&tmp_addr, 0, sizeof(tmp_addr));
tmp_addr.slot = 2;
- if (qemuDomainPCIAddressCheckSlot(addrs, &tmp_addr) < 0) {
+ if (qemuDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
VIR_DEBUG("PCI address 0:0:2.0 in use, future addition of a video"
" device will not be possible without manual"
" intervention");