mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
conf: fix virDevicePCIAddressEqual args
This function really should have been taking virDevicePCIAddress* instead of the inefficient virDevicePCIAddress (results in copying two entire structs onto the stack rather than just two pointers), and returning a bool true/false (not matching is not necessarily a "failure", as a -1 return would imply, and also using "if (!virDevicePCIAddressEqual(x, y))" to mean "if x == y" is just a bit counterintuitive).
This commit is contained in:
parent
a2b80edbc6
commit
310945597c
@ -130,18 +130,15 @@ virDevicePCIAddressFormat(virBufferPtr buf,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
bool
|
||||||
virDevicePCIAddressEqual(virDevicePCIAddress addr1,
|
virDevicePCIAddressEqual(virDevicePCIAddress *addr1,
|
||||||
virDevicePCIAddress addr2)
|
virDevicePCIAddress *addr2)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
if (addr1->domain == addr2->domain &&
|
||||||
|
addr1->bus == addr2->bus &&
|
||||||
if (addr1.domain == addr2.domain &&
|
addr1->slot == addr2->slot &&
|
||||||
addr1.bus == addr2.bus &&
|
addr1->function == addr2->function) {
|
||||||
addr1.slot == addr2.slot &&
|
return true;
|
||||||
addr1.function == addr2.function) {
|
|
||||||
ret = 0;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ int virDevicePCIAddressFormat(virBufferPtr buf,
|
|||||||
virDevicePCIAddress addr,
|
virDevicePCIAddress addr,
|
||||||
bool includeTypeInAddr);
|
bool includeTypeInAddr);
|
||||||
|
|
||||||
int virDevicePCIAddressEqual(virDevicePCIAddress addr1,
|
bool virDevicePCIAddressEqual(virDevicePCIAddress *addr1,
|
||||||
virDevicePCIAddress addr2);
|
virDevicePCIAddress *addr2);
|
||||||
|
|
||||||
|
|
||||||
VIR_ENUM_DECL(virDeviceAddressPciMulti)
|
VIR_ENUM_DECL(virDeviceAddressPciMulti)
|
||||||
|
@ -3820,8 +3820,8 @@ networkNotifyActualDevice(virDomainNetDefPtr iface)
|
|||||||
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
|
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
|
||||||
if (netdef->forwardIfs[ii].type
|
if (netdef->forwardIfs[ii].type
|
||||||
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
|
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
|
||||||
(virDevicePCIAddressEqual(hostdev->source.subsys.u.pci,
|
virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci,
|
||||||
netdef->forwardIfs[ii].device.pci) == 0)) {
|
&netdef->forwardIfs[ii].device.pci)) {
|
||||||
dev = &netdef->forwardIfs[ii];
|
dev = &netdef->forwardIfs[ii];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3972,8 +3972,8 @@ networkReleaseActualDevice(virDomainNetDefPtr iface)
|
|||||||
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
|
for (ii = 0; ii < netdef->nForwardIfs; ii++) {
|
||||||
if (netdef->forwardIfs[ii].type
|
if (netdef->forwardIfs[ii].type
|
||||||
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
|
== VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI &&
|
||||||
(virDevicePCIAddressEqual(hostdev->source.subsys.u.pci,
|
virDevicePCIAddressEqual(&hostdev->source.subsys.u.pci,
|
||||||
netdef->forwardIfs[ii].device.pci) == 0)) {
|
&netdef->forwardIfs[ii].device.pci)) {
|
||||||
dev = &netdef->forwardIfs[ii];
|
dev = &netdef->forwardIfs[ii];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user