mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
conf: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageVolDef
Let's make use of the auto __cleanup capabilities cleaning up any now unnecessary goto paths. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
d04fbe7dab
commit
1f20da92d8
@ -1168,7 +1168,6 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virStorageVolDefPtr def;
|
|
||||||
virStorageVolDefPtr ret = NULL;
|
virStorageVolDefPtr ret = NULL;
|
||||||
virStorageVolOptionsPtr options;
|
virStorageVolOptionsPtr options;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
@ -1180,6 +1179,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) def = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY |
|
virCheckFlags(VIR_VOL_XML_PARSE_NO_CAPACITY |
|
||||||
VIR_VOL_XML_PARSE_OPT_CAPACITY, NULL);
|
VIR_VOL_XML_PARSE_OPT_CAPACITY, NULL);
|
||||||
@ -1331,7 +1331,6 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
|
|||||||
VIR_STEAL_PTR(ret, def);
|
VIR_STEAL_PTR(ret, def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageVolDefFree(def);
|
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
VIR_FREE(allocation);
|
VIR_FREE(allocation);
|
||||||
VIR_FREE(capacity);
|
VIR_FREE(capacity);
|
||||||
|
@ -461,5 +461,6 @@ VIR_ENUM_DECL(virStoragePartedFs);
|
|||||||
VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)
|
VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_POOL_TYPE)
|
||||||
|
|
||||||
VIR_DEFINE_AUTOPTR_FUNC(virStoragePoolSource, virStoragePoolSourceFree);
|
VIR_DEFINE_AUTOPTR_FUNC(virStoragePoolSource, virStoragePoolSourceFree);
|
||||||
|
VIR_DEFINE_AUTOPTR_FUNC(virStorageVolDef, virStorageVolDefFree);
|
||||||
|
|
||||||
#endif /* LIBVIRT_STORAGE_CONF_H */
|
#endif /* LIBVIRT_STORAGE_CONF_H */
|
||||||
|
@ -836,7 +836,6 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
virStorageVolPtr volume = NULL;
|
virStorageVolPtr volume = NULL;
|
||||||
esxPrivate *priv = pool->conn->privateData;
|
esxPrivate *priv = pool->conn->privateData;
|
||||||
virStoragePoolDef poolDef;
|
virStoragePoolDef poolDef;
|
||||||
virStorageVolDefPtr def = NULL;
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
char *unescapedDatastorePath = NULL;
|
char *unescapedDatastorePath = NULL;
|
||||||
char *unescapedDirectoryName = NULL;
|
char *unescapedDirectoryName = NULL;
|
||||||
@ -852,6 +851,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
char *taskInfoErrorMessage = NULL;
|
char *taskInfoErrorMessage = NULL;
|
||||||
char *uuid_string = NULL;
|
char *uuid_string = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) def = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
@ -1024,7 +1024,6 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
virtualDiskSpec->adapterType = NULL;
|
virtualDiskSpec->adapterType = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virStorageVolDefFree(def);
|
|
||||||
VIR_FREE(unescapedDatastorePath);
|
VIR_FREE(unescapedDatastorePath);
|
||||||
VIR_FREE(unescapedDirectoryName);
|
VIR_FREE(unescapedDirectoryName);
|
||||||
VIR_FREE(unescapedDirectoryAndFileName);
|
VIR_FREE(unescapedDirectoryAndFileName);
|
||||||
@ -1054,7 +1053,6 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
esxPrivate *priv = pool->conn->privateData;
|
esxPrivate *priv = pool->conn->privateData;
|
||||||
virStoragePoolDef poolDef;
|
virStoragePoolDef poolDef;
|
||||||
char *sourceDatastorePath = NULL;
|
char *sourceDatastorePath = NULL;
|
||||||
virStorageVolDefPtr def = NULL;
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
char *unescapedDatastorePath = NULL;
|
char *unescapedDatastorePath = NULL;
|
||||||
char *unescapedDirectoryName = NULL;
|
char *unescapedDirectoryName = NULL;
|
||||||
@ -1069,6 +1067,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
char *taskInfoErrorMessage = NULL;
|
char *taskInfoErrorMessage = NULL;
|
||||||
char *uuid_string = NULL;
|
char *uuid_string = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) def = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
@ -1207,7 +1206,6 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(sourceDatastorePath);
|
VIR_FREE(sourceDatastorePath);
|
||||||
virStorageVolDefFree(def);
|
|
||||||
VIR_FREE(unescapedDatastorePath);
|
VIR_FREE(unescapedDatastorePath);
|
||||||
VIR_FREE(unescapedDirectoryName);
|
VIR_FREE(unescapedDirectoryName);
|
||||||
VIR_FREE(unescapedDirectoryAndFileName);
|
VIR_FREE(unescapedDirectoryAndFileName);
|
||||||
|
@ -1952,11 +1952,11 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
{
|
{
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
virStorageVolDefPtr voldef = NULL;
|
|
||||||
virStoragePoolDefPtr spdef = NULL;
|
virStoragePoolDefPtr spdef = NULL;
|
||||||
virStorageVolPtr vol = NULL;
|
virStorageVolPtr vol = NULL;
|
||||||
virStorageVolPtr dup_vol = NULL;
|
virStorageVolPtr dup_vol = NULL;
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(spdef) < 0)
|
if (VIR_ALLOC(spdef) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2036,7 +2036,6 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
err:
|
err:
|
||||||
VIR_FREE(key);
|
VIR_FREE(key);
|
||||||
virStorageVolDefFree(voldef);
|
|
||||||
virStoragePoolDefFree(spdef);
|
virStoragePoolDefFree(spdef);
|
||||||
virObjectUnref(vol);
|
virObjectUnref(vol);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -242,12 +242,12 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||||||
virStorageVolDefPtr *volptr)
|
virStorageVolDefPtr *volptr)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virStorageVolDefPtr vol = NULL;
|
|
||||||
glfs_fd_t *fd = NULL;
|
glfs_fd_t *fd = NULL;
|
||||||
virStorageSourcePtr meta = NULL;
|
virStorageSourcePtr meta = NULL;
|
||||||
char *header = NULL;
|
char *header = NULL;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
int backingFormat;
|
int backingFormat;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
*volptr = NULL;
|
*volptr = NULL;
|
||||||
|
|
||||||
@ -331,7 +331,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageSourceFree(meta);
|
virStorageSourceFree(meta);
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
if (fd)
|
if (fd)
|
||||||
glfs_close(fd);
|
glfs_close(fd);
|
||||||
VIR_FREE(header);
|
VIR_FREE(header);
|
||||||
|
@ -305,22 +305,21 @@ virISCSIDirectRefreshVol(virStoragePoolObjPtr pool,
|
|||||||
char *portal)
|
char *portal)
|
||||||
{
|
{
|
||||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
virStorageVolDefPtr vol = NULL;
|
|
||||||
uint32_t block_size;
|
uint32_t block_size;
|
||||||
uint32_t nb_block;
|
uint32_t nb_block;
|
||||||
int ret = -1;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
virStoragePoolObjClearVols(pool);
|
virStoragePoolObjClearVols(pool);
|
||||||
if (virISCSIDirectTestUnitReady(iscsi, lun) < 0)
|
if (virISCSIDirectTestUnitReady(iscsi, lun) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (VIR_ALLOC(vol) < 0)
|
if (VIR_ALLOC(vol) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
vol->type = VIR_STORAGE_VOL_NETWORK;
|
vol->type = VIR_STORAGE_VOL_NETWORK;
|
||||||
|
|
||||||
if (virISCSIDirectGetVolumeCapacity(iscsi, lun, &block_size, &nb_block) < 0)
|
if (virISCSIDirectGetVolumeCapacity(iscsi, lun, &block_size, &nb_block) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
vol->target.capacity = block_size * nb_block;
|
vol->target.capacity = block_size * nb_block;
|
||||||
vol->target.allocation = block_size * nb_block;
|
vol->target.allocation = block_size * nb_block;
|
||||||
@ -328,17 +327,13 @@ virISCSIDirectRefreshVol(virStoragePoolObjPtr pool,
|
|||||||
def->allocation += vol->target.allocation;
|
def->allocation += vol->target.allocation;
|
||||||
|
|
||||||
if (virISCSIDirectSetVolumeAttributes(pool, vol, lun, portal) < 0)
|
if (virISCSIDirectSetVolumeAttributes(pool, vol, lun, portal) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjAddVol(pool, vol) < 0)
|
if (virStoragePoolObjAddVol(pool, vol) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
vol = NULL;
|
vol = NULL;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -46,42 +46,36 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool,
|
|||||||
const char *dev)
|
const char *dev)
|
||||||
{
|
{
|
||||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
virStorageVolDefPtr vol;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (VIR_ALLOC(vol) < 0)
|
if (VIR_ALLOC(vol) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
vol->type = VIR_STORAGE_VOL_BLOCK;
|
vol->type = VIR_STORAGE_VOL_BLOCK;
|
||||||
|
|
||||||
if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0)
|
if (virAsprintf(&(vol->name), "dm-%u", devnum) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0)
|
if (virAsprintf(&vol->target.path, "/dev/%s", dev) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStorageBackendUpdateVolInfo(vol, true,
|
if (virStorageBackendUpdateVolInfo(vol, true,
|
||||||
VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0) {
|
VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX should use logical unit's UUID instead */
|
/* XXX should use logical unit's UUID instead */
|
||||||
if (VIR_STRDUP(vol->key, vol->target.path) < 0)
|
if (VIR_STRDUP(vol->key, vol->target.path) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjAddVol(pool, vol) < 0)
|
if (virStoragePoolObjAddVol(pool, vol) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
def->capacity += vol->target.capacity;
|
def->capacity += vol->target.capacity;
|
||||||
def->allocation += vol->target.allocation;
|
def->allocation += vol->target.allocation;
|
||||||
ret = 0;
|
vol = NULL;
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
|
|
||||||
if (ret != 0)
|
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (name = names; name < names + max_size;) {
|
for (name = names; name < names + max_size;) {
|
||||||
virStorageVolDefPtr vol;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
if (STREQ(name, ""))
|
if (STREQ(name, ""))
|
||||||
break;
|
break;
|
||||||
@ -626,10 +626,8 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
|
|||||||
if (VIR_ALLOC(vol) < 0)
|
if (VIR_ALLOC(vol) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_STRDUP(vol->name, name) < 0) {
|
if (VIR_STRDUP(vol->name, name) < 0)
|
||||||
VIR_FREE(vol);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
name += strlen(name) + 1;
|
name += strlen(name) + 1;
|
||||||
|
|
||||||
@ -648,15 +646,14 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
|
|||||||
if (r == -ENOENT || r == -ETIMEDOUT)
|
if (r == -ENOENT || r == -ETIMEDOUT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virStoragePoolObjAddVol(pool, vol) < 0) {
|
if (virStoragePoolObjAddVol(pool, vol) < 0) {
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
virStoragePoolObjClearVols(pool);
|
virStoragePoolObjClearVols(pool);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
vol = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("Found %zu images in RBD pool %s",
|
VIR_DEBUG("Found %zu images in RBD pool %s",
|
||||||
|
@ -110,30 +110,27 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
|
|||||||
static int
|
static int
|
||||||
virStorageBackendSheepdogAddVolume(virStoragePoolObjPtr pool, const char *diskInfo)
|
virStorageBackendSheepdogAddVolume(virStoragePoolObjPtr pool, const char *diskInfo)
|
||||||
{
|
{
|
||||||
virStorageVolDefPtr vol = NULL;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
if (diskInfo == NULL) {
|
if (diskInfo == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Missing disk info when adding volume"));
|
_("Missing disk info when adding volume"));
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(vol) < 0 || VIR_STRDUP(vol->name, diskInfo) < 0)
|
if (VIR_ALLOC(vol) < 0 || VIR_STRDUP(vol->name, diskInfo) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
vol->type = VIR_STORAGE_VOL_NETWORK;
|
vol->type = VIR_STORAGE_VOL_NETWORK;
|
||||||
|
|
||||||
if (virStorageBackendSheepdogRefreshVol(pool, vol) < 0)
|
if (virStorageBackendSheepdogRefreshVol(pool, vol) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
if (virStoragePoolObjAddVol(pool, vol) < 0)
|
if (virStoragePoolObjAddVol(pool, vol) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
vol = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1820,8 +1820,8 @@ storageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
virStoragePoolDefPtr def;
|
virStoragePoolDefPtr def;
|
||||||
virStorageBackendPtr backend;
|
virStorageBackendPtr backend;
|
||||||
virStorageVolDefPtr voldef = NULL;
|
|
||||||
virStorageVolPtr vol = NULL, newvol = NULL;
|
virStorageVolPtr vol = NULL, newvol = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
|
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
|
||||||
|
|
||||||
@ -1941,7 +1941,6 @@ storageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(newvol);
|
virObjectUnref(newvol);
|
||||||
virStorageVolDefFree(voldef);
|
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
@ -1957,11 +1956,11 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
virStoragePoolObjPtr objsrc = NULL;
|
virStoragePoolObjPtr objsrc = NULL;
|
||||||
virStorageBackendPtr backend;
|
virStorageBackendPtr backend;
|
||||||
virStorageVolDefPtr voldefsrc = NULL;
|
virStorageVolDefPtr voldefsrc = NULL;
|
||||||
virStorageVolDefPtr voldef = NULL;
|
|
||||||
virStorageVolDefPtr shadowvol = NULL;
|
virStorageVolDefPtr shadowvol = NULL;
|
||||||
virStorageVolPtr newvol = NULL;
|
virStorageVolPtr newvol = NULL;
|
||||||
virStorageVolPtr vol = NULL;
|
virStorageVolPtr vol = NULL;
|
||||||
int buildret;
|
int buildret;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) voldef = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
|
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
|
||||||
VIR_STORAGE_VOL_CREATE_REFLINK,
|
VIR_STORAGE_VOL_CREATE_REFLINK,
|
||||||
@ -2134,7 +2133,6 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(newvol);
|
virObjectUnref(newvol);
|
||||||
virStorageVolDefFree(voldef);
|
|
||||||
VIR_FREE(shadowvol);
|
VIR_FREE(shadowvol);
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
virStoragePoolObjEndAPI(&objsrc);
|
virStoragePoolObjEndAPI(&objsrc);
|
||||||
|
@ -3672,10 +3672,10 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
|
|||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
struct statvfs sb;
|
struct statvfs sb;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
virStorageVolDefPtr vol = NULL;
|
|
||||||
virStorageSourcePtr target = NULL;
|
virStorageSourcePtr target = NULL;
|
||||||
int direrr;
|
int direrr;
|
||||||
int fd = -1, ret = -1;
|
int fd = -1, ret = -1;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
if (virDirOpen(&dir, def->target.path) < 0)
|
if (virDirOpen(&dir, def->target.path) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3767,7 +3767,6 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_DIR_CLOSE(dir);
|
VIR_DIR_CLOSE(dir);
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
virStorageSourceFree(target);
|
virStorageSourceFree(target);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
virStoragePoolObjClearVols(pool);
|
virStoragePoolObjClearVols(pool);
|
||||||
@ -3816,9 +3815,9 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
|
|||||||
const char *dev)
|
const char *dev)
|
||||||
{
|
{
|
||||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||||
virStorageVolDefPtr vol = NULL;
|
|
||||||
char *devpath = NULL;
|
char *devpath = NULL;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
/* Check if the pool is using a stable target path. The call to
|
/* Check if the pool is using a stable target path. The call to
|
||||||
* virStorageBackendStablePath will fail if the pool target path
|
* virStorageBackendStablePath will fail if the pool target path
|
||||||
@ -3898,7 +3897,6 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool,
|
|||||||
retval = 0;
|
retval = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
VIR_FREE(devpath);
|
VIR_FREE(devpath);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1025,7 @@ testOpenVolumesForPool(const char *file,
|
|||||||
size_t i;
|
size_t i;
|
||||||
int num, ret = -1;
|
int num, ret = -1;
|
||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
virStorageVolDefPtr volDef = NULL;
|
VIR_AUTOPTR(virStorageVolDef) volDef = NULL;
|
||||||
|
|
||||||
/* Find storage volumes */
|
/* Find storage volumes */
|
||||||
if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
|
if (virAsprintf(&vol_xpath, "/node/pool[%d]/volume", objidx) < 0)
|
||||||
@ -1064,7 +1064,6 @@ testOpenVolumesForPool(const char *file,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
error:
|
error:
|
||||||
virStorageVolDefFree(volDef);
|
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -5051,8 +5050,8 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
testDriverPtr privconn = pool->conn->privateData;
|
testDriverPtr privconn = pool->conn->privateData;
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
virStoragePoolDefPtr def;
|
virStoragePoolDefPtr def;
|
||||||
virStorageVolDefPtr privvol = NULL;
|
|
||||||
virStorageVolPtr ret = NULL;
|
virStorageVolPtr ret = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) privvol = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
@ -5096,7 +5095,6 @@ testStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
privvol = NULL;
|
privvol = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageVolDefFree(privvol);
|
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -5111,8 +5109,9 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
testDriverPtr privconn = pool->conn->privateData;
|
testDriverPtr privconn = pool->conn->privateData;
|
||||||
virStoragePoolObjPtr obj;
|
virStoragePoolObjPtr obj;
|
||||||
virStoragePoolDefPtr def;
|
virStoragePoolDefPtr def;
|
||||||
virStorageVolDefPtr privvol = NULL, origvol = NULL;
|
virStorageVolDefPtr origvol = NULL;
|
||||||
virStorageVolPtr ret = NULL;
|
virStorageVolPtr ret = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) privvol = NULL;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
@ -5164,7 +5163,6 @@ testStorageVolCreateXMLFrom(virStoragePoolPtr pool,
|
|||||||
privvol = NULL;
|
privvol = NULL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageVolDefFree(privvol);
|
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,6 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
const char *xml, unsigned int flags)
|
const char *xml, unsigned int flags)
|
||||||
{
|
{
|
||||||
vboxDriverPtr data = pool->conn->privateData;
|
vboxDriverPtr data = pool->conn->privateData;
|
||||||
virStorageVolDefPtr def = NULL;
|
|
||||||
PRUnichar *hddFormatUtf16 = NULL;
|
PRUnichar *hddFormatUtf16 = NULL;
|
||||||
PRUnichar *hddNameUtf16 = NULL;
|
PRUnichar *hddNameUtf16 = NULL;
|
||||||
virStoragePoolDef poolDef;
|
virStoragePoolDef poolDef;
|
||||||
@ -415,6 +414,7 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
PRUint32 variant = HardDiskVariant_Standard;
|
PRUint32 variant = HardDiskVariant_Standard;
|
||||||
resultCodeUnion resultCode;
|
resultCodeUnion resultCode;
|
||||||
virStorageVolPtr ret = NULL;
|
virStorageVolPtr ret = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) def = NULL;
|
||||||
|
|
||||||
if (!data->vboxObj)
|
if (!data->vboxObj)
|
||||||
return ret;
|
return ret;
|
||||||
@ -501,7 +501,6 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool,
|
|||||||
VBOX_RELEASE(progress);
|
VBOX_RELEASE(progress);
|
||||||
VBOX_UTF16_FREE(hddFormatUtf16);
|
VBOX_UTF16_FREE(hddFormatUtf16);
|
||||||
VBOX_UTF16_FREE(hddNameUtf16);
|
VBOX_UTF16_FREE(hddNameUtf16);
|
||||||
virStorageVolDefFree(def);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ test_vdi_list_parser(const void *opaque)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *output = NULL;
|
char *output = NULL;
|
||||||
virStoragePoolDefPtr pool = NULL;
|
virStoragePoolDefPtr pool = NULL;
|
||||||
virStorageVolDefPtr vol = NULL;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
|
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -121,7 +121,6 @@ test_vdi_list_parser(const void *opaque)
|
|||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(output);
|
VIR_FREE(output);
|
||||||
virStoragePoolDefFree(pool);
|
virStoragePoolDefFree(pool);
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +48,11 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
|
|
||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
|
|
||||||
virStorageVolDefPtr vol = NULL, inputvol = NULL;
|
|
||||||
virStoragePoolDefPtr def = NULL;
|
virStoragePoolDefPtr def = NULL;
|
||||||
virStoragePoolDefPtr inputpool = NULL;
|
virStoragePoolDefPtr inputpool = NULL;
|
||||||
virStoragePoolObjPtr obj = NULL;
|
virStoragePoolObjPtr obj = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageVolDef) inputvol = NULL;
|
||||||
|
|
||||||
if (!(def = virStoragePoolDefParseFile(poolxml)))
|
if (!(def = virStoragePoolDefParseFile(poolxml)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -139,8 +140,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStoragePoolDefFree(inputpool);
|
virStoragePoolDefFree(inputpool);
|
||||||
virStorageVolDefFree(vol);
|
|
||||||
virStorageVolDefFree(inputvol);
|
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
VIR_FREE(actualCmdline);
|
VIR_FREE(actualCmdline);
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
|
@ -20,7 +20,7 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
|||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virStoragePoolDefPtr pool = NULL;
|
virStoragePoolDefPtr pool = NULL;
|
||||||
virStorageVolDefPtr dev = NULL;
|
VIR_AUTOPTR(virStorageVolDef) dev = NULL;
|
||||||
|
|
||||||
if (!(pool = virStoragePoolDefParseFile(poolxml)))
|
if (!(pool = virStoragePoolDefParseFile(poolxml)))
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -39,7 +39,6 @@ testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
|||||||
fail:
|
fail:
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
virStoragePoolDefFree(pool);
|
virStoragePoolDefFree(pool);
|
||||||
virStorageVolDefFree(dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user