On Tue, Sep 18, 2012 at 03:39:03AM -0400, Laine Stump wrote:
The test driver does nothing outside of keeping track of each
network's config/state in the in-memory database maintained by
network_conf functions, so all we have to do is call the function that
updates the network's entry in the in-memory database.
---
src/test/test_driver.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1bd0d61..0036563 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3126,7 +3126,9 @@ cleanup:
return ret;
}
-static virNetworkPtr testNetworkDefine(virConnectPtr conn, const char *xml) {
+static
+virNetworkPtr testNetworkDefine(virConnectPtr conn, const char *xml)
+{
testConnPtr privconn = conn->privateData;
virNetworkDefPtr def;
virNetworkObjPtr net = NULL;
@@ -3183,6 +3185,54 @@ cleanup:
return ret;
}
+static int
+testNetworkUpdate(virNetworkPtr net,
+ unsigned int command,
+ unsigned int section,
+ int parentIndex,
+ const char *xml,
+ unsigned int flags)
+{
+ testConnPtr privconn = net->conn->privateData;
+ virNetworkObjPtr network = NULL;
+ int isActive, ret = -1;
+
+ virCheckFlags(VIR_NETWORK_UPDATE_AFFECT_LIVE |
+ VIR_NETWORK_UPDATE_AFFECT_CONFIG,
+ -1);
+
+ testDriverLock(privconn);
+
+ network = virNetworkFindByUUID(&privconn->networks, net->uuid);
+ if (!network) {
+ virReportError(VIR_ERR_NO_NETWORK,
+ "%s", _("no network with matching uuid"));
+ goto cleanup;
+ }
+
+ /* VIR_NETWORK_UPDATE_AFFECT_CURRENT means "change LIVE if network
+ * is active, else change CONFIG
+ */
+ isActive = virNetworkObjIsActive(network);
+ if ((flags & (VIR_NETWORK_UPDATE_AFFECT_LIVE
+ | VIR_NETWORK_UPDATE_AFFECT_CONFIG)) ==
+ VIR_NETWORK_UPDATE_AFFECT_CURRENT) {
+ if (isActive)
+ flags |= VIR_NETWORK_UPDATE_AFFECT_LIVE;
+ else
+ flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
+ }
+
+ /* update the network config in memory/on disk */
+ if (virNetworkObjUpdate(network, command, section, parentIndex, xml, flags) < 0)
+ goto cleanup;
+
+ ret = 0;
+cleanup:
+ testDriverUnlock(privconn);
+ return ret;
+}
+
static int testNetworkStart(virNetworkPtr network) {
testConnPtr privconn = network->conn->privateData;
virNetworkObjPtr privnet;
@@ -5722,6 +5772,7 @@ static virNetworkDriver testNetworkDriver = {
.networkCreateXML = testNetworkCreate, /* 0.3.2 */
.networkDefineXML = testNetworkDefine, /* 0.3.2 */
.networkUndefine = testNetworkUndefine, /* 0.3.2 */
+ .networkUpdate = testNetworkUpdate, /* 0.10.2 */
.networkCreate = testNetworkStart, /* 0.3.2 */
.networkDestroy = testNetworkDestroy, /* 0.3.2 */
.networkGetXMLDesc = testNetworkGetXMLDesc, /* 0.3.2 */
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/