# HG changeset patch
# User john.levon(a)sun.com
# 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(a)sun.com>
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);
}