提交 ed4db85a 编写于 作者: M Marek Marczykowski-Górecki 提交者: Jim Fehlig

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: NMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
上级 e1bfa03a
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册