
On Fri, May 19, 2017 at 09:03:17AM -0400, John Ferlan wrote:
In preparation for making the object private, create a couple of API's to get the obj->def and obj->newDef.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/conf/virnetworkobj.c | 14 ++ src/conf/virnetworkobj.h | 6 + src/libvirt_private.syms | 2 + src/network/bridge_driver.c | 488 ++++++++++++++++++++++++-------------------- src/test/test_driver.c | 38 ++-- 5 files changed, 312 insertions(+), 236 deletions(-)
[...]
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index cd91a1a..f8e11e2 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c
[...]
@@ -430,6 +431,7 @@ static int networkUpdateState(virNetworkObjPtr obj, void *opaque) { + virNetworkDefPtr def = virNetworkObjGetDef(obj);
The @obj is not locked here, you need to move the assignment after the lock.
virNetworkDriverStatePtr driver = opaque; dnsmasqCapsPtr dnsmasq_caps = networkGetDnsmasqCaps(driver); virMacMapPtr macmap;
[...]
@@ -3460,6 +3475,7 @@ networkCreateXML(virConnectPtr conn, virNetworkDriverStatePtr driver = networkGetDriver(); virNetworkDefPtr def; virNetworkObjPtr obj = NULL; + virNetworkDefPtr objdef;
I would probably change the current @def to @newDef and go with @def instead of @objdef.
virNetworkPtr net = NULL; virObjectEventPtr event = NULL;
[...]
@@ -3870,20 +3894,24 @@ networkGetXMLDesc(virNetworkPtr net, { virNetworkObjPtr obj; virNetworkDefPtr def; + virNetworkDefPtr objdef; + virNetworkDefPtr newDef;
This one is a little bit tricky since there is already @newDef, in this context I would change the @def to @curDef and go with @def instead of @objdef. One note, please try to use camelCase even for @objDef. We like consistency :).
char *ret = NULL;
virCheckFlags(VIR_NETWORK_XML_INACTIVE, NULL);
if (!(obj = networkObjFromNetwork(net))) return ret; + objdef = virNetworkObjGetDef(obj); + newDef = virNetworkObjGetNewDef(obj);
- if (virNetworkGetXMLDescEnsureACL(net->conn, obj->def) < 0) + if (virNetworkGetXMLDescEnsureACL(net->conn, objdef) < 0) goto cleanup;
- if ((flags & VIR_NETWORK_XML_INACTIVE) && obj->newDef) - def = obj->newDef; + if ((flags & VIR_NETWORK_XML_INACTIVE) && newDef) + def = newDef; else - def = obj->def; + def = objdef;
ret = virNetworkDefFormat(def, flags);
[...]
diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 46f0a9a..ee473ba 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c
[...]
@@ -3384,6 +3388,7 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml) testDriverPtr privconn = conn->privateData; virNetworkDefPtr def; virNetworkObjPtr obj = NULL; + virNetworkDefPtr objdef;
The same, @def -> @newDef, @objdef -> @def.
virNetworkPtr net = NULL; virObjectEventPtr event = NULL;
@@ -3395,13 +3400,14 @@ testNetworkCreateXML(virConnectPtr conn, const char *xml) VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE))) goto cleanup; def = NULL; + objdef = virNetworkObjGetDef(obj); obj->active = 1;
- event = virNetworkEventLifecycleNew(obj->def->name, obj->def->uuid, + event = virNetworkEventLifecycleNew(objdef->name, objdef->uuid, VIR_NETWORK_EVENT_STARTED, 0);
- net = virGetNetwork(conn, obj->def->name, obj->def->uuid); + net = virGetNetwork(conn, objdef->name, objdef->uuid);
cleanup: virNetworkDefFree(def); @@ -3418,6 +3424,7 @@ testNetworkDefineXML(virConnectPtr conn, testDriverPtr privconn = conn->privateData; virNetworkDefPtr def; virNetworkObjPtr obj = NULL; + virNetworkDefPtr objdef;
And here as well. Otherwise the patch is correct. Pavel