[libvirt] [PATCH v2 4/4] conf: add error checking of UUID generation

Daniel P. Berrangé berrange at redhat.com
Tue Jun 18 17:39:21 UTC 2019


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

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ee651e7742..c69d382d70 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30415,7 +30415,11 @@ virDomainNetDefToNetworkPort(virDomainDefPtr dom,
     if (VIR_ALLOC(port) < 0)
         return NULL;
 
-    virUUIDGenerate(port->uuid);
+    if (virUUIDGenerate(port->uuid) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("Failed to generate UUID"));
+        goto error;
+    }
 
     memcpy(port->owneruuid, dom->uuid, VIR_UUID_BUFLEN);
     if (VIR_STRDUP(port->ownername, dom->name) < 0)
@@ -30576,7 +30580,11 @@ virDomainNetDefActualToNetworkPort(virDomainDefPtr dom,
         return NULL;
 
     /* Bad - we need to preserve original port uuid */
-    virUUIDGenerate(port->uuid);
+    if (virUUIDGenerate(port->uuid) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("Failed to generate UUID"));
+        goto error;
+    }
 
     memcpy(port->owneruuid, dom->uuid, VIR_UUID_BUFLEN);
     if (VIR_STRDUP(port->ownername, dom->name) < 0)
-- 
2.21.0




More information about the libvir-list mailing list