From patchwork Fri Jul 1 11:38:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 71300 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp255597qgy; Fri, 1 Jul 2016 04:41:55 -0700 (PDT) X-Received: by 10.55.89.2 with SMTP id n2mr27907015qkb.169.1467373315529; Fri, 01 Jul 2016 04:41:55 -0700 (PDT) Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com. [209.132.183.37]) by mx.google.com with ESMTPS id 3si2125951qth.154.2016.07.01.04.41.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jul 2016 04:41:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u61BcMbq021926; Fri, 1 Jul 2016 07:38:22 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u61BcKOb032576 for ; Fri, 1 Jul 2016 07:38:20 -0400 Received: from colepc.redhat.com (ovpn-116-79.rdu2.redhat.com [10.10.116.79]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u61BcIbV004609; Fri, 1 Jul 2016 07:38:20 -0400 From: Cole Robinson To: libvir-list@redhat.com Date: Fri, 1 Jul 2016 07:38:00 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/4] test: Move testOpenDefault definition later X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com Upcoming patches need this defined later --- src/test/test_driver.c | 273 ++++++++++++++++++++++++------------------------- 1 file changed, 136 insertions(+), 137 deletions(-) -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 53901d6..e0d3e60 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -615,143 +615,6 @@ testDomainStartState(testDriverPtr privconn, } -/* Simultaneous test:///default connections should share the same - * common state (among other things, this allows testing event - * detection in one connection for an action caused in another). */ -static int -testOpenDefault(virConnectPtr conn) -{ - int u; - testDriverPtr privconn = NULL; - virDomainDefPtr domdef = NULL; - virDomainObjPtr domobj = NULL; - virNetworkDefPtr netdef = NULL; - virNetworkObjPtr netobj = NULL; - virInterfaceDefPtr interfacedef = NULL; - virInterfaceObjPtr interfaceobj = NULL; - virStoragePoolDefPtr pooldef = NULL; - virStoragePoolObjPtr poolobj = NULL; - virNodeDeviceDefPtr nodedef = NULL; - virNodeDeviceObjPtr nodeobj = NULL; - - virMutexLock(&defaultLock); - if (defaultConnections++) { - conn->privateData = defaultConn; - virMutexUnlock(&defaultLock); - return VIR_DRV_OPEN_SUCCESS; - } - - if (!(privconn = testDriverNew())) - goto error; - - conn->privateData = privconn; - - memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo)); - - /* Numa setup */ - privconn->numCells = 2; - for (u = 0; u < 2; ++u) { - privconn->cells[u].numCpus = 8; - privconn->cells[u].mem = (u + 1) * 2048 * 1024; - } - for (u = 0; u < 16; u++) { - virBitmapPtr siblings = virBitmapNew(16); - if (!siblings) - goto error; - ignore_value(virBitmapSetBit(siblings, u)); - privconn->cells[u / 8].cpus[(u % 8)].id = u; - privconn->cells[u / 8].cpus[(u % 8)].socket_id = u / 8; - privconn->cells[u / 8].cpus[(u % 8)].core_id = u % 8; - privconn->cells[u / 8].cpus[(u % 8)].siblings = siblings; - } - - if (!(privconn->caps = testBuildCapabilities(conn))) - goto error; - - if (!(domdef = virDomainDefParseString(defaultDomainXML, - privconn->caps, - privconn->xmlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE))) - goto error; - - if (testDomainGenerateIfnames(domdef) < 0) - goto error; - if (!(domobj = virDomainObjListAdd(privconn->domains, - domdef, - privconn->xmlopt, - 0, NULL))) - goto error; - domdef = NULL; - - domobj->persistent = 1; - if (testDomainStartState(privconn, domobj, - VIR_DOMAIN_RUNNING_BOOTED) < 0) { - virObjectUnlock(domobj); - goto error; - } - - virObjectUnlock(domobj); - - if (!(netdef = virNetworkDefParseString(defaultNetworkXML))) - goto error; - if (!(netobj = virNetworkAssignDef(privconn->networks, netdef, 0))) { - virNetworkDefFree(netdef); - goto error; - } - netobj->active = 1; - virNetworkObjEndAPI(&netobj); - - if (!(interfacedef = virInterfaceDefParseString(defaultInterfaceXML))) - goto error; - if (!(interfaceobj = virInterfaceAssignDef(&privconn->ifaces, interfacedef))) { - virInterfaceDefFree(interfacedef); - goto error; - } - interfaceobj->active = 1; - virInterfaceObjUnlock(interfaceobj); - - if (!(pooldef = virStoragePoolDefParseString(defaultPoolXML))) - goto error; - - if (!(poolobj = virStoragePoolObjAssignDef(&privconn->pools, - pooldef))) { - virStoragePoolDefFree(pooldef); - goto error; - } - - if (testStoragePoolObjSetDefaults(poolobj) == -1) { - virStoragePoolObjUnlock(poolobj); - goto error; - } - poolobj->active = 1; - virStoragePoolObjUnlock(poolobj); - - /* Init default node device */ - if (!(nodedef = virNodeDeviceDefParseString(defaultNodeXML, 0, NULL))) - goto error; - if (!(nodeobj = virNodeDeviceAssignDef(&privconn->devs, - nodedef))) { - virNodeDeviceDefFree(nodedef); - goto error; - } - virNodeDeviceObjUnlock(nodeobj); - - defaultConn = privconn; - - virMutexUnlock(&defaultLock); - - return VIR_DRV_OPEN_SUCCESS; - - error: - testDriverFree(privconn); - conn->privateData = NULL; - virDomainDefFree(domdef); - defaultConnections--; - virMutexUnlock(&defaultLock); - return VIR_DRV_OPEN_ERROR; -} - - static char *testBuildFilename(const char *relativeTo, const char *filename) { @@ -1368,6 +1231,142 @@ testOpenFromFile(virConnectPtr conn, const char *file) return VIR_DRV_OPEN_ERROR; } +/* Simultaneous test:///default connections should share the same + * common state (among other things, this allows testing event + * detection in one connection for an action caused in another). */ +static int +testOpenDefault(virConnectPtr conn) +{ + int u; + testDriverPtr privconn = NULL; + virDomainDefPtr domdef = NULL; + virDomainObjPtr domobj = NULL; + virNetworkDefPtr netdef = NULL; + virNetworkObjPtr netobj = NULL; + virInterfaceDefPtr interfacedef = NULL; + virInterfaceObjPtr interfaceobj = NULL; + virStoragePoolDefPtr pooldef = NULL; + virStoragePoolObjPtr poolobj = NULL; + virNodeDeviceDefPtr nodedef = NULL; + virNodeDeviceObjPtr nodeobj = NULL; + + virMutexLock(&defaultLock); + if (defaultConnections++) { + conn->privateData = defaultConn; + virMutexUnlock(&defaultLock); + return VIR_DRV_OPEN_SUCCESS; + } + + if (!(privconn = testDriverNew())) + goto error; + + conn->privateData = privconn; + + memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo)); + + /* Numa setup */ + privconn->numCells = 2; + for (u = 0; u < 2; ++u) { + privconn->cells[u].numCpus = 8; + privconn->cells[u].mem = (u + 1) * 2048 * 1024; + } + for (u = 0; u < 16; u++) { + virBitmapPtr siblings = virBitmapNew(16); + if (!siblings) + goto error; + ignore_value(virBitmapSetBit(siblings, u)); + privconn->cells[u / 8].cpus[(u % 8)].id = u; + privconn->cells[u / 8].cpus[(u % 8)].socket_id = u / 8; + privconn->cells[u / 8].cpus[(u % 8)].core_id = u % 8; + privconn->cells[u / 8].cpus[(u % 8)].siblings = siblings; + } + + if (!(privconn->caps = testBuildCapabilities(conn))) + goto error; + + if (!(domdef = virDomainDefParseString(defaultDomainXML, + privconn->caps, + privconn->xmlopt, + VIR_DOMAIN_DEF_PARSE_INACTIVE))) + goto error; + + if (testDomainGenerateIfnames(domdef) < 0) + goto error; + if (!(domobj = virDomainObjListAdd(privconn->domains, + domdef, + privconn->xmlopt, + 0, NULL))) + goto error; + domdef = NULL; + + domobj->persistent = 1; + if (testDomainStartState(privconn, domobj, + VIR_DOMAIN_RUNNING_BOOTED) < 0) { + virObjectUnlock(domobj); + goto error; + } + + virObjectUnlock(domobj); + + if (!(netdef = virNetworkDefParseString(defaultNetworkXML))) + goto error; + if (!(netobj = virNetworkAssignDef(privconn->networks, netdef, 0))) { + virNetworkDefFree(netdef); + goto error; + } + netobj->active = 1; + virNetworkObjEndAPI(&netobj); + + if (!(interfacedef = virInterfaceDefParseString(defaultInterfaceXML))) + goto error; + if (!(interfaceobj = virInterfaceAssignDef(&privconn->ifaces, interfacedef))) { + virInterfaceDefFree(interfacedef); + goto error; + } + interfaceobj->active = 1; + virInterfaceObjUnlock(interfaceobj); + + if (!(pooldef = virStoragePoolDefParseString(defaultPoolXML))) + goto error; + + if (!(poolobj = virStoragePoolObjAssignDef(&privconn->pools, + pooldef))) { + virStoragePoolDefFree(pooldef); + goto error; + } + + if (testStoragePoolObjSetDefaults(poolobj) == -1) { + virStoragePoolObjUnlock(poolobj); + goto error; + } + poolobj->active = 1; + virStoragePoolObjUnlock(poolobj); + + /* Init default node device */ + if (!(nodedef = virNodeDeviceDefParseString(defaultNodeXML, 0, NULL))) + goto error; + if (!(nodeobj = virNodeDeviceAssignDef(&privconn->devs, + nodedef))) { + virNodeDeviceDefFree(nodedef); + goto error; + } + virNodeDeviceObjUnlock(nodeobj); + + defaultConn = privconn; + + virMutexUnlock(&defaultLock); + + return VIR_DRV_OPEN_SUCCESS; + + error: + testDriverFree(privconn); + conn->privateData = NULL; + virDomainDefFree(domdef); + defaultConnections--; + virMutexUnlock(&defaultLock); + return VIR_DRV_OPEN_ERROR; +} + static int testConnectAuthenticate(virConnectPtr conn, virConnectAuthPtr auth)