mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +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");
|
||||
|
||||
struct _virInterfaceObj {
|
||||
virMutex lock;
|
||||
|
||||
bool active; /* true if interface is active (up) */
|
||||
virInterfaceDefPtr def; /* The interface definition */
|
||||
};
|
||||
|
||||
|
||||
/* 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 */
|
||||
int
|
||||
virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
|
||||
|
@ -24,12 +24,6 @@
|
||||
|
||||
typedef struct _virInterfaceObj virInterfaceObj;
|
||||
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 virInterfaceObjList *virInterfaceObjListPtr;
|
||||
@ -38,11 +32,15 @@ struct _virInterfaceObjList {
|
||||
virInterfaceObjPtr *objs;
|
||||
};
|
||||
|
||||
static inline bool
|
||||
virInterfaceObjIsActive(const virInterfaceObj *iface)
|
||||
{
|
||||
return iface->active;
|
||||
}
|
||||
virInterfaceDefPtr
|
||||
virInterfaceObjGetDef(virInterfaceObjPtr obj);
|
||||
|
||||
bool
|
||||
virInterfaceObjIsActive(virInterfaceObjPtr obj);
|
||||
|
||||
void
|
||||
virInterfaceObjSetActive(virInterfaceObjPtr obj,
|
||||
bool active);
|
||||
|
||||
int
|
||||
virInterfaceObjFindByMACString(virInterfaceObjListPtr interfaces,
|
||||
|
@ -913,12 +913,15 @@ virDomainObjListRename;
|
||||
virInterfaceObjAssignDef;
|
||||
virInterfaceObjFindByMACString;
|
||||
virInterfaceObjFindByName;
|
||||
virInterfaceObjGetDef;
|
||||
virInterfaceObjGetNames;
|
||||
virInterfaceObjIsActive;
|
||||
virInterfaceObjListClone;
|
||||
virInterfaceObjListFree;
|
||||
virInterfaceObjLock;
|
||||
virInterfaceObjNumOfInterfaces;
|
||||
virInterfaceObjRemove;
|
||||
virInterfaceObjSetActive;
|
||||
virInterfaceObjUnlock;
|
||||
|
||||
|
||||
|
@ -1025,7 +1025,7 @@ testParseInterfaces(testDriverPtr privconn,
|
||||
goto error;
|
||||
}
|
||||
|
||||
obj->active = 1;
|
||||
virInterfaceObjSetActive(obj, true);
|
||||
virInterfaceObjUnlock(obj);
|
||||
}
|
||||
|
||||
@ -3711,7 +3711,7 @@ testInterfaceLookupByName(virConnectPtr conn,
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, name)))
|
||||
return NULL;
|
||||
def = obj->def;
|
||||
def = virInterfaceObjGetDef(obj);
|
||||
|
||||
ret = virGetInterface(conn, def->name, def->mac);
|
||||
|
||||
@ -3744,7 +3744,7 @@ testInterfaceLookupByMACString(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
def = obj->def;
|
||||
def = virInterfaceObjGetDef(obj);
|
||||
ret = virGetInterface(conn, def->name, def->mac);
|
||||
|
||||
cleanup:
|
||||
@ -3870,14 +3870,16 @@ testInterfaceGetXMLDesc(virInterfacePtr iface,
|
||||
{
|
||||
testDriverPtr privconn = iface->conn->privateData;
|
||||
virInterfaceObjPtr obj;
|
||||
virInterfaceDefPtr def;
|
||||
char *ret = NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
return NULL;
|
||||
def = virInterfaceObjGetDef(obj);
|
||||
|
||||
ret = virInterfaceDefFormat(obj->def);
|
||||
ret = virInterfaceDefFormat(def);
|
||||
|
||||
virInterfaceObjUnlock(obj);
|
||||
return ret;
|
||||
@ -3904,7 +3906,7 @@ testInterfaceDefineXML(virConnectPtr conn,
|
||||
if ((obj = virInterfaceObjAssignDef(&privconn->ifaces, def)) == NULL)
|
||||
goto cleanup;
|
||||
def = NULL;
|
||||
objdef = obj->def;
|
||||
objdef = virInterfaceObjGetDef(obj);
|
||||
|
||||
ret = virGetInterface(conn, objdef->name, objdef->mac);
|
||||
|
||||
@ -3945,12 +3947,12 @@ testInterfaceCreate(virInterfacePtr iface,
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
return -1;
|
||||
|
||||
if (obj->active != 0) {
|
||||
if (virInterfaceObjIsActive(obj)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
obj->active = 1;
|
||||
virInterfaceObjSetActive(obj, true);
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
@ -3972,12 +3974,12 @@ testInterfaceDestroy(virInterfacePtr iface,
|
||||
if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
|
||||
return -1;
|
||||
|
||||
if (obj->active == 0) {
|
||||
if (!virInterfaceObjIsActive(obj)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
obj->active = 0;
|
||||
virInterfaceObjSetActive(obj, false);
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
|
Loading…
Reference in New Issue
Block a user