mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-29 17:33:09 +00:00
xenstore: Use virMacAddrCompare() for case-insensitive comparison
This commit is contained in:
parent
b8b4fd4c7d
commit
003f354917
@ -1,3 +1,8 @@
|
|||||||
|
Thu Feb 5 18:08:39 GMT 2009 John Levon <john.levon@sun.com>
|
||||||
|
|
||||||
|
* src/xs_internal.c: Use virMacAddrCompare() for
|
||||||
|
case-insensitive comparison
|
||||||
|
|
||||||
Thu Feb 5 17:19:24 GMT 2009 John Levon <john.levon@sun.com>
|
Thu Feb 5 17:19:24 GMT 2009 John Levon <john.levon@sun.com>
|
||||||
|
|
||||||
* src/xend_internal.c: report error for some xend operations on
|
* src/xend_internal.c: report error for some xend operations on
|
||||||
|
@ -915,7 +915,7 @@ xenStoreDomainGetOSTypeID(virConnectPtr conn, int id) {
|
|||||||
char *
|
char *
|
||||||
xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
|
xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
|
||||||
char dir[80], path[128], **list = NULL, *val = NULL;
|
char dir[80], path[128], **list = NULL, *val = NULL;
|
||||||
unsigned int maclen, len, i, num;
|
unsigned int len, i, num;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
xenUnifiedPrivatePtr priv;
|
xenUnifiedPrivatePtr priv;
|
||||||
|
|
||||||
@ -927,9 +927,6 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
if (mac == NULL)
|
if (mac == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
maclen = strlen(mac);
|
|
||||||
if (maclen <= 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
snprintf(dir, sizeof(dir), "/local/domain/0/backend/vif/%d", id);
|
snprintf(dir, sizeof(dir), "/local/domain/0/backend/vif/%d", id);
|
||||||
list = xs_directory(priv->xshandle, 0, dir, &num);
|
list = xs_directory(priv->xshandle, 0, dir, &num);
|
||||||
@ -937,18 +934,20 @@ xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
snprintf(path, sizeof(path), "%s/%s/%s", dir, list[i], "mac");
|
snprintf(path, sizeof(path), "%s/%s/%s", dir, list[i], "mac");
|
||||||
val = xs_read(priv->xshandle, 0, path, &len);
|
if ((val = xs_read(priv->xshandle, 0, path, &len)) == NULL)
|
||||||
if (val == NULL)
|
|
||||||
break;
|
break;
|
||||||
if ((maclen != len) || memcmp(val, mac, len)) {
|
|
||||||
free(val);
|
bool match = (virMacAddrCompare(val, mac) == 0);
|
||||||
} else {
|
|
||||||
|
VIR_FREE(val);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
ret = strdup(list[i]);
|
ret = strdup(list[i]);
|
||||||
free(val);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(list);
|
|
||||||
|
VIR_FREE(list);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user