struct stat local_fileinfo;
char buffer[1024];
int rc = 0;
- FILE *fd;
+ FILE *fd = NULL;
size_t nread, sent;
char *ptr;
char local_file[] = "./uuid_table";
libssh2_channel_free(channel);
channel = NULL;
}
+ VIR_FORCE_FCLOSE(fd);
return -1;
}
virStorageVolDefPtr voldef = NULL;
virStoragePoolDefPtr spdef = NULL;
virStorageVolPtr vol = NULL;
+ virStorageVolPtr dup_vol = NULL;
char *key = NULL;
if (VIR_ALLOC(spdef) < 0) {
}
/* checking if this name already exists on this system */
- if (phypVolumeLookupByName(pool, voldef->name) != NULL) {
+ if ((dup_vol = phypVolumeLookupByName(pool, voldef->name)) != NULL) {
VIR_ERROR(_("StoragePool name already exists."));
+ virUnrefStorageVol(dup_vol);
goto err;
}
virStorageVolDef voldef;
virStoragePoolDef pool;
virStoragePoolPtr sp;
- char *xml;
+ char *xml = NULL;
virCheckFlags(0, NULL);
sp = phypStoragePoolLookupByName(vol->conn, vol->pool);
if (!sp)
- goto err;
+ goto cleanup;
if (sp->name != NULL) {
pool.name = sp->name;
} else {
VIR_ERROR(_("Unable to determine storage sp's name."));
- goto err;
+ goto cleanup;
}
if (memcpy(pool.uuid, sp->uuid, VIR_UUID_BUFLEN) == NULL) {
VIR_ERROR(_("Unable to determine storage sp's uuid."));
- goto err;
+ goto cleanup;
}
if ((pool.capacity = phypGetStoragePoolSize(sp->conn, sp->name)) == -1) {
VIR_ERROR(_("Unable to determine storage sps's size."));
- goto err;
+ goto cleanup;
}
/* Information not avaliable */
if ((pool.source.adapter =
phypGetStoragePoolDevice(sp->conn, sp->name)) == NULL) {
VIR_ERROR(_("Unable to determine storage sps's source adapter."));
- goto err;
+ goto cleanup;
}
if (vol->name != NULL)
voldef.name = vol->name;
else {
VIR_ERROR(_("Unable to determine storage pool's name."));
- goto err;
+ goto cleanup;
}
voldef.key = strdup(vol->key);
if (voldef.key == NULL) {
virReportOOMError();
- goto err;
+ goto cleanup;
}
voldef.type = VIR_STORAGE_POOL_LOGICAL;
VIR_FREE(voldef.key);
+cleanup:
+ if (sp)
+ virUnrefStoragePool(sp);
return xml;
-
-err:
- return NULL;
}
/* The Volume Group path here will be treated as suggested in the
virCheckFlags(0, NULL);
virStoragePoolDefPtr def = NULL;
+ virStoragePoolPtr dup_sp = NULL;
virStoragePoolPtr sp = NULL;
if (!(def = virStoragePoolDefParseString(xml)))
goto err;
/* checking if this name already exists on this system */
- if (phypStoragePoolLookupByName(conn, def->name) != NULL) {
+ if ((dup_sp = phypStoragePoolLookupByName(conn, def->name)) != NULL) {
VIR_WARN("StoragePool name already exists.");
+ virUnrefStoragePool(dup_sp);
goto err;
}
/* checking if ID or UUID already exists on this system */
- if (phypGetStoragePoolLookUpByUUID(conn, def->uuid) != NULL) {
+ if ((dup_sp = phypGetStoragePoolLookUpByUUID(conn, def->uuid)) != NULL) {
VIR_WARN("StoragePool uuid already exists.");
+ virUnrefStoragePool(dup_sp);
goto err;
}