From: zhangjl02 <zhangjl02(a)inspur.com>
Tell whether a port definition is an ovs managed virtual port
---
diff to v2:
- Delete actualType argument, get it in function.
- Format code.
Thanks to Michal Privoznik's advice.
---
src/conf/domain_conf.c | 11 +++++++++++
src/conf/domain_conf.h | 2 ++
src/libvirt_private.syms | 1 +
3 files changed, 14 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 04c10df0a9..5a27cd9d7d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29126,6 +29126,17 @@ virDomainNetGetActualVirtPortProfile(const virDomainNetDef
*iface)
}
}
+/* Check whether the port is an ovs managed port */
+bool
+virDomainNetDefIsOvsport(const virDomainNetDef *net)
+{
+ const virNetDevVPortProfile *vport = virDomainNetGetActualVirtPortProfile(net);
+ virDomainNetType actualType = virDomainNetGetActualType(net);
+
+ return (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) && vport &&
+ vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH;
+}
+
const virNetDevBandwidth *
virDomainNetGetActualBandwidth(const virDomainNetDef *iface)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4d9d499b16..2a36c5acf1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3610,6 +3610,8 @@ int virDomainNetGetActualDirectMode(const virDomainNetDef *iface);
virDomainHostdevDef *virDomainNetGetActualHostdev(virDomainNetDef *iface);
const virNetDevVPortProfile *
virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface);
+bool
+virDomainNetDefIsOvsport(const virDomainNetDef *net);
const virNetDevBandwidth *
virDomainNetGetActualBandwidth(const virDomainNetDef *iface);
const virNetDevVlan *virDomainNetGetActualVlan(const virDomainNetDef *iface);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 43e6398ae5..110b243e28 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -518,6 +518,7 @@ virDomainNetDefActualFromNetworkPort;
virDomainNetDefActualToNetworkPort;
virDomainNetDefFormat;
virDomainNetDefFree;
+virDomainNetDefIsOvsport;
virDomainNetDefNew;
virDomainNetDefToNetworkPort;
virDomainNetDHCPInterfaces;
--
2.30.2.windows.1