Allow NULL mac address in virGetInterface
There are places where an interface will not have a mac address, and netcf returns this as a NULL pointer rather than a pointer to an empty string. Rather than checking for this all over the place in libvirt, just save it in the virInterface object as an empty string. * src/datatypes.c: allow NULL mac in virGetInterface()
This commit is contained in:
parent
112ed8f50d
commit
4728bad403
@ -588,10 +588,15 @@ virInterfacePtr
|
|||||||
virGetInterface(virConnectPtr conn, const char *name, const char *mac) {
|
virGetInterface(virConnectPtr conn, const char *name, const char *mac) {
|
||||||
virInterfacePtr ret = NULL;
|
virInterfacePtr ret = NULL;
|
||||||
|
|
||||||
if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (mac == NULL)) {
|
if ((!VIR_IS_CONNECT(conn)) || (name == NULL)) {
|
||||||
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* a NULL mac from caller is okay. Treat it as blank */
|
||||||
|
if (mac == NULL)
|
||||||
|
mac = "";
|
||||||
|
|
||||||
virMutexLock(&conn->lock);
|
virMutexLock(&conn->lock);
|
||||||
|
|
||||||
ret = (virInterfacePtr) virHashLookup(conn->interfaces, name);
|
ret = (virInterfacePtr) virHashLookup(conn->interfaces, name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user