[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 3/5] virDomainNetDefParseXML: suppress generation of MAC when VIR_DOMAIN_PARSE_NO_GENERATE is set



---
 src/conf/domain_conf.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c2c7057..7f9c178 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2491,8 +2491,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
     xmlNodePtr oldnode = ctxt->node;
     int ret;
 
-    if ((VIR_ALLOC(def) < 0) ||
-        (VIR_ALLOC_N(def->mac,VIR_MAC_BUFLEN) < 0)) {
+    if (VIR_ALLOC(def) < 0) {
         virReportOOMError();
         return NULL;
     }
@@ -2588,6 +2587,12 @@ virDomainNetDefParseXML(virCapsPtr caps,
         cur = cur->next;
     }
 
+    if ((macaddr || !(flags & VIR_DOMAIN_PARSE_NO_GENERATE)) &&
+        (VIR_ALLOC_N(def->mac, VIR_MAC_BUFLEN) < 0)) {
+        virReportOOMError();
+        goto error;
+    }
+
     if (macaddr) {
         if (virParseMacAddr((const char *)macaddr, def->mac) < 0) {
             virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2595,7 +2600,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
                                  (const char *)macaddr);
             goto error;
         }
-    } else {
+    } else if (!(flags & VIR_DOMAIN_PARSE_NO_GENERATE)) {
         virCapabilitiesGenerateMac(caps, def->mac);
     }
 
-- 
1.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]