mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: rename some functions in qemu_command.c
* qemuDomainPCIAddressSetNextAddr The name of this function was confusing because 1) other functions in the file that end in "Addr" are only operating on a single function of one PCI slot, not the entire slot, while functions that do something with the entire slot end in "Slot", and 2) it didn't contain a verb describing what it is doing (the "Set" refers to the set that contains all PCI buses in the system, used to keep track of which slots in which buses are already reserved for use). It is now renamed to qemuDomainPCIAddressReserveNextSlot, which more clearly describes what it is doing. Arguably, it could have been changed to qemuDomainPCIAddressSetReserveNextSlot, but 1) the word "set" is confusing in this context because it could be intended as a verb or as a noun, and 2) most other functions that operate on a single slot or address within this set are also named qemuDomainPCIAddress... rather than qemuDomainPCIAddressSet... Only the Create, Free, and Grow functions for an address set (which modify the entire set, not just one element) use "Set" in their name. * qemuPCIAddressAsString, qemuPCIAddressValidate All the other functions in this set are named qemuDomainPCIAddressxxxxx, so I renamed these to be consistent.
This commit is contained in:
parent
c66da9d224
commit
29e3a1df47
@ -1439,9 +1439,9 @@ struct _qemuDomainPCIAddressSet {
|
|||||||
* with the specified PCI address set.
|
* with the specified PCI address set.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
qemuPCIAddressValidate(qemuDomainPCIAddressSetPtr addrs ATTRIBUTE_UNUSED,
|
qemuDomainPCIAddressValidate(qemuDomainPCIAddressSetPtr addrs,
|
||||||
virDevicePCIAddressPtr addr,
|
virDevicePCIAddressPtr addr,
|
||||||
qemuDomainPCIConnectFlags flags)
|
qemuDomainPCIConnectFlags flags)
|
||||||
{
|
{
|
||||||
qemuDomainPCIAddressBusPtr bus;
|
qemuDomainPCIAddressBusPtr bus;
|
||||||
|
|
||||||
@ -1578,7 +1578,7 @@ qemuDomainPCIAddressSetGrow(qemuDomainPCIAddressSetPtr addrs,
|
|||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
qemuPCIAddressAsString(virDevicePCIAddressPtr addr)
|
qemuDomainPCIAddressAsString(virDevicePCIAddressPtr addr)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
@ -1648,10 +1648,10 @@ qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|||||||
* that the bus is of the correct type for the device (via
|
* that the bus is of the correct type for the device (via
|
||||||
* comparing the flags).
|
* comparing the flags).
|
||||||
*/
|
*/
|
||||||
if (!qemuPCIAddressValidate(addrs, addr, flags))
|
if (!qemuDomainPCIAddressValidate(addrs, addr, flags))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(str = qemuPCIAddressAsString(addr)))
|
if (!(str = qemuDomainPCIAddressAsString(addr)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* check if already in use */
|
/* check if already in use */
|
||||||
@ -1729,7 +1729,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
|
if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
/* Reserve 1 extra slot for a (potential) bridge */
|
/* Reserve 1 extra slot for a (potential) bridge */
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 1; i < addrs->nbuses; i++) {
|
for (i = 1; i < addrs->nbuses; i++) {
|
||||||
@ -1740,7 +1740,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
|
|||||||
i, bus->model)) < 0)
|
i, bus->model)) < 0)
|
||||||
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 && qemuDomainPCIAddressSetNextAddr(addrs, &info, flags) < 0)
|
if (rv > 0 && qemuDomainPCIAddressReserveNextSlot(addrs, &info,
|
||||||
|
flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
nbuses = addrs->nbuses;
|
nbuses = addrs->nbuses;
|
||||||
@ -1881,7 +1882,7 @@ qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
|
|||||||
if (addrs->dryRun && qemuDomainPCIAddressSetGrow(addrs, addr, flags) < 0)
|
if (addrs->dryRun && qemuDomainPCIAddressSetGrow(addrs, addr, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(str = qemuPCIAddressAsString(addr)))
|
if (!(str = qemuDomainPCIAddressAsString(addr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VIR_DEBUG("Reserving PCI addr %s", str);
|
VIR_DEBUG("Reserving PCI addr %s", str);
|
||||||
@ -1923,7 +1924,7 @@ qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
|
|||||||
if (addrs->dryRun && qemuDomainPCIAddressSetGrow(addrs, addr, flags) < 0)
|
if (addrs->dryRun && qemuDomainPCIAddressSetGrow(addrs, addr, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(str = qemuPCIAddressAsString(addr)))
|
if (!(str = qemuDomainPCIAddressAsString(addr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
VIR_DEBUG("Reserving PCI slot %s", str);
|
VIR_DEBUG("Reserving PCI slot %s", str);
|
||||||
@ -1959,12 +1960,12 @@ int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!qemuPCIAddressValidate(addrs, &dev->addr.pci, flags))
|
if (!qemuDomainPCIAddressValidate(addrs, &dev->addr.pci, flags))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ret = qemuDomainPCIAddressReserveSlot(addrs, &dev->addr.pci, flags);
|
ret = qemuDomainPCIAddressReserveSlot(addrs, &dev->addr.pci, flags);
|
||||||
} else {
|
} else {
|
||||||
ret = qemuDomainPCIAddressSetNextAddr(addrs, dev, flags);
|
ret = qemuDomainPCIAddressReserveNextSlot(addrs, dev, flags);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1986,7 +1987,7 @@ qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs,
|
|||||||
*/
|
*/
|
||||||
qemuDomainPCIConnectFlags flags = QEMU_PCI_CONNECT_TYPES_MASK;
|
qemuDomainPCIConnectFlags flags = QEMU_PCI_CONNECT_TYPES_MASK;
|
||||||
|
|
||||||
if (!qemuPCIAddressValidate(addrs, addr, flags))
|
if (!qemuDomainPCIAddressValidate(addrs, addr, flags))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
addrs->buses[addr->bus].slots[addr->slot] = 0;
|
addrs->buses[addr->bus].slots[addr->slot] = 0;
|
||||||
@ -2059,9 +2060,9 @@ success:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainPCIAddressSetNextAddr(qemuDomainPCIAddressSetPtr addrs,
|
qemuDomainPCIAddressReserveNextSlot(qemuDomainPCIAddressSetPtr addrs,
|
||||||
virDomainDeviceInfoPtr dev,
|
virDomainDeviceInfoPtr dev,
|
||||||
qemuDomainPCIConnectFlags flags)
|
qemuDomainPCIConnectFlags flags)
|
||||||
{
|
{
|
||||||
virDevicePCIAddress addr;
|
virDevicePCIAddress addr;
|
||||||
if (qemuDomainPCIAddressGetNextSlot(addrs, &addr, flags) < 0)
|
if (qemuDomainPCIAddressGetNextSlot(addrs, &addr, flags) < 0)
|
||||||
@ -2188,14 +2189,16 @@ qemuValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
|
|||||||
primaryVideo->info.addr.pci.function = 0;
|
primaryVideo->info.addr.pci.function = 0;
|
||||||
addrptr = &primaryVideo->info.addr.pci;
|
addrptr = &primaryVideo->info.addr.pci;
|
||||||
|
|
||||||
if (!qemuPCIAddressValidate(addrs, addrptr, flags))
|
if (!qemuDomainPCIAddressValidate(addrs, addrptr, flags))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (qemuDomainPCIAddressSlotInUse(addrs, addrptr)) {
|
if (qemuDomainPCIAddressSlotInUse(addrs, addrptr)) {
|
||||||
if (qemuDeviceVideoUsable) {
|
if (qemuDeviceVideoUsable) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &primaryVideo->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
goto error;;
|
&primaryVideo->info,
|
||||||
|
flags) < 0)
|
||||||
|
goto error;
|
||||||
} 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, "
|
||||||
@ -2296,7 +2299,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
continue;
|
continue;
|
||||||
if (def->controllers[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
|
if (def->controllers[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
|
||||||
continue;
|
continue;
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->controllers[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
|
&def->controllers[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2307,7 +2312,8 @@ qemuAssignDevicePCISlots(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 (qemuDomainPCIAddressSetNextAddr(addrs, &def->fss[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2321,7 +2327,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
(def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) {
|
(def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->nets[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->nets[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2334,7 +2341,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK)
|
def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->sounds[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->sounds[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2409,7 +2417,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
|
||||||
def->controllers[i]->info.addr.pci = addr;
|
def->controllers[i]->info.addr.pci = addr;
|
||||||
} else {
|
} else {
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->controllers[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
|
&def->controllers[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2434,7 +2444,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->disks[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2446,7 +2457,9 @@ qemuAssignDevicePCISlots(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 (qemuDomainPCIAddressSetNextAddr(addrs, def->hostdevs[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
|
def->hostdevs[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2454,7 +2467,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
if (def->memballoon &&
|
if (def->memballoon &&
|
||||||
def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
|
def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
|
||||||
def->memballoon->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
def->memballoon->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->memballoon->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
|
&def->memballoon->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2462,7 +2477,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
if (def->rng &&
|
if (def->rng &&
|
||||||
def->rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO &&
|
def->rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO &&
|
||||||
def->rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
def->rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->rng->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs,
|
||||||
|
&def->rng->info, flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2470,7 +2486,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
if (def->watchdog &&
|
if (def->watchdog &&
|
||||||
def->watchdog->model != VIR_DOMAIN_WATCHDOG_MODEL_IB700 &&
|
def->watchdog->model != VIR_DOMAIN_WATCHDOG_MODEL_IB700 &&
|
||||||
def->watchdog->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
def->watchdog->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->watchdog->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2483,7 +2500,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
if (def->videos[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
|
if (def->videos[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
|
||||||
continue;
|
continue;
|
||||||
if (qemuDomainPCIAddressSetNextAddr(addrs, &def->videos[i]->info, flags) < 0)
|
if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
|
||||||
|
flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
for (i = 0; i < def->ninputs; i++) {
|
for (i = 0; i < def->ninputs; i++) {
|
||||||
|
@ -254,9 +254,9 @@ int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
|
|||||||
int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
|
int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||||
virDevicePCIAddressPtr addr,
|
virDevicePCIAddressPtr addr,
|
||||||
qemuDomainPCIConnectFlags flags);
|
qemuDomainPCIConnectFlags flags);
|
||||||
int qemuDomainPCIAddressSetNextAddr(qemuDomainPCIAddressSetPtr addrs,
|
int qemuDomainPCIAddressReserveNextSlot(qemuDomainPCIAddressSetPtr addrs,
|
||||||
virDomainDeviceInfoPtr dev,
|
virDomainDeviceInfoPtr dev,
|
||||||
qemuDomainPCIConnectFlags flags);
|
qemuDomainPCIConnectFlags flags);
|
||||||
int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
|
int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||||
virDomainDeviceInfoPtr dev);
|
virDomainDeviceInfoPtr dev);
|
||||||
int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
|
int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user