mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
util: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageSource
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
b20e957d0a
commit
bf688a0067
@ -9065,13 +9065,13 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
|
|||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
virDomainXMLOptionPtr xmlopt)
|
virDomainXMLOptionPtr xmlopt)
|
||||||
{
|
{
|
||||||
virStorageSourcePtr backingStore = NULL;
|
|
||||||
xmlNodePtr save_ctxt = ctxt->node;
|
xmlNodePtr save_ctxt = ctxt->node;
|
||||||
xmlNodePtr source;
|
xmlNodePtr source;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
char *idx = NULL;
|
char *idx = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOPTR(virStorageSource) backingStore = NULL;
|
||||||
|
|
||||||
if (!(ctxt->node = virXPathNode("./backingStore", ctxt))) {
|
if (!(ctxt->node = virXPathNode("./backingStore", ctxt))) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -9132,7 +9132,6 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageSourceFree(backingStore);
|
|
||||||
VIR_FREE(type);
|
VIR_FREE(type);
|
||||||
VIR_FREE(format);
|
VIR_FREE(format);
|
||||||
VIR_FREE(idx);
|
VIR_FREE(idx);
|
||||||
|
@ -2730,10 +2730,10 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node,
|
|||||||
{
|
{
|
||||||
xmlNodePtr savedNode = ctxt->node;
|
xmlNodePtr savedNode = ctxt->node;
|
||||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
virStorageSourcePtr migrSource = NULL;
|
|
||||||
char *format = NULL;
|
char *format = NULL;
|
||||||
char *type = NULL;
|
char *type = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOPTR(virStorageSource) migrSource = NULL;
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
@ -2781,7 +2781,6 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageSourceFree(migrSource);
|
|
||||||
VIR_FREE(format);
|
VIR_FREE(format);
|
||||||
VIR_FREE(type);
|
VIR_FREE(type);
|
||||||
ctxt->node = savedNode;
|
ctxt->node = savedNode;
|
||||||
|
@ -274,11 +274,11 @@ qemuSecurityChownCallback(const virStorageSource *src,
|
|||||||
uid_t uid,
|
uid_t uid,
|
||||||
gid_t gid)
|
gid_t gid)
|
||||||
{
|
{
|
||||||
virStorageSourcePtr cpy = NULL;
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int save_errno = 0;
|
int save_errno = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int rv;
|
int rv;
|
||||||
|
VIR_AUTOPTR(virStorageSource) cpy = NULL;
|
||||||
|
|
||||||
rv = virStorageFileSupportsSecurityDriver(src);
|
rv = virStorageFileSupportsSecurityDriver(src);
|
||||||
if (rv <= 0)
|
if (rv <= 0)
|
||||||
@ -319,7 +319,6 @@ qemuSecurityChownCallback(const virStorageSource *src,
|
|||||||
cleanup:
|
cleanup:
|
||||||
save_errno = errno;
|
save_errno = errno;
|
||||||
virStorageFileDeinit(cpy);
|
virStorageFileDeinit(cpy);
|
||||||
virStorageSourceFree(cpy);
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -17958,7 +17957,7 @@ qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
|
|||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned long long speed = bandwidth;
|
unsigned long long speed = bandwidth;
|
||||||
virStorageSourcePtr dest = NULL;
|
VIR_AUTOPTR(virStorageSource) dest = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
|
virCheckFlags(VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
|
||||||
VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT |
|
VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT |
|
||||||
@ -18020,7 +18019,6 @@ qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainObjEndAPI(&vm);
|
virDomainObjEndAPI(&vm);
|
||||||
virStorageSourceFree(dest);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18150,10 +18148,10 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|||||||
char *topPath = NULL;
|
char *topPath = NULL;
|
||||||
char *basePath = NULL;
|
char *basePath = NULL;
|
||||||
char *backingPath = NULL;
|
char *backingPath = NULL;
|
||||||
virStorageSourcePtr mirror = NULL;
|
|
||||||
unsigned long long speed = bandwidth;
|
unsigned long long speed = bandwidth;
|
||||||
qemuBlockJobDataPtr job = NULL;
|
qemuBlockJobDataPtr job = NULL;
|
||||||
qemuBlockJobType jobtype = QEMU_BLOCKJOB_TYPE_COMMIT;
|
qemuBlockJobType jobtype = QEMU_BLOCKJOB_TYPE_COMMIT;
|
||||||
|
VIR_AUTOPTR(virStorageSource) mirror = NULL;
|
||||||
|
|
||||||
/* XXX Add support for COMMIT_DELETE */
|
/* XXX Add support for COMMIT_DELETE */
|
||||||
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
|
virCheckFlags(VIR_DOMAIN_BLOCK_COMMIT_SHALLOW |
|
||||||
@ -18352,7 +18350,6 @@ qemuDomainBlockCommit(virDomainPtr dom,
|
|||||||
virFreeError(orig_err);
|
virFreeError(orig_err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virStorageSourceFree(mirror);
|
|
||||||
qemuBlockJobStartupFinalize(job);
|
qemuBlockJobStartupFinalize(job);
|
||||||
qemuDomainObjEndJob(driver, vm);
|
qemuDomainObjEndJob(driver, vm);
|
||||||
|
|
||||||
|
@ -788,9 +788,9 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
qemuBlockStorageSourceAttachDataPtr data = NULL;
|
qemuBlockStorageSourceAttachDataPtr data = NULL;
|
||||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
virStorageSourcePtr copysrc = NULL;
|
|
||||||
int mon_ret = 0;
|
int mon_ret = 0;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOPTR(virStorageSource) copysrc = NULL;
|
||||||
|
|
||||||
VIR_DEBUG("starting blockdev mirror for disk=%s to host=%s", diskAlias, host);
|
VIR_DEBUG("starting blockdev mirror for disk=%s to host=%s", diskAlias, host);
|
||||||
|
|
||||||
@ -849,7 +849,6 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qemuBlockStorageSourceAttachDataFree(data);
|
qemuBlockStorageSourceAttachDataFree(data);
|
||||||
virStorageSourceFree(copysrc);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,10 +236,10 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
glfs_fd_t *fd = NULL;
|
glfs_fd_t *fd = NULL;
|
||||||
virStorageSourcePtr meta = NULL;
|
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
int backingFormat;
|
int backingFormat;
|
||||||
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageSource) meta = NULL;
|
||||||
VIR_AUTOFREE(char *) header = NULL;
|
VIR_AUTOFREE(char *) header = NULL;
|
||||||
|
|
||||||
*volptr = NULL;
|
*volptr = NULL;
|
||||||
@ -323,7 +323,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
|
|||||||
VIR_STEAL_PTR(*volptr, vol);
|
VIR_STEAL_PTR(*volptr, vol);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageSourceFree(meta);
|
|
||||||
if (fd)
|
if (fd)
|
||||||
glfs_close(fd);
|
glfs_close(fd);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -3357,10 +3357,9 @@ storageBackendProbeTarget(virStorageSourcePtr target,
|
|||||||
virStorageEncryptionPtr *encryption)
|
virStorageEncryptionPtr *encryption)
|
||||||
{
|
{
|
||||||
int backingStoreFormat;
|
int backingStoreFormat;
|
||||||
int ret = -1;
|
|
||||||
int rc;
|
int rc;
|
||||||
virStorageSourcePtr meta = NULL;
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
VIR_AUTOPTR(virStorageSource) meta = NULL;
|
||||||
VIR_AUTOCLOSE fd = -1;
|
VIR_AUTOCLOSE fd = -1;
|
||||||
|
|
||||||
if (encryption)
|
if (encryption)
|
||||||
@ -3372,17 +3371,16 @@ storageBackendProbeTarget(virStorageSourcePtr target,
|
|||||||
fd = rc;
|
fd = rc;
|
||||||
|
|
||||||
if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb) < 0)
|
if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &sb) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (S_ISDIR(sb.st_mode)) {
|
if (S_ISDIR(sb.st_mode)) {
|
||||||
if (storageBackendIsPloopDir(target->path)) {
|
if (storageBackendIsPloopDir(target->path)) {
|
||||||
if (storageBackendRedoPloopUpdate(target, &sb, &fd,
|
if (storageBackendRedoPloopUpdate(target, &sb, &fd,
|
||||||
VIR_STORAGE_VOL_FS_PROBE_FLAGS) < 0)
|
VIR_STORAGE_VOL_FS_PROBE_FLAGS) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
target->format = VIR_STORAGE_FILE_DIR;
|
target->format = VIR_STORAGE_FILE_DIR;
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3390,11 +3388,11 @@ storageBackendProbeTarget(virStorageSourcePtr target,
|
|||||||
fd,
|
fd,
|
||||||
VIR_STORAGE_FILE_AUTO,
|
VIR_STORAGE_FILE_AUTO,
|
||||||
&backingStoreFormat)))
|
&backingStoreFormat)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (meta->backingStoreRaw) {
|
if (meta->backingStoreRaw) {
|
||||||
if (!(target->backingStore = virStorageSourceNewFromBacking(meta)))
|
if (!(target->backingStore = virStorageSourceNewFromBacking(meta)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
target->backingStore->format = backingStoreFormat;
|
target->backingStore->format = backingStoreFormat;
|
||||||
|
|
||||||
@ -3405,7 +3403,7 @@ storageBackendProbeTarget(virStorageSourcePtr target,
|
|||||||
virStorageSourceFree(target->backingStore);
|
virStorageSourceFree(target->backingStore);
|
||||||
|
|
||||||
if (VIR_ALLOC(target->backingStore) < 0)
|
if (VIR_ALLOC(target->backingStore) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
target->backingStore->type = VIR_STORAGE_TYPE_NETWORK;
|
target->backingStore->type = VIR_STORAGE_TYPE_NETWORK;
|
||||||
target->backingStore->path = meta->backingStoreRaw;
|
target->backingStore->path = meta->backingStoreRaw;
|
||||||
@ -3434,8 +3432,6 @@ storageBackendProbeTarget(virStorageSourcePtr target,
|
|||||||
target->format = meta->format;
|
target->format = meta->format;
|
||||||
|
|
||||||
/* Default to success below this point */
|
/* Default to success below this point */
|
||||||
ret = 0;
|
|
||||||
|
|
||||||
if (meta->capacity)
|
if (meta->capacity)
|
||||||
target->capacity = meta->capacity;
|
target->capacity = meta->capacity;
|
||||||
|
|
||||||
@ -3461,9 +3457,7 @@ storageBackendProbeTarget(virStorageSourcePtr target,
|
|||||||
VIR_STEAL_PTR(target->compat, meta->compat);
|
VIR_STEAL_PTR(target->compat, meta->compat);
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
return 0;
|
||||||
virStorageSourceFree(meta);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3531,11 +3525,11 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
|
|||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
struct statvfs sb;
|
struct statvfs sb;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
virStorageSourcePtr target = NULL;
|
|
||||||
int direrr;
|
int direrr;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
VIR_AUTOCLOSE fd = -1;
|
VIR_AUTOCLOSE fd = -1;
|
||||||
|
VIR_AUTOPTR(virStorageSource) target = NULL;
|
||||||
|
|
||||||
if (virDirOpen(&dir, def->target.path) < 0)
|
if (virDirOpen(&dir, def->target.path) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3626,7 +3620,6 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_DIR_CLOSE(dir);
|
VIR_DIR_CLOSE(dir);
|
||||||
virStorageSourceFree(target);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
virStoragePoolObjClearVols(pool);
|
virStoragePoolObjClearVols(pool);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -544,5 +544,6 @@ void virStorageFileReportBrokenChain(int errcode,
|
|||||||
virStorageSourcePtr parent);
|
virStorageSourcePtr parent);
|
||||||
|
|
||||||
VIR_DEFINE_AUTOPTR_FUNC(virStorageAuthDef, virStorageAuthDefFree);
|
VIR_DEFINE_AUTOPTR_FUNC(virStorageAuthDef, virStorageAuthDefFree);
|
||||||
|
VIR_DEFINE_AUTOPTR_FUNC(virStorageSource, virStorageSourceFree);
|
||||||
|
|
||||||
#endif /* LIBVIRT_VIRSTORAGEFILE_H */
|
#endif /* LIBVIRT_VIRSTORAGEFILE_H */
|
||||||
|
@ -46,14 +46,14 @@ testBackingXMLjsonXML(const void *args)
|
|||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
virStorageSourcePtr xmlsrc = NULL;
|
|
||||||
virStorageSourcePtr jsonsrc = NULL;
|
|
||||||
virJSONValuePtr backendprops = NULL;
|
virJSONValuePtr backendprops = NULL;
|
||||||
virJSONValuePtr wrapper = NULL;
|
virJSONValuePtr wrapper = NULL;
|
||||||
char *propsstr = NULL;
|
char *propsstr = NULL;
|
||||||
char *protocolwrapper = NULL;
|
char *protocolwrapper = NULL;
|
||||||
char *actualxml = NULL;
|
char *actualxml = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOPTR(virStorageSource) xmlsrc = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageSource) jsonsrc = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(xmlsrc) < 0)
|
if (VIR_ALLOC(xmlsrc) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -104,8 +104,6 @@ testBackingXMLjsonXML(const void *args)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageSourceFree(xmlsrc);
|
|
||||||
virStorageSourceFree(jsonsrc);
|
|
||||||
VIR_FREE(propsstr);
|
VIR_FREE(propsstr);
|
||||||
VIR_FREE(protocolwrapper);
|
VIR_FREE(protocolwrapper);
|
||||||
VIR_FREE(actualxml);
|
VIR_FREE(actualxml);
|
||||||
|
@ -95,7 +95,8 @@ testStorageFileGetMetadata(const char *path,
|
|||||||
uid_t uid, gid_t gid)
|
uid_t uid, gid_t gid)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
virStorageSourcePtr def = NULL;
|
virStorageSourcePtr ret = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageSource) def = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(def) < 0)
|
if (VIR_ALLOC(def) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -112,16 +113,13 @@ testStorageFileGetMetadata(const char *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_STRDUP(def->path, path) < 0)
|
if (VIR_STRDUP(def->path, path) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
if (virStorageFileGetMetadata(def, uid, gid, false) < 0)
|
if (virStorageFileGetMetadata(def, uid, gid, false) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
return def;
|
VIR_STEAL_PTR(ret, def);
|
||||||
|
return ret;
|
||||||
error:
|
|
||||||
virStorageSourceFree(def);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -308,41 +306,40 @@ static int
|
|||||||
testStorageChain(const void *args)
|
testStorageChain(const void *args)
|
||||||
{
|
{
|
||||||
const struct testChainData *data = args;
|
const struct testChainData *data = args;
|
||||||
int ret = -1;
|
|
||||||
virStorageSourcePtr meta;
|
|
||||||
virStorageSourcePtr elt;
|
virStorageSourcePtr elt;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
VIR_AUTOPTR(virStorageSource) meta = NULL;
|
||||||
VIR_AUTOFREE(char *) broken = NULL;
|
VIR_AUTOFREE(char *) broken = NULL;
|
||||||
|
|
||||||
meta = testStorageFileGetMetadata(data->start, data->format, -1, -1);
|
meta = testStorageFileGetMetadata(data->start, data->format, -1, -1);
|
||||||
if (!meta) {
|
if (!meta) {
|
||||||
if (data->flags & EXP_FAIL) {
|
if (data->flags & EXP_FAIL) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
ret = 0;
|
return 0;
|
||||||
}
|
}
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (data->flags & EXP_FAIL) {
|
} else if (data->flags & EXP_FAIL) {
|
||||||
fprintf(stderr, "call should have failed\n");
|
fprintf(stderr, "call should have failed\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (data->flags & EXP_WARN) {
|
if (data->flags & EXP_WARN) {
|
||||||
if (virGetLastErrorCode() == VIR_ERR_OK) {
|
if (virGetLastErrorCode() == VIR_ERR_OK) {
|
||||||
fprintf(stderr, "call should have warned\n");
|
fprintf(stderr, "call should have warned\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
if (virStorageFileChainGetBroken(meta, &broken) || !broken) {
|
if (virStorageFileChainGetBroken(meta, &broken) || !broken) {
|
||||||
fprintf(stderr, "call should identify broken part of chain\n");
|
fprintf(stderr, "call should identify broken part of chain\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (virGetLastErrorCode()) {
|
if (virGetLastErrorCode()) {
|
||||||
fprintf(stderr, "call should not have warned\n");
|
fprintf(stderr, "call should not have warned\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (virStorageFileChainGetBroken(meta, &broken) || broken) {
|
if (virStorageFileChainGetBroken(meta, &broken) || broken) {
|
||||||
fprintf(stderr, "chain should not be identified as broken\n");
|
fprintf(stderr, "chain should not be identified as broken\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +350,7 @@ testStorageChain(const void *args)
|
|||||||
|
|
||||||
if (i == data->nfiles) {
|
if (i == data->nfiles) {
|
||||||
fprintf(stderr, "probed chain was too long\n");
|
fprintf(stderr, "probed chain was too long\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virAsprintf(&expect,
|
if (virAsprintf(&expect,
|
||||||
@ -378,24 +375,21 @@ testStorageChain(const void *args)
|
|||||||
elt->format,
|
elt->format,
|
||||||
virStorageNetProtocolTypeToString(elt->protocol),
|
virStorageNetProtocolTypeToString(elt->protocol),
|
||||||
NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL)) < 0) {
|
NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL)) < 0) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (STRNEQ(expect, actual)) {
|
if (STRNEQ(expect, actual)) {
|
||||||
virTestDifference(stderr, expect, actual);
|
virTestDifference(stderr, expect, actual);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
elt = elt->backingStore;
|
elt = elt->backingStore;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (i != data->nfiles) {
|
if (i != data->nfiles) {
|
||||||
fprintf(stderr, "probed chain was too short\n");
|
fprintf(stderr, "probed chain was too short\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
virStorageSourceFree(meta);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct testLookupData
|
struct testLookupData
|
||||||
@ -646,9 +640,9 @@ testBackingParse(const void *args)
|
|||||||
{
|
{
|
||||||
const struct testBackingParseData *data = args;
|
const struct testBackingParseData *data = args;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
virStorageSourcePtr src = NULL;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
VIR_AUTOFREE(char *) xml = NULL;
|
VIR_AUTOFREE(char *) xml = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageSource) src = NULL;
|
||||||
|
|
||||||
if (!(src = virStorageSourceNewFromBackingAbsolute(data->backing))) {
|
if (!(src = virStorageSourceNewFromBackingAbsolute(data->backing))) {
|
||||||
if (!data->expect)
|
if (!data->expect)
|
||||||
@ -680,7 +674,6 @@ testBackingParse(const void *args)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virStorageSourceFree(src);
|
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -696,10 +689,10 @@ mymain(void)
|
|||||||
struct testPathCanonicalizeData data3;
|
struct testPathCanonicalizeData data3;
|
||||||
struct testPathRelativeBacking data4;
|
struct testPathRelativeBacking data4;
|
||||||
struct testBackingParseData data5;
|
struct testBackingParseData data5;
|
||||||
virStorageSourcePtr chain = NULL;
|
|
||||||
virStorageSourcePtr chain2; /* short for chain->backingStore */
|
virStorageSourcePtr chain2; /* short for chain->backingStore */
|
||||||
virStorageSourcePtr chain3; /* short for chain2->backingStore */
|
virStorageSourcePtr chain3; /* short for chain2->backingStore */
|
||||||
VIR_AUTOPTR(virCommand) cmd = NULL;
|
VIR_AUTOPTR(virCommand) cmd = NULL;
|
||||||
|
VIR_AUTOPTR(virStorageSource) chain = NULL;
|
||||||
|
|
||||||
if (storageRegisterAll() < 0)
|
if (storageRegisterAll() < 0)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@ -1580,7 +1573,6 @@ mymain(void)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
/* Final cleanup */
|
/* Final cleanup */
|
||||||
virStorageSourceFree(chain);
|
|
||||||
testCleanupImages();
|
testCleanupImages();
|
||||||
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
|
Loading…
Reference in New Issue
Block a user