[PATCH 1/4] qemu: interface: add qemuDomainDefIsOvsport

zhangjl02 posted 4 patches 4 years, 7 months ago
There is a newer version of this series
[PATCH 1/4] qemu: interface: add qemuDomainDefIsOvsport
Posted by zhangjl02 4 years, 7 months ago
From: zhangjl02 <zhangjl02@inspur.com>

Tell whether a port definition is an ovs managed virtual port
---
 src/qemu/qemu_domain.c | 13 +++++++++++++
 src/qemu/qemu_domain.h |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index fc60e15eea..da5a226fc2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -11575,3 +11575,16 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg,
 
     return 0;
 }
+
+/*
+ * Check whether the port is an ovs managed port
+ */
+bool qemuDomainDefIsOvsport(virDomainNetDef *net,
+                         int actualType) {
+    const virNetDevVPortProfile *vport = virDomainNetGetActualVirtPortProfile(net);
+    if ((actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) && vport  &&
+        vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
+        return true;
+    }
+    return false;
+}
\ No newline at end of file
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index acf6ca5ab6..81a9bf0cfb 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1063,3 +1063,6 @@ int
 qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg,
                            const char *name,
                            bool bestEffort);
+
+bool qemuDomainDefIsOvsport(virDomainNetDef *net,
+        int actualType);
\ No newline at end of file
-- 
2.30.2.windows.1

Re: [PATCH 1/4] qemu: interface: add qemuDomainDefIsOvsport
Posted by Michal Prívozník 4 years, 7 months ago
On 6/28/21 11:18 AM, zhangjl02 wrote:
> From: zhangjl02 <zhangjl02@inspur.com>
> 
> Tell whether a port definition is an ovs managed virtual port
> ---
>  src/qemu/qemu_domain.c | 13 +++++++++++++
>  src/qemu/qemu_domain.h |  3 +++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index fc60e15eea..da5a226fc2 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -11575,3 +11575,16 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg,
>  
>      return 0;
>  }
> +
> +/*
> + * Check whether the port is an ovs managed port
> + */
> +bool qemuDomainDefIsOvsport(virDomainNetDef *net,
> +                         int actualType) {
> +    const virNetDevVPortProfile *vport = virDomainNetGetActualVirtPortProfile(net);
> +    if ((actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) && vport  &&
> +        vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
> +        return true;
> +    }
> +    return false;
> +}
> \ No newline at end of file
> diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
> index acf6ca5ab6..81a9bf0cfb 100644
> --- a/src/qemu/qemu_domain.h
> +++ b/src/qemu/qemu_domain.h
> @@ -1063,3 +1063,6 @@ int
>  qemuDomainNamePathsCleanup(virQEMUDriverConfig *cfg,
>                             const char *name,
>                             bool bestEffort);
> +
> +bool qemuDomainDefIsOvsport(virDomainNetDef *net,
> +        int actualType);
> \ No newline at end of file
> 

There's nothing QEMU specific in this function. I think it can go into
src/conf/domain_conf.c (somewhere near
virDomainNetGetActualVirtPortProfile() perhaps) and that check from the
function - we have a few places like it, those can be replaced with the
function call.

Michal