diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ae8688e92d52a97de333f6f03326d8ecd6ad7df3..3d05844aa4d0e1fe7ea06326f9321a35b0554da3 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ea463cb8727df2f53e664ce8524aaec67bce8f98..f36315be5169e06aeb50bd06c31475be98337b0a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -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); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b5fe88cb940ce48bda471df5a53bdb99e405a776..63e378bf0a7acf59b4565bee2a5a82e115c2cde6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -293,6 +293,7 @@ virDomainGraphicsTypeToString; virDomainGraphicsVNCSharePolicyTypeFromString; virDomainGraphicsVNCSharePolicyTypeToString; virDomainHasDiskMirror; +virDomainHasNet; virDomainHostdevCapsTypeToString; virDomainHostdevDefAlloc; virDomainHostdevDefClear;