*/
+static virInterfaceObjPtr
+testInterfaceObjFindByName(testDriverPtr privconn,
+ const char *name)
+{
+ virInterfaceObjPtr iface;
+
+ testDriverLock(privconn);
+ iface = virInterfaceObjFindByName(&privconn->ifaces, name);
+ testDriverUnlock(privconn);
+
+ if (!iface)
+ virReportError(VIR_ERR_NO_INTERFACE,
+ _("no interface with matching name '%s'"),
+ name);
+
+ return iface;
+}
+
+
static int testConnectNumOfInterfaces(virConnectPtr conn)
{
testDriverPtr privconn = conn->privateData;
virInterfaceObjPtr iface;
virInterfacePtr ret = NULL;
- testDriverLock(privconn);
- iface = virInterfaceObjFindByName(&privconn->ifaces, name);
- testDriverUnlock(privconn);
-
- if (iface == NULL) {
- virReportError(VIR_ERR_NO_INTERFACE, NULL);
+ if (!(iface = testInterfaceObjFindByName(privconn, name)))
goto cleanup;
- }
ret = virGetInterface(conn, iface->def->name, iface->def->mac);
virInterfaceObjPtr obj;
int ret = -1;
- testDriverLock(privconn);
- obj = virInterfaceObjFindByName(&privconn->ifaces, iface->name);
- testDriverUnlock(privconn);
- if (!obj) {
- virReportError(VIR_ERR_NO_INTERFACE, NULL);
+ if (!(obj = testInterfaceObjFindByName(privconn, iface->name)))
goto cleanup;
- }
+
ret = virInterfaceObjIsActive(obj);
cleanup:
virCheckFlags(0, NULL);
- testDriverLock(privconn);
- privinterface = virInterfaceObjFindByName(&privconn->ifaces, iface->name);
- testDriverUnlock(privconn);
-
- if (privinterface == NULL) {
- virReportError(VIR_ERR_NO_INTERFACE, __FUNCTION__);
+ if (!(privinterface = testInterfaceObjFindByName(privconn, iface->name)))
goto cleanup;
- }
ret = virInterfaceDefFormat(privinterface->def);
virInterfaceObjPtr privinterface;
int ret = -1;
- testDriverLock(privconn);
- privinterface = virInterfaceObjFindByName(&privconn->ifaces, iface->name);
-
- if (privinterface == NULL) {
- virReportError(VIR_ERR_NO_INTERFACE, NULL);
+ if (!(privinterface = testInterfaceObjFindByName(privconn, iface->name)))
goto cleanup;
- }
virInterfaceObjRemove(&privconn->ifaces, privinterface);
ret = 0;
virCheckFlags(0, -1);
- testDriverLock(privconn);
- privinterface = virInterfaceObjFindByName(&privconn->ifaces, iface->name);
-
- if (privinterface == NULL) {
- virReportError(VIR_ERR_NO_INTERFACE, NULL);
+ if (!(privinterface = testInterfaceObjFindByName(privconn, iface->name)))
goto cleanup;
- }
if (privinterface->active != 0) {
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
virCheckFlags(0, -1);
- testDriverLock(privconn);
- privinterface = virInterfaceObjFindByName(&privconn->ifaces, iface->name);
-
- if (privinterface == NULL) {
- virReportError(VIR_ERR_NO_INTERFACE, NULL);
+ if (!(privinterface = testInterfaceObjFindByName(privconn, iface->name)))
goto cleanup;
- }
if (privinterface->active == 0) {
virReportError(VIR_ERR_OPERATION_INVALID, NULL);
}
+static virStoragePoolObjPtr
+testStoragePoolObjFindByName(testDriverPtr privconn,
+ const char *name)
+{
+ virStoragePoolObjPtr pool;
+
+ testDriverLock(privconn);
+ pool = virStoragePoolObjFindByName(&privconn->pools, name);
+ testDriverUnlock(privconn);
+
+ if (!pool)
+ virReportError(VIR_ERR_NO_STORAGE_POOL,
+ _("no storage pool with matching name '%s'"),
+ name);
+
+ return pool;
+}
+
+
static virStoragePoolPtr
testStoragePoolLookupByUUID(virConnectPtr conn,
const unsigned char *uuid)
virStoragePoolObjPtr pool;
virStoragePoolPtr ret = NULL;
- testDriverLock(privconn);
- pool = virStoragePoolObjFindByName(&privconn->pools, name);
- testDriverUnlock(privconn);
-
- if (pool == NULL) {
- virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
+ if (!(pool = testStoragePoolObjFindByName(privconn, name)))
goto cleanup;
- }
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
NULL, NULL);
virCheckFlags(0, -1);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
int ret = -1;
virObjectEventPtr event = NULL;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virCheckFlags(0, -1);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
int ret = -1;
virObjectEventPtr event = NULL;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (!virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virCheckFlags(0, -1);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virCheckFlags(0, -1);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (!virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virStoragePoolObjPtr privpool;
int ret = -1;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
memset(info, 0, sizeof(virStoragePoolInfo));
if (privpool->active)
virCheckFlags(0, NULL);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
ret = virStoragePoolDefFormat(privpool->def);
virStoragePoolObjPtr privpool;
int ret = -1;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (!privpool->configFile) {
*autostart = 0;
virStoragePoolObjPtr privpool;
int ret = -1;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (!privpool->configFile) {
virReportError(VIR_ERR_INVALID_ARG,
virStoragePoolObjPtr privpool;
int ret = -1;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (!virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
memset(names, 0, maxnames * sizeof(*names));
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
-
if (!virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virStorageVolDefPtr privvol;
virStorageVolPtr ret = NULL;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
-
if (!virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virCheckFlags(0, NULL);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (!virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virCheckFlags(0, NULL);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- pool->name);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, pool->name)))
goto cleanup;
- }
if (!virStoragePoolObjIsActive(privpool)) {
virReportError(VIR_ERR_OPERATION_INVALID,
virCheckFlags(0, -1);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- vol->pool);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup;
- }
-
privvol = virStorageVolDefFindByName(privpool, vol->name);
virStorageVolDefPtr privvol;
int ret = -1;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- vol->pool);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup;
- }
privvol = virStorageVolDefFindByName(privpool, vol->name);
virCheckFlags(0, NULL);
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- vol->pool);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup;
- }
privvol = virStorageVolDefFindByName(privpool, vol->name);
virStorageVolDefPtr privvol;
char *ret = NULL;
- testDriverLock(privconn);
- privpool = virStoragePoolObjFindByName(&privconn->pools,
- vol->pool);
- testDriverUnlock(privconn);
-
- if (privpool == NULL) {
- virReportError(VIR_ERR_INVALID_ARG, __FUNCTION__);
+ if (!(privpool = testStoragePoolObjFindByName(privconn, vol->pool)))
goto cleanup;
- }
privvol = virStorageVolDefFindByName(privpool, vol->name);
/* Node device implementations */
+static virNodeDeviceObjPtr
+testNodeDeviceObjFindByName(testDriverPtr driver,
+ const char *name)
+{
+ virNodeDeviceObjPtr obj;
+
+ testDriverLock(driver);
+ obj = virNodeDeviceObjFindByName(&driver->devs, name);
+ testDriverUnlock(driver);
+
+ if (!obj)
+ virReportError(VIR_ERR_NO_NODE_DEVICE,
+ _("no node device with matching name '%s'"),
+ name);
+
+ return obj;
+}
+
+
static int
testNodeNumOfDevices(virConnectPtr conn,
const char *cap,
virNodeDeviceObjPtr obj;
virNodeDevicePtr ret = NULL;
- testDriverLock(driver);
- obj = virNodeDeviceObjFindByName(&driver->devs, name);
- testDriverUnlock(driver);
-
- if (!obj) {
- virReportError(VIR_ERR_NO_NODE_DEVICE,
- _("no node device with matching name '%s'"),
- name);
+ if (!(obj = testNodeDeviceObjFindByName(driver, name)))
goto cleanup;
- }
if ((ret = virGetNodeDevice(conn, name))) {
if (VIR_STRDUP(ret->parent, obj->def->parent) < 0)
virCheckFlags(0, NULL);
- testDriverLock(driver);
- obj = virNodeDeviceObjFindByName(&driver->devs, dev->name);
- testDriverUnlock(driver);
-
- if (!obj) {
- virReportError(VIR_ERR_NO_NODE_DEVICE,
- _("no node device with matching name '%s'"),
- dev->name);
+ if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
goto cleanup;
- }
ret = virNodeDeviceDefFormat(obj->def);
virNodeDeviceObjPtr obj;
char *ret = NULL;
- testDriverLock(driver);
- obj = virNodeDeviceObjFindByName(&driver->devs, dev->name);
- testDriverUnlock(driver);
-
- if (!obj) {
- virReportError(VIR_ERR_NO_NODE_DEVICE,
- _("no node device with matching name '%s'"),
- dev->name);
+ if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
goto cleanup;
- }
if (obj->def->parent) {
ignore_value(VIR_STRDUP(ret, obj->def->parent));
int ncaps = 0;
int ret = -1;
- testDriverLock(driver);
- obj = virNodeDeviceObjFindByName(&driver->devs, dev->name);
- testDriverUnlock(driver);
-
- if (!obj) {
- virReportError(VIR_ERR_NO_NODE_DEVICE,
- _("no node device with matching name '%s'"),
- dev->name);
+ if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
goto cleanup;
- }
for (caps = obj->def->caps; caps; caps = caps->next)
++ncaps;
int ncaps = 0;
int ret = -1;
- testDriverLock(driver);
- obj = virNodeDeviceObjFindByName(&driver->devs, dev->name);
- testDriverUnlock(driver);
-
- if (!obj) {
- virReportError(VIR_ERR_NO_NODE_DEVICE,
- _("no node device with matching name '%s'"),
- dev->name);
+ if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
goto cleanup;
- }
for (caps = obj->def->caps; caps && ncaps < maxnames; caps = caps->next) {
if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps->data.type)) < 0)
char *parent_name = NULL, *wwnn = NULL, *wwpn = NULL;
virObjectEventPtr event = NULL;
- testDriverLock(driver);
- obj = virNodeDeviceObjFindByName(&driver->devs, dev->name);
- testDriverUnlock(driver);
-
- if (!obj) {
- virReportError(VIR_ERR_NO_NODE_DEVICE,
- _("no node device with matching name '%s'"),
- dev->name);
+ if (!(obj = testNodeDeviceObjFindByName(driver, dev->name)))
goto out;
- }
if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1)
goto out;