mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
interface: Make _virInterfaceObj struct private
Move the struct into virinterfaceobj.c, create necessary accessors, and initializers. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
4939f0b25d
commit
3b6de6c0cb
@ -32,6 +32,12 @@
|
|||||||
|
|
||||||
VIR_LOG_INIT("conf.virinterfaceobj");
|
VIR_LOG_INIT("conf.virinterfaceobj");
|
||||||
|
|
||||||
|
struct _virInterfaceObj {
|
||||||
|
virMutex lock;
|
||||||
|
|
||||||
|
bool active; /* true if interface is active (up) */
|
||||||
|
virInterfaceDefPtr def; /* The interface definition */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* virInterfaceObj manipulation */
|
/* virInterfaceObj manipulation */
|
||||||
@ -62,6 +68,28 @@ virInterfaceObjFree(virInterfaceObjPtr obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virInterfaceDefPtr
|
||||||
|
virInterfaceObjGetDef(virInterfaceObjPtr obj)
|
||||||
|
{
|
||||||
|
return obj->def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
virInterfaceObjIsActive(virInterfaceObjPtr obj)
|
||||||
|
{
|
||||||
|
return obj->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virInterfaceObjSetActive(virInterfaceObjPtr obj,
|
||||||
|
bool active)
|
||||||
|
{
|
||||||
|
obj->active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virInterfaceObjList manipulation */
|
/* virInterfaceObjList manipulation */
|
||||||
int
|
int
|
||||||
virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
|
virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
|
||||||
|
@ -24,12 +24,6 @@
|
|||||||
|
|
||||||
typedef struct _virInterfaceObj virInterfaceObj;
|
typedef struct _virInterfaceObj virInterfaceObj;
|
||||||
typedef virInterfaceObj *virInterfaceObjPtr;
|
typedef virInterfaceObj *virInterfaceObjPtr;
|
||||||
struct _virInterfaceObj {
|
|
||||||
virMutex lock;
|
|
||||||
|
|
||||||
bool active; /* true if interface is active (up) */
|
|
||||||
virInterfaceDefPtr def; /* The interface definition */
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct _virInterfaceObjList virInterfaceObjList;
|
typedef struct _virInterfaceObjList virInterfaceObjList;
|
||||||
typedef virInterfaceObjList *virInterfaceObjListPtr;
|
typedef virInterfaceObjList *virInterfaceObjListPtr;
|
||||||
@ -38,11 +32,15 @@ struct _virInterfaceObjList {
|
|||||||
virInterfaceObjPtr *objs;
|
virInterfaceObjPtr *objs;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool
|
virInterfaceDefPtr
|
||||||
virInterfaceObjIsActive(const virInterfaceObj *iface)
|
virInterfaceObjGetDef(virInterfaceObjPtr obj);
|
||||||
{
|
|
||||||
return iface->active;
|
bool
|
||||||
}
|
virInterfaceObjIsActive(virInterfaceObjPtr obj);
|
||||||
|
|
||||||
|
void
|
||||||
|
virInterfaceObjSetActive(virInterfaceObjPtr obj,
|
||||||
|
bool active);
|
||||||
|
|
||||||
int
|
int
|
||||||
virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
|
virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
|
||||||
|
@ -913,12 +913,15 @@ virDomainObjListRename;
|
|||||||
virInterfaceObjAssignDef;
|
virInterfaceObjAssignDef;
|
||||||
virInterfaceObjFindByMACString;
|
virInterfaceObjFindByMACString;
|
||||||
virInterfaceObjFindByName;
|
virInterfaceObjFindByName;
|
||||||
|
virInterfaceObjGetDef;
|
||||||
virInterfaceObjGetNames;
|
virInterfaceObjGetNames;
|
||||||
|
virInterfaceObjIsActive;
|
||||||
virInterfaceObjListClone;
|
virInterfaceObjListClone;
|
||||||
virInterfaceObjListFree;
|
virInterfaceObjListFree;
|
||||||
virInterfaceObjLock;
|
virInterfaceObjLock;
|
||||||
virInterfaceObjNumOfInterfaces;
|
virInterfaceObjNumOfInterfaces;
|
||||||
virInterfaceObjRemove;
|
virInterfaceObjRemove;
|
||||||
|
virInterfaceObjSetActive;
|
||||||
virInterfaceObjUnlock;
|
virInterfaceObjUnlock;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1025,7 +1025,7 @@ testParseInterfaces(testDriverPtr privconn,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->active = 1;
|
virInterfaceObjSetActive(obj, true);
|
||||||
virInterfaceObjUnlock(obj);
|
virInterfaceObjUnlock(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3711,7 +3711,7 @@ testInterfaceLookupByName(virConnectPtr conn,
|
|||||||
|
|
||||||
if (!(obj = testInterfaceObjFindByName(privconn, name)))
|
if (!(obj = testInterfaceObjFindByName(privconn, name)))
|
||||||
return NULL;
|
return NULL;
|
||||||
def = obj->def;
|
def = virInterfaceObjGetDef(obj);
|
||||||
|
|
||||||
ret = virGetInterface(conn, def->name, def->mac);
|
ret = virGetInterface(conn, def->name, def->mac);
|
||||||
|
|
||||||
@ -3744,7 +3744,7 @@ testInterfaceLookupByMACString(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
def = obj->def;
|
def = virInterfaceObjGetDef(obj);
|
||||||
ret = virGetInterface(conn, def->name, def->mac);
|
ret = virGetInterface(conn, def->name, def->mac);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -3870,14 +3870,16 @@ testInterfaceGetXMLDesc(virInterfacePtr iface,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = iface->conn->privateData;
|
testDriverPtr privconn = iface->conn->privateData;
|
||||||
virInterfaceObjPtr obj;
|
virInterfaceObjPtr obj;
|
||||||
|
virInterfaceDefPtr def;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
def = virInterfaceObjGetDef(obj);
|
||||||
|
|
||||||
ret = virInterfaceDefFormat(obj->def);
|
ret = virInterfaceDefFormat(def);
|
||||||
|
|
||||||
virInterfaceObjUnlock(obj);
|
virInterfaceObjUnlock(obj);
|
||||||
return ret;
|
return ret;
|
||||||
@ -3904,7 +3906,7 @@ testInterfaceDefineXML(virConnectPtr conn,
|
|||||||
if ((obj = virInterfaceObjAssignDef(&privconn->ifaces, def)) == NULL)
|
if ((obj = virInterfaceObjAssignDef(&privconn->ifaces, def)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
def = NULL;
|
||||||
objdef = obj->def;
|
objdef = virInterfaceObjGetDef(obj);
|
||||||
|
|
||||||
ret = virGetInterface(conn, objdef->name, objdef->mac);
|
ret = virGetInterface(conn, objdef->name, objdef->mac);
|
||||||
|
|
||||||
@ -3945,12 +3947,12 @@ testInterfaceCreate(virInterfacePtr iface,
|
|||||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (obj->active != 0) {
|
if (virInterfaceObjIsActive(obj)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->active = 1;
|
virInterfaceObjSetActive(obj, true);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -3972,12 +3974,12 @@ testInterfaceDestroy(virInterfacePtr iface,
|
|||||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (obj->active == 0) {
|
if (!virInterfaceObjIsActive(obj)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj->active = 0;
|
virInterfaceObjSetActive(obj, false);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user