提交 c246b025 编写于 作者: P Peter Krempa 提交者: Daniel Veillard

link-state: util: Add equality comparison functions for structures

This patch adds functions to compare structures containing network
device configuration for equality. They serve for the purpose of
disallowing unsupported changes to live network devices.
上级 9fd3bb7a
......@@ -842,6 +842,43 @@ error:
return ret;
}
bool
virVirtualPortProfileEqual(virVirtualPortProfileParamsPtr a, virVirtualPortProfileParamsPtr b)
{
/* NULL resistant */
if (!a && !b)
return true;
if (!a || !b)
return false;
if (a->virtPortType != b->virtPortType)
return false;
switch (a->virtPortType) {
case VIR_VIRTUALPORT_NONE:
break;
case VIR_VIRTUALPORT_8021QBG:
if (a->u.virtPort8021Qbg.managerID != b->u.virtPort8021Qbg.managerID ||
a->u.virtPort8021Qbg.typeID != b->u.virtPort8021Qbg.typeID ||
a->u.virtPort8021Qbg.typeIDVersion != b->u.virtPort8021Qbg.typeIDVersion ||
memcmp(a->u.virtPort8021Qbg.instanceID, b->u.virtPort8021Qbg.instanceID, VIR_UUID_BUFLEN) != 0)
return false;
break;
case VIR_VIRTUALPORT_8021QBH:
if (STRNEQ(a->u.virtPort8021Qbh.profileID, b->u.virtPort8021Qbh.profileID))
return false;
break;
default:
break;
}
return true;
}
void
virVirtualPortProfileFormat(virBufferPtr buf,
virVirtualPortProfileParamsPtr virtPort,
......@@ -1321,3 +1358,28 @@ cleanup:
}
return ret;
}
bool
virBandwidthEqual(virBandwidthPtr a,
virBandwidthPtr b)
{
if (!a && !b)
return true;
if (!a || !b)
return false;
/* in */
if (a->in->average != b->in->average ||
a->in->peak != b->in->peak ||
a->in->burst != b->in->burst)
return false;
/*out*/
if (a->out->average != b->out->average ||
a->out->peak != b->out->peak ||
a->out->burst != b->out->burst)
return false;
return true;
}
......@@ -150,6 +150,8 @@ virVirtualPortProfileFormat(virBufferPtr buf,
virVirtualPortProfileParamsPtr virtPort,
const char *indent);
bool virVirtualPortProfileEqual(virVirtualPortProfileParamsPtr a, virVirtualPortProfileParamsPtr b);
virBandwidthPtr virBandwidthDefParseNode(xmlNodePtr node);
void virBandwidthDefFree(virBandwidthPtr def);
int virBandwidthDefFormat(virBufferPtr buf,
......@@ -160,4 +162,7 @@ int virBandwidthEnable(virBandwidthPtr bandwidth, const char *iface);
int virBandwidthDisable(const char *iface, bool may_fail);
int virBandwidthCopy(virBandwidthPtr *dest, const virBandwidthPtr src);
bool virBandwidthEqual(virBandwidthPtr a, virBandwidthPtr b);
#endif /* __VIR_NETWORK_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册