mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
test_driver: Adapt to new virNetworkObjList accessors
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b61db335f9
commit
d8e01f527b
@ -3543,16 +3543,11 @@ static virNetworkPtr testNetworkLookupByName(virConnectPtr conn,
|
|||||||
static int testConnectNumOfNetworks(virConnectPtr conn)
|
static int testConnectNumOfNetworks(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
testConnPtr privconn = conn->privateData;
|
testConnPtr privconn = conn->privateData;
|
||||||
int numActive = 0;
|
int numActive;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
testDriverLock(privconn);
|
testDriverLock(privconn);
|
||||||
for (i = 0; i < privconn->networks->count; i++) {
|
numActive = virNetworkObjListNumOfNetworks(privconn->networks,
|
||||||
virNetworkObjLock(privconn->networks->objs[i]);
|
true, NULL, conn);
|
||||||
if (virNetworkObjIsActive(privconn->networks->objs[i]))
|
|
||||||
numActive++;
|
|
||||||
virNetworkObjUnlock(privconn->networks->objs[i]);
|
|
||||||
}
|
|
||||||
testDriverUnlock(privconn);
|
testDriverUnlock(privconn);
|
||||||
|
|
||||||
return numActive;
|
return numActive;
|
||||||
@ -3560,44 +3555,24 @@ static int testConnectNumOfNetworks(virConnectPtr conn)
|
|||||||
|
|
||||||
static int testConnectListNetworks(virConnectPtr conn, char **const names, int nnames) {
|
static int testConnectListNetworks(virConnectPtr conn, char **const names, int nnames) {
|
||||||
testConnPtr privconn = conn->privateData;
|
testConnPtr privconn = conn->privateData;
|
||||||
int n = 0;
|
int n;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
testDriverLock(privconn);
|
testDriverLock(privconn);
|
||||||
memset(names, 0, sizeof(*names)*nnames);
|
n = virNetworkObjListGetNames(privconn->networks,
|
||||||
for (i = 0; i < privconn->networks->count && n < nnames; i++) {
|
true, names, nnames, NULL, conn);
|
||||||
virNetworkObjLock(privconn->networks->objs[i]);
|
|
||||||
if (virNetworkObjIsActive(privconn->networks->objs[i]) &&
|
|
||||||
VIR_STRDUP(names[n++], privconn->networks->objs[i]->def->name) < 0) {
|
|
||||||
virNetworkObjUnlock(privconn->networks->objs[i]);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
virNetworkObjUnlock(privconn->networks->objs[i]);
|
|
||||||
}
|
|
||||||
testDriverUnlock(privconn);
|
testDriverUnlock(privconn);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
|
|
||||||
error:
|
|
||||||
for (n = 0; n < nnames; n++)
|
|
||||||
VIR_FREE(names[n]);
|
|
||||||
testDriverUnlock(privconn);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testConnectNumOfDefinedNetworks(virConnectPtr conn)
|
static int testConnectNumOfDefinedNetworks(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
testConnPtr privconn = conn->privateData;
|
testConnPtr privconn = conn->privateData;
|
||||||
int numInactive = 0;
|
int numInactive;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
testDriverLock(privconn);
|
testDriverLock(privconn);
|
||||||
for (i = 0; i < privconn->networks->count; i++) {
|
numInactive = virNetworkObjListNumOfNetworks(privconn->networks,
|
||||||
virNetworkObjLock(privconn->networks->objs[i]);
|
false, NULL, conn);
|
||||||
if (!virNetworkObjIsActive(privconn->networks->objs[i]))
|
|
||||||
numInactive++;
|
|
||||||
virNetworkObjUnlock(privconn->networks->objs[i]);
|
|
||||||
}
|
|
||||||
testDriverUnlock(privconn);
|
testDriverUnlock(privconn);
|
||||||
|
|
||||||
return numInactive;
|
return numInactive;
|
||||||
@ -3605,29 +3580,14 @@ static int testConnectNumOfDefinedNetworks(virConnectPtr conn)
|
|||||||
|
|
||||||
static int testConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) {
|
static int testConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) {
|
||||||
testConnPtr privconn = conn->privateData;
|
testConnPtr privconn = conn->privateData;
|
||||||
int n = 0;
|
int n;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
testDriverLock(privconn);
|
testDriverLock(privconn);
|
||||||
memset(names, 0, sizeof(*names)*nnames);
|
n = virNetworkObjListGetNames(privconn->networks,
|
||||||
for (i = 0; i < privconn->networks->count && n < nnames; i++) {
|
false, names, nnames, NULL, conn);
|
||||||
virNetworkObjLock(privconn->networks->objs[i]);
|
|
||||||
if (!virNetworkObjIsActive(privconn->networks->objs[i]) &&
|
|
||||||
VIR_STRDUP(names[n++], privconn->networks->objs[i]->def->name) < 0) {
|
|
||||||
virNetworkObjUnlock(privconn->networks->objs[i]);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
virNetworkObjUnlock(privconn->networks->objs[i]);
|
|
||||||
}
|
|
||||||
testDriverUnlock(privconn);
|
testDriverUnlock(privconn);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
|
|
||||||
error:
|
|
||||||
for (n = 0; n < nnames; n++)
|
|
||||||
VIR_FREE(names[n]);
|
|
||||||
testDriverUnlock(privconn);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user