mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: add virDomainHasNet
virDomainNetFindIdx no longer returns info whether device was not found, or there was multiple matches. Additionally it already handle error reporting. Introduce virDomainHasNet which does a simple task, without implicit error reporting. Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
This commit is contained in:
parent
e1bfa03a83
commit
ed4db85a55
@ -12016,6 +12016,27 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net)
|
||||
return matchidx;
|
||||
}
|
||||
|
||||
bool
|
||||
virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net)
|
||||
{
|
||||
size_t i;
|
||||
bool PCIAddrSpecified = virDomainDeviceAddressIsValid(&net->info,
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI);
|
||||
|
||||
for (i = 0; i < def->nnets; i++) {
|
||||
if (virMacAddrCmp(&def->nets[i]->mac, &net->mac))
|
||||
continue;
|
||||
|
||||
if (PCIAddrSpecified) {
|
||||
if (virDevicePCIAddressEqual(&def->nets[i]->info.addr.pci,
|
||||
&net->info.addr.pci))
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
virDomainNetRemoveHostdev(virDomainDefPtr def,
|
||||
|
@ -2603,6 +2603,7 @@ bool virDomainHasDiskMirror(virDomainObjPtr vm);
|
||||
|
||||
int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
|
||||
virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
|
||||
bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net);
|
||||
int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net);
|
||||
virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i);
|
||||
void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net);
|
||||
|
@ -293,6 +293,7 @@ virDomainGraphicsTypeToString;
|
||||
virDomainGraphicsVNCSharePolicyTypeFromString;
|
||||
virDomainGraphicsVNCSharePolicyTypeToString;
|
||||
virDomainHasDiskMirror;
|
||||
virDomainHasNet;
|
||||
virDomainHostdevCapsTypeToString;
|
||||
virDomainHostdevDefAlloc;
|
||||
virDomainHostdevDefClear;
|
||||
|
Loading…
Reference in New Issue
Block a user