virDomainDiskTranslateSourcePool(virDomainDiskDefPtr def)
{
virConnectPtr conn = NULL;
- virStoragePoolDefPtr pooldef = NULL;
virStoragePoolPtr pool = NULL;
virStorageVolPtr vol = NULL;
char *poolxml = NULL;
virStorageVolInfo info;
int ret = -1;
+ VIR_AUTOPTR(virStoragePoolDef) pooldef = NULL;
if (def->src->type != VIR_STORAGE_TYPE_VOLUME)
return 0;
virObjectUnref(pool);
virObjectUnref(vol);
VIR_FREE(poolxml);
- virStoragePoolDefFree(pooldef);
return ret;
}
virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
{
virStoragePoolOptionsPtr options;
- virStoragePoolDefPtr def;
virStoragePoolDefPtr ret = NULL;
xmlNodePtr source_node;
char *type = NULL;
char *uuid = NULL;
char *target_path = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) def = NULL;
if (VIR_ALLOC(def) < 0)
return NULL;
VIR_STEAL_PTR(ret, def);
cleanup:
- virStoragePoolDefFree(def);
VIR_FREE(uuid);
VIR_FREE(type);
VIR_FREE(target_path);
VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)
VIR_DEFINE_AUTOPTR_FUNC(virStoragePoolSource, virStoragePoolSourceFree);
+VIR_DEFINE_AUTOPTR_FUNC(virStoragePoolDef, virStoragePoolDefFree);
VIR_DEFINE_AUTOPTR_FUNC(virStorageVolDef, virStorageVolDefFree);
#endif /* LIBVIRT_STORAGE_CONF_H */
const char *path,
const char *autostartLink)
{
- virStoragePoolDefPtr def;
virStoragePoolObjPtr obj;
+ VIR_AUTOPTR(virStoragePoolDef) def = NULL;
if (!(def = virStoragePoolDefParseFile(path)))
return NULL;
_("Storage pool config filename '%s' does "
"not match pool name '%s'"),
path, def->name);
- virStoragePoolDefFree(def);
return NULL;
}
- if (!(obj = virStoragePoolObjAssignDef(pools, def, false))) {
- virStoragePoolDefFree(def);
+ if (!(obj = virStoragePoolObjAssignDef(pools, def, false)))
return NULL;
- }
+ def = NULL;
VIR_FREE(obj->configFile); /* for driver reload */
if (VIR_STRDUP(obj->configFile, path) < 0) {
const char *name)
{
char *stateFile = NULL;
- virStoragePoolDefPtr def = NULL;
virStoragePoolObjPtr obj = NULL;
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
xmlNodePtr node = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) def = NULL;
if (!(stateFile = virFileBuildPath(stateDir, name, ".xml")))
- goto error;
+ return NULL;
if (!(xml = virXMLParseCtxt(stateFile, NULL, _("(pool state)"), &ctxt)))
- goto error;
+ goto cleanup;
if (!(node = virXPathNode("//pool", ctxt))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not find any 'pool' element in state file"));
- goto error;
+ goto cleanup;
}
ctxt->node = node;
if (!(def = virStoragePoolDefParseXML(ctxt)))
- goto error;
+ goto cleanup;
if (STRNEQ(name, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Storage pool state file '%s' does not match "
"pool name '%s'"),
stateFile, def->name);
- goto error;
+ goto cleanup;
}
/* create the object */
if (!(obj = virStoragePoolObjAssignDef(pools, def, true)))
- goto error;
+ goto cleanup;
+ def = NULL;
/* XXX: future handling of some additional useful status data,
* for now, if a status file for a pool exists, the pool will be marked
xmlFreeDoc(xml);
xmlXPathFreeContext(ctxt);
return obj;
-
- error:
- virStoragePoolDefFree(def);
- goto cleanup;
}
{
virCheckFlags(0, NULL);
- virStoragePoolDefPtr spdef = NULL;
virStorageVolPtr vol = NULL;
virStorageVolPtr dup_vol = NULL;
char *key = NULL;
VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) spdef = NULL;
if (VIR_ALLOC(spdef) < 0)
return NULL;
goto err;
VIR_FREE(key);
- virStoragePoolDefFree(spdef);
return vol;
err:
VIR_FREE(key);
- virStoragePoolDefFree(spdef);
virObjectUnref(vol);
return NULL;
}
const char *xml,
unsigned int flags)
{
- virStoragePoolDefPtr newDef;
virStoragePoolObjPtr obj = NULL;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL;
char *stateFile = NULL;
unsigned int build_flags = 0;
+ VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
virCheckFlags(VIR_STORAGE_POOL_CREATE_WITH_BUILD |
VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE |
cleanup:
VIR_FREE(stateFile);
- virStoragePoolDefFree(newDef);
virObjectEventStateQueue(driver->storageEventState, event);
virStoragePoolObjEndAPI(&obj);
return pool;
const char *xml,
unsigned int flags)
{
- virStoragePoolDefPtr newDef;
virStoragePoolObjPtr obj = NULL;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
virCheckFlags(0, NULL);
cleanup:
virObjectEventStateQueue(driver->storageEventState, event);
- virStoragePoolDefFree(newDef);
virStoragePoolObjEndAPI(&obj);
return pool;
}
unsigned int flags)
{
testDriverPtr privconn = conn->privateData;
- virStoragePoolDefPtr newDef;
virStoragePoolObjPtr obj = NULL;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
virCheckFlags(0, NULL);
pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
cleanup:
- virStoragePoolDefFree(newDef);
virObjectEventStateQueue(privconn->eventState, event);
virStoragePoolObjEndAPI(&obj);
virObjectUnlock(privconn);
unsigned int flags)
{
testDriverPtr privconn = conn->privateData;
- virStoragePoolDefPtr newDef;
virStoragePoolObjPtr obj = NULL;
virStoragePoolDefPtr def;
virStoragePoolPtr pool = NULL;
virObjectEventPtr event = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) newDef = NULL;
virCheckFlags(0, NULL);
pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
cleanup:
- virStoragePoolDefFree(newDef);
virObjectEventStateQueue(privconn->eventState, event);
virStoragePoolObjEndAPI(&obj);
virObjectUnlock(privconn);
collie_test test = data->data;
int ret = -1;
char *output = NULL;
- virStoragePoolDefPtr pool = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
goto cleanup;
cleanup:
VIR_FREE(output);
- virStoragePoolDefFree(pool);
return ret;
}
collie_test test = data->data;
int ret = -1;
char *output = NULL;
- virStoragePoolDefPtr pool = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
cleanup:
VIR_FREE(output);
- virStoragePoolDefFree(pool);
return ret;
}
{
char *actual = NULL;
int ret = -1;
- virStoragePoolDefPtr dev = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) dev = NULL;
if (!(dev = virStoragePoolDefParseFile(inxml)))
goto fail;
fail:
VIR_FREE(actual);
- virStoragePoolDefFree(dev);
return ret;
}
virCommandPtr cmd = NULL;
virStoragePoolDefPtr def = NULL;
- virStoragePoolDefPtr inputpool = NULL;
virStoragePoolObjPtr obj = NULL;
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
VIR_AUTOPTR(virStorageVolDef) inputvol = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) inputpool = NULL;
if (!(def = virStoragePoolDefParseFile(poolxml)))
goto cleanup;
ret = 0;
cleanup:
- virStoragePoolDefFree(inputpool);
virCommandFree(cmd);
VIR_FREE(actualCmdline);
virStoragePoolObjEndAPI(&obj);
{
char *actual = NULL;
int ret = -1;
- virStoragePoolDefPtr pool = NULL;
+ VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
VIR_AUTOPTR(virStorageVolDef) dev = NULL;
if (!(pool = virStoragePoolDefParseFile(poolxml)))
fail:
VIR_FREE(actual);
- virStoragePoolDefFree(pool);
return ret;
}