mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-13 16:15:19 +00:00
network: Add virNetworkObj Get/Set API's for @def and @newDef
In preparation for making the object private, create a couple of API's to get the obj->def & obj->newDef and set the obj->def. While altering networkxml2conftest.c to use the virNetworkObjSetDef API, fix the name of the variable from @dev to @def Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
062c38ce75
commit
db207a6233
@ -107,6 +107,28 @@ virNetworkObjEndAPI(virNetworkObjPtr *net)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virNetworkDefPtr
|
||||||
|
virNetworkObjGetDef(virNetworkObjPtr obj)
|
||||||
|
{
|
||||||
|
return obj->def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virNetworkObjSetDef(virNetworkObjPtr obj,
|
||||||
|
virNetworkDefPtr def)
|
||||||
|
{
|
||||||
|
obj->def = def;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virNetworkDefPtr
|
||||||
|
virNetworkObjGetNewDef(virNetworkObjPtr obj)
|
||||||
|
{
|
||||||
|
return obj->newDef;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
virNetworkObjGetDnsmasqPid(virNetworkObjPtr obj)
|
virNetworkObjGetDnsmasqPid(virNetworkObjPtr obj)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +50,16 @@ struct _virNetworkObj {
|
|||||||
virNetworkObjPtr
|
virNetworkObjPtr
|
||||||
virNetworkObjNew(void);
|
virNetworkObjNew(void);
|
||||||
|
|
||||||
|
virNetworkDefPtr
|
||||||
|
virNetworkObjGetDef(virNetworkObjPtr obj);
|
||||||
|
|
||||||
|
void
|
||||||
|
virNetworkObjSetDef(virNetworkObjPtr obj,
|
||||||
|
virNetworkDefPtr def);
|
||||||
|
|
||||||
|
virNetworkDefPtr
|
||||||
|
virNetworkObjGetNewDef(virNetworkObjPtr obj);
|
||||||
|
|
||||||
virMacMapPtr
|
virMacMapPtr
|
||||||
virNetworkObjGetMacMap(virNetworkObjPtr obj);
|
virNetworkObjGetMacMap(virNetworkObjPtr obj);
|
||||||
|
|
||||||
|
@ -943,9 +943,11 @@ virNetworkObjEndAPI;
|
|||||||
virNetworkObjFindByName;
|
virNetworkObjFindByName;
|
||||||
virNetworkObjFindByUUID;
|
virNetworkObjFindByUUID;
|
||||||
virNetworkObjGetClassIdMap;
|
virNetworkObjGetClassIdMap;
|
||||||
|
virNetworkObjGetDef;
|
||||||
virNetworkObjGetDnsmasqPid;
|
virNetworkObjGetDnsmasqPid;
|
||||||
virNetworkObjGetFloorSum;
|
virNetworkObjGetFloorSum;
|
||||||
virNetworkObjGetMacMap;
|
virNetworkObjGetMacMap;
|
||||||
|
virNetworkObjGetNewDef;
|
||||||
virNetworkObjGetPersistentDef;
|
virNetworkObjGetPersistentDef;
|
||||||
virNetworkObjGetRadvdPid;
|
virNetworkObjGetRadvdPid;
|
||||||
virNetworkObjListExport;
|
virNetworkObjListExport;
|
||||||
@ -962,6 +964,7 @@ virNetworkObjNew;
|
|||||||
virNetworkObjRemoveInactive;
|
virNetworkObjRemoveInactive;
|
||||||
virNetworkObjReplacePersistentDef;
|
virNetworkObjReplacePersistentDef;
|
||||||
virNetworkObjSaveStatus;
|
virNetworkObjSaveStatus;
|
||||||
|
virNetworkObjSetDef;
|
||||||
virNetworkObjSetDefTransient;
|
virNetworkObjSetDefTransient;
|
||||||
virNetworkObjSetDnsmasqPid;
|
virNetworkObjSetDnsmasqPid;
|
||||||
virNetworkObjSetFloorSum;
|
virNetworkObjSetFloorSum;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3233,12 +3233,14 @@ testNetworkLookupByUUID(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
|
virNetworkDefPtr def;
|
||||||
virNetworkPtr net = NULL;
|
virNetworkPtr net = NULL;
|
||||||
|
|
||||||
if (!(obj = testNetworkObjFindByUUID(privconn, uuid)))
|
if (!(obj = testNetworkObjFindByUUID(privconn, uuid)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
def = virNetworkObjGetDef(obj);
|
||||||
|
|
||||||
net = virGetNetwork(conn, obj->def->name, obj->def->uuid);
|
net = virGetNetwork(conn, def->name, def->uuid);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNetworkObjEndAPI(&obj);
|
virNetworkObjEndAPI(&obj);
|
||||||
@ -3267,12 +3269,14 @@ testNetworkLookupByName(virConnectPtr conn,
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
|
virNetworkDefPtr def;
|
||||||
virNetworkPtr net = NULL;
|
virNetworkPtr net = NULL;
|
||||||
|
|
||||||
if (!(obj = testNetworkObjFindByName(privconn, name)))
|
if (!(obj = testNetworkObjFindByName(privconn, name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
def = virNetworkObjGetDef(obj);
|
||||||
|
|
||||||
net = virGetNetwork(conn, obj->def->name, obj->def->uuid);
|
net = virGetNetwork(conn, def->name, def->uuid);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNetworkObjEndAPI(&obj);
|
virNetworkObjEndAPI(&obj);
|
||||||
@ -3385,29 +3389,31 @@ static virNetworkPtr
|
|||||||
testNetworkCreateXML(virConnectPtr conn, const char *xml)
|
testNetworkCreateXML(virConnectPtr conn, const char *xml)
|
||||||
{
|
{
|
||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
virNetworkDefPtr def;
|
virNetworkDefPtr newDef;
|
||||||
virNetworkObjPtr obj = NULL;
|
virNetworkObjPtr obj = NULL;
|
||||||
|
virNetworkDefPtr def;
|
||||||
virNetworkPtr net = NULL;
|
virNetworkPtr net = NULL;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
if ((def = virNetworkDefParseString(xml)) == NULL)
|
if ((newDef = virNetworkDefParseString(xml)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(obj = virNetworkObjAssignDef(privconn->networks, def,
|
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef,
|
||||||
VIR_NETWORK_OBJ_LIST_ADD_LIVE |
|
VIR_NETWORK_OBJ_LIST_ADD_LIVE |
|
||||||
VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE)))
|
VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
newDef = NULL;
|
||||||
|
def = virNetworkObjGetDef(obj);
|
||||||
obj->active = 1;
|
obj->active = 1;
|
||||||
|
|
||||||
event = virNetworkEventLifecycleNew(obj->def->name, obj->def->uuid,
|
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||||
VIR_NETWORK_EVENT_STARTED,
|
VIR_NETWORK_EVENT_STARTED,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
net = virGetNetwork(conn, obj->def->name, obj->def->uuid);
|
net = virGetNetwork(conn, def->name, def->uuid);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNetworkDefFree(def);
|
virNetworkDefFree(newDef);
|
||||||
testObjectEventQueue(privconn, event);
|
testObjectEventQueue(privconn, event);
|
||||||
virNetworkObjEndAPI(&obj);
|
virNetworkObjEndAPI(&obj);
|
||||||
return net;
|
return net;
|
||||||
@ -3419,26 +3425,28 @@ testNetworkDefineXML(virConnectPtr conn,
|
|||||||
const char *xml)
|
const char *xml)
|
||||||
{
|
{
|
||||||
testDriverPtr privconn = conn->privateData;
|
testDriverPtr privconn = conn->privateData;
|
||||||
virNetworkDefPtr def;
|
virNetworkDefPtr newDef;
|
||||||
virNetworkObjPtr obj = NULL;
|
virNetworkObjPtr obj = NULL;
|
||||||
|
virNetworkDefPtr def;
|
||||||
virNetworkPtr net = NULL;
|
virNetworkPtr net = NULL;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
if ((def = virNetworkDefParseString(xml)) == NULL)
|
if ((newDef = virNetworkDefParseString(xml)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(obj = virNetworkObjAssignDef(privconn->networks, def, 0)))
|
if (!(obj = virNetworkObjAssignDef(privconn->networks, newDef, 0)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
newDef = NULL;
|
||||||
|
def = virNetworkObjGetDef(obj);
|
||||||
|
|
||||||
event = virNetworkEventLifecycleNew(obj->def->name, obj->def->uuid,
|
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||||
VIR_NETWORK_EVENT_DEFINED,
|
VIR_NETWORK_EVENT_DEFINED,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
net = virGetNetwork(conn, obj->def->name, obj->def->uuid);
|
net = virGetNetwork(conn, def->name, def->uuid);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNetworkDefFree(def);
|
virNetworkDefFree(newDef);
|
||||||
testObjectEventQueue(privconn, event);
|
testObjectEventQueue(privconn, event);
|
||||||
virNetworkObjEndAPI(&obj);
|
virNetworkObjEndAPI(&obj);
|
||||||
return net;
|
return net;
|
||||||
@ -3524,11 +3532,13 @@ testNetworkCreate(virNetworkPtr net)
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = net->conn->privateData;
|
testDriverPtr privconn = net->conn->privateData;
|
||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
|
virNetworkDefPtr def;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
def = virNetworkObjGetDef(obj);
|
||||||
|
|
||||||
if (virNetworkObjIsActive(obj)) {
|
if (virNetworkObjIsActive(obj)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||||
@ -3537,7 +3547,7 @@ testNetworkCreate(virNetworkPtr net)
|
|||||||
}
|
}
|
||||||
|
|
||||||
obj->active = 1;
|
obj->active = 1;
|
||||||
event = virNetworkEventLifecycleNew(obj->def->name, obj->def->uuid,
|
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||||
VIR_NETWORK_EVENT_STARTED,
|
VIR_NETWORK_EVENT_STARTED,
|
||||||
0);
|
0);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -3554,14 +3564,16 @@ testNetworkDestroy(virNetworkPtr net)
|
|||||||
{
|
{
|
||||||
testDriverPtr privconn = net->conn->privateData;
|
testDriverPtr privconn = net->conn->privateData;
|
||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
|
virNetworkDefPtr def;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virObjectEventPtr event = NULL;
|
virObjectEventPtr event = NULL;
|
||||||
|
|
||||||
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
def = virNetworkObjGetDef(obj);
|
||||||
|
|
||||||
obj->active = 0;
|
obj->active = 0;
|
||||||
event = virNetworkEventLifecycleNew(obj->def->name, obj->def->uuid,
|
event = virNetworkEventLifecycleNew(def->name, def->uuid,
|
||||||
VIR_NETWORK_EVENT_STOPPED,
|
VIR_NETWORK_EVENT_STOPPED,
|
||||||
0);
|
0);
|
||||||
if (!obj->persistent)
|
if (!obj->persistent)
|
||||||
@ -3589,7 +3601,7 @@ testNetworkGetXMLDesc(virNetworkPtr net,
|
|||||||
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = virNetworkDefFormat(obj->def, flags);
|
ret = virNetworkDefFormat(virNetworkObjGetDef(obj), flags);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNetworkObjEndAPI(&obj);
|
virNetworkObjEndAPI(&obj);
|
||||||
@ -3603,18 +3615,20 @@ testNetworkGetBridgeName(virNetworkPtr net)
|
|||||||
testDriverPtr privconn = net->conn->privateData;
|
testDriverPtr privconn = net->conn->privateData;
|
||||||
char *bridge = NULL;
|
char *bridge = NULL;
|
||||||
virNetworkObjPtr obj;
|
virNetworkObjPtr obj;
|
||||||
|
virNetworkDefPtr def;
|
||||||
|
|
||||||
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
if (!(obj = testNetworkObjFindByName(privconn, net->name)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
def = virNetworkObjGetDef(obj);
|
||||||
|
|
||||||
if (!(obj->def->bridge)) {
|
if (!(def->bridge)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("network '%s' does not have a bridge name."),
|
_("network '%s' does not have a bridge name."),
|
||||||
obj->def->name);
|
def->name);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore_value(VIR_STRDUP(bridge, obj->def->bridge));
|
ignore_value(VIR_STRDUP(bridge, def->bridge));
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNetworkObjEndAPI(&obj);
|
virNetworkObjEndAPI(&obj);
|
||||||
|
@ -23,20 +23,21 @@ testCompareXMLToConfFiles(const char *inxml, const char *outconf, dnsmasqCapsPtr
|
|||||||
{
|
{
|
||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virNetworkDefPtr dev = NULL;
|
virNetworkDefPtr def = NULL;
|
||||||
virNetworkObjPtr obj = NULL;
|
virNetworkObjPtr obj = NULL;
|
||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
char *pidfile = NULL;
|
char *pidfile = NULL;
|
||||||
dnsmasqContext *dctx = NULL;
|
dnsmasqContext *dctx = NULL;
|
||||||
|
|
||||||
if (!(dev = virNetworkDefParseFile(inxml)))
|
if (!(def = virNetworkDefParseFile(inxml)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(obj = virNetworkObjNew()))
|
if (!(obj = virNetworkObjNew()))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
obj->def = dev;
|
virNetworkObjSetDef(obj, def);
|
||||||
dctx = dnsmasqContextNew(dev->name, "/var/lib/libvirt/dnsmasq");
|
|
||||||
|
dctx = dnsmasqContextNew(def->name, "/var/lib/libvirt/dnsmasq");
|
||||||
|
|
||||||
if (dctx == NULL)
|
if (dctx == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user