[libvirt] [PATCH] conf: avoid looking up network port that doesn't exist

Daniel P. Berrangé posted 1 patch 4 years, 7 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190912132418.7124-1-berrange@redhat.com
src/conf/domain_conf.c | 6 ++++++
1 file changed, 6 insertions(+)
[libvirt] [PATCH] conf: avoid looking up network port that doesn't exist
Posted by Daniel P. Berrangé 4 years, 7 months ago
If the hypervisor driver has not yet created the network port, the
portid field will be "00000000-0000-0000-0000-000000000000".

If a failure occurs during early VM startup, the hypervisor driver may
none the less try to release the network port, resulting in an
undesirable warning:

2019-09-12 13:17:42.349+0000: 16544: error :
virNetworkObjLookupPort:1679 : network port not found: Network port with
UUID 00000000-0000-0000-0000-000000000000 does not exist

By checking if the portid UUID is valid, we can avoid polluting the logs
in this way.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 src/conf/domain_conf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3dc638f0de..b1f8a13319 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30994,6 +30994,12 @@ virDomainNetReleaseActualDevice(virConnectPtr conn,
     virNetworkPortPtr port = NULL;
     int ret = -1;
 
+    /* Port might not exist if a failure occurred during VM startup */
+    if (!virUUIDIsValid(iface->data.network.portid)) {
+        ret = 0;
+        goto cleanup;
+    }
+
     if (!(net = virNetworkLookupByName(conn, iface->data.network.name)))
         goto cleanup;
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: avoid looking up network port that doesn't exist
Posted by Michal Privoznik 4 years, 7 months ago
On 9/12/19 3:24 PM, Daniel P. Berrangé wrote:
> If the hypervisor driver has not yet created the network port, the
> portid field will be "00000000-0000-0000-0000-000000000000".
> 
> If a failure occurs during early VM startup, the hypervisor driver may
> none the less try to release the network port, resulting in an
> undesirable warning:
> 
> 2019-09-12 13:17:42.349+0000: 16544: error :
> virNetworkObjLookupPort:1679 : network port not found: Network port with
> UUID 00000000-0000-0000-0000-000000000000 does not exist
> 
> By checking if the portid UUID is valid, we can avoid polluting the logs
> in this way.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   src/conf/domain_conf.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list