[PATCH] xenapi: Convert to virMacAddr

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

 



---
Can't we just get rid of this horrific and mostly unmaintained xenapi code
completely? :-)

 src/xenapi/xenapi_driver.c |  3 ++-
 src/xenapi/xenapi_utils.c  | 36 ++++++++++++++----------------------
 2 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 298ab21..a91f497 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1512,7 +1512,8 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
             }
             xen_vif_get_record(session, &vif_rec, vif);
             if (vif_rec != NULL) {
-                if (virMacAddrParse((const char *)vif_rec->mac,defPtr->nets[i]->mac) < 0)
+                if (virMacAddrParse((const char *)vif_rec->mac,
+                                    &defPtr->nets[i]->mac) < 0)
                     xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,
                                               _("Unable to parse given mac address"));
                 xen_vif_record_free(vif_rec);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index e5a9cc5..c8b12de 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -453,7 +453,6 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
     char uuidStr[VIR_UUID_STRING_BUFLEN];
     xen_string_string_map *strings = NULL;
     int device_number = 0;
-    char *bridge = NULL, *mac = NULL;
     int i;
 
     *record = xen_vm_record_alloc();
@@ -542,28 +541,21 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
     }
 
     for (i = 0; i < def->nnets; i++) {
-        if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
-            if (def->nets[i]->data.bridge.brname)
-                if (!(bridge = strdup(def->nets[i]->data.bridge.brname)))
-                    goto error_cleanup;
-            if (def->nets[i]->mac) {
-                char macStr[VIR_MAC_STRING_BUFLEN];
-                virMacAddrFormat(def->nets[i]->mac, macStr);
-                if (!(mac = strdup(macStr))) {
-                    VIR_FREE(bridge);
-                    goto error_cleanup;
-                }
-            }
-            if (mac != NULL && bridge != NULL) {
-                if (createVifNetwork(conn, *vm, device_number, bridge,
-                                     mac) < 0) {
-                    VIR_FREE(bridge);
-                    goto error_cleanup;
-                }
-                VIR_FREE(bridge);
-                device_number++;
+        if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE &&
+            def->nets[i]->data.bridge.brname) {
+            char *mac;
+
+            if (VIR_ALLOC_N(mac, VIR_MAC_STRING_BUFLEN) < 0)
+                goto error_cleanup;
+            virMacAddrFormat(&def->nets[i]->mac, mac);
+
+            if (createVifNetwork(conn, *vm, device_number,
+                                 def->nets[i]->data.bridge.brname,
+                                 mac) < 0) {
+                VIR_FREE(mac);
+                goto error_cleanup;
             }
-            VIR_FREE(bridge);
+            device_number++;
         }
     }
     return 0;
-- 
1.7.11.1

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]