static virStoragePoolPtr parallelsStoragePoolDefineXML(virConnectPtr conn, const char *xml, unsigned int flags) { parallelsConnPtr privconn = conn->privateData; virStoragePoolDefPtr def; virStoragePoolObjPtr pool = NULL; virStoragePoolPtr ret = NULL; virCheckFlags(0, NULL); parallelsDriverLock(privconn); if (!(def = virStoragePoolDefParseString(xml))) goto cleanup; if (def->type != VIR_STORAGE_POOL_DIR) { virReportError(VIR_ERR_NO_SUPPORT, "%s", _("Only local directories are supported")); goto cleanup; } if (virStoragePoolObjIsDuplicate(&privconn->pools, def, 0) < 0) goto cleanup; if (virStoragePoolSourceFindDuplicate(&privconn->pools, def) < 0) goto cleanup; if (parallelsStoragePoolGetAlloc(def)) goto cleanup; if (!(pool = virStoragePoolObjAssignDef(&privconn->pools, def))) goto cleanup; if (virStoragePoolObjSaveDef(conn->storagePrivateData, pool, def) < 0) { virStoragePoolObjRemove(&privconn->pools, pool); def = NULL; goto cleanup; } def = NULL; if (VIR_STRDUP(pool->configFile, "\0") < 0) goto cleanup; ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid, NULL, NULL); cleanup: virStoragePoolDefFree(def); if (pool) virStoragePoolObjUnlock(pool); parallelsDriverUnlock(privconn); return ret; }
static virStoragePoolObjPtr parallelsPoolCreateByPath(virConnectPtr conn, const char *path) { parallelsConnPtr privconn = conn->privateData; virStoragePoolObjListPtr pools = &privconn->pools; virStoragePoolDefPtr def; virStoragePoolObjPtr pool = NULL; if (VIR_ALLOC(def) < 0) goto no_memory; if (!(def->name = parallelsMakePoolName(conn, path))) goto error; if (VIR_ALLOC_N(def->uuid, VIR_UUID_BUFLEN)) goto no_memory; if (virUUIDGenerate(def->uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Can't generate UUID")); goto error; } def->type = VIR_STORAGE_POOL_DIR; if (VIR_STRDUP(def->target.path, path) < 0) goto error; if (!(pool = virStoragePoolObjAssignDef(pools, def))) goto error; if (virStoragePoolObjSaveDef(conn->storagePrivateData, pool, def) < 0) { virStoragePoolObjRemove(pools, pool); goto error; } virStoragePoolObjUnlock(pool); return pool; no_memory: virReportOOMError(); error: virStoragePoolDefFree(def); if (pool) virStoragePoolObjUnlock(pool); return NULL; }