[libvirt] [PATCH] Use virMacAddrCompare() in xs_internal.c

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

 



# HG changeset patch
# User john.levon@xxxxxxx
# Date 1233800565 28800
# Node ID 379763c63798c9f0c426facb9b9b61e34e6477e2
# Parent  e6b17082b9b9440ce14ad76bd2f4c003ae2404db
Use virMacAddrCompare() in xs_internal.c

This solves a failure to look up a net device.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/src/xs_internal.c b/src/xs_internal.c
--- a/src/xs_internal.c
+++ b/src/xs_internal.c
@@ -915,7 +915,7 @@ char *
 char *
 xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
     char dir[80], path[128], **list = NULL, *val = NULL;
-    unsigned int maclen, len, i, num;
+    unsigned int len, i, num;
     char *ret = NULL;
     xenUnifiedPrivatePtr priv;
 
@@ -926,9 +926,6 @@ xenStoreDomainGetNetworkID(virConnectPtr
     if (priv->xshandle == NULL)
         return (NULL);
     if (mac == NULL)
-        return (NULL);
-    maclen = strlen(mac);
-    if (maclen <= 0)
         return (NULL);
 
     snprintf(dir, sizeof(dir), "/local/domain/0/backend/vif/%d", id);
@@ -937,18 +934,20 @@ xenStoreDomainGetNetworkID(virConnectPtr
         return(NULL);
     for (i = 0; i < num; i++) {
         snprintf(path, sizeof(path), "%s/%s/%s", dir, list[i], "mac");
-        val = xs_read(priv->xshandle, 0, path, &len);
-        if (val == NULL)
+        if ((val = xs_read(priv->xshandle, 0, path, &len)) == NULL)
             break;
-        if ((maclen != len) || memcmp(val, mac, len)) {
-            free(val);
-        } else {
+
+        if (virMacAddrCompare(val, mac) == 0) {
             ret = strdup(list[i]);
-            free(val);
-            break;
+            goto out;
         }
-    }
-    free(list);
+
+        VIR_FREE(val);
+    }
+
+out:
+    VIR_FREE(val);
+    VIR_FREE(list);
     return(ret);
 }
 

--
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]