const char *drvparent = NULL;
const char *parentnodename = NULL;
const char *filename = NULL;
- int ret = -1;
if (!nodename)
return 0;
}
if (VIR_ALLOC(data) < 0)
- goto cleanup;
+ return -1;
if (VIR_STRDUP(data->nodeformat, nodename) < 0 ||
VIR_STRDUP(data->nodestorage, parentnodename) < 0 ||
VIR_STRDUP(data->qemufilename, filename) < 0 ||
VIR_STRDUP(data->drvformat, drvname) < 0 ||
VIR_STRDUP(data->drvstorage, drvparent) < 0)
- goto cleanup;
+ return -1;
if (backing &&
qemuBlockNodeNameGetBackingChainBacking(backing, nodenamestable,
&backingdata) < 0)
- goto cleanup;
+ return -1;
VIR_STEAL_PTR(data->backing, backingdata);
VIR_STEAL_PTR(*nodenamedata, data);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
struct qemuBlockNodeNameGetBackingChainData *data = opaque;
const char *device = virJSONValueObjectGetString(item, "device");
VIR_AUTOPTR(qemuBlockNodeNameBackingChainData) devicedata = NULL;
- int ret = -1;
if (qemuBlockNodeNameGetBackingChainBacking(item, data->nodenamestable,
&devicedata) < 0)
- goto cleanup;
+ return -1;
if (devicedata &&
virHashAddEntry(data->disks, device, devicedata) < 0)
- goto cleanup;
+ return -1;
devicedata = NULL;
- ret = 1; /* we don't really want to steal @item */
-
- cleanup:
-
- return ret;
+ return 1; /* we don't really want to steal @item */
}
memset(&data, 0, sizeof(data));
if (!(namednodestable = virHashCreate(50, virJSONValueHashFree)))
- goto cleanup;
+ return NULL;
if (virJSONValueArrayForeachSteal(namednodes,
qemuBlockNamedNodesArrayToHash,
namednodestable) < 0)
- goto cleanup;
+ return NULL;
if (!(disks = virHashCreate(50, qemuBlockNodeNameBackingChainDataHashEntryFree)))
- goto cleanup;
+ return NULL;
data.nodenamestable = namednodestable;
data.disks = disks;
if (virJSONValueArrayForeachSteal(blockstats,
qemuBlockNodeNameGetBackingChainDisk,
&data) < 0)
- goto cleanup;
+ return NULL;
VIR_STEAL_PTR(ret, disks);
-
- cleanup:
-
- return ret;
+ return ret;
}
VIR_AUTOPTR(virJSONValue) blockstats = NULL;
virDomainDiskDefPtr disk;
size_t i;
- int ret = -1;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_NAMED_BLOCK_NODES))
return 0;
blockstats = qemuMonitorQueryBlockstats(qemuDomainGetMonitor(vm));
if (qemuDomainObjExitMonitor(driver, vm) < 0 || !data || !blockstats)
- goto cleanup;
+ return -1;
if (!(disktable = qemuBlockNodeNameGetBackingChain(data, blockstats)))
- goto cleanup;
+ return -1;
for (i = 0; i < vm->def->ndisks; i++) {
disk = vm->def->disks[i];
if (qemuBlockDiskDetectNodes(disk, disktable) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
-
- return ret;
+ return 0;
}
if (virJSONValueArrayForeachSteal(data,
qemuBlockNamedNodesArrayToHash, nodedata) < 0)
- goto error;
+ return NULL;
VIR_STEAL_PTR(ret, nodedata);
return ret;
-
- error:
- return NULL;
}
virReportError(VIR_ERR_INTERNAL_ERROR,
_("protocol '%s' accepts only one host"),
virStorageNetProtocolTypeToString(src->protocol));
- goto cleanup;
+ return NULL;
}
if (VIR_ALLOC(uri) < 0)
- goto cleanup;
+ return NULL;
if (src->hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP) {
uri->port = src->hosts->port;
if (VIR_STRDUP(uri->scheme,
virStorageNetProtocolTypeToString(src->protocol)) < 0)
- goto cleanup;
+ return NULL;
} else {
if (virAsprintf(&uri->scheme, "%s+%s",
virStorageNetProtocolTypeToString(src->protocol),
virStorageNetHostTransportTypeToString(src->hosts->transport)) < 0)
- goto cleanup;
+ return NULL;
}
if (src->path) {
if (src->volume) {
if (virAsprintf(&uri->path, "/%s/%s",
src->volume, src->path) < 0)
- goto cleanup;
+ return NULL;
} else {
if (virAsprintf(&uri->path, "%s%s",
src->path[0] == '/' ? "" : "/",
src->path) < 0)
- goto cleanup;
+ return NULL;
}
}
if (VIR_STRDUP(uri->server, src->hosts->name) < 0)
- goto cleanup;
+ return NULL;
VIR_STEAL_PTR(ret, uri);
-
- cleanup:
return ret;
}
transport = "inet";
if (virAsprintf(&port, "%u", host->port) < 0)
- goto cleanup;
+ return NULL;
if (virJSONValueObjectCreate(&server,
"s:type", transport,
"s:host", host->name,
"s:port", port,
NULL) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_STORAGE_NET_HOST_TRANS_UNIX:
"s:type", "unix",
field, host->socket,
NULL) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_STORAGE_NET_HOST_TRANS_RDMA:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("transport protocol '%s' is not yet supported"),
virStorageNetHostTransportTypeToString(host->transport));
- goto cleanup;
+ return NULL;
}
VIR_STEAL_PTR(ret, server);
-
- cleanup:
-
return ret;
}
size_t i;
if (!(servers = virJSONValueNewArray()))
- goto cleanup;
+ return NULL;
for (i = 0; i < src->nhosts; i++) {
host = src->hosts + i;
if (!(server = qemuBlockStorageSourceBuildJSONSocketAddress(host, legacy)))
- goto cleanup;
+ return NULL;
if (virJSONValueArrayAppend(servers, server) < 0)
- goto cleanup;
+ return NULL;
server = NULL;
}
VIR_STEAL_PTR(ret, servers);
-
- cleanup:
-
return ret;
}
size_t i;
if (!(servers = virJSONValueNewArray()))
- goto cleanup;
+ return NULL;
for (i = 0; i < src->nhosts; i++) {
host = src->hosts + i;
if (!(server = qemuBlockStorageSourceBuildJSONInetSocketAddress(host)))
- goto cleanup;
+ return NULL;
if (virJSONValueArrayAppend(servers, server) < 0)
- goto cleanup;
+ return NULL;
server = NULL;
}
VIR_STEAL_PTR(ret, servers);
-
- cleanup:
-
return ret;
}
"s:volume", src->volume,
"s:path", src->path,
"a:server", &servers, NULL) < 0)
- goto cleanup;
+ return NULL;
if (src->debug &&
virJSONValueObjectAdd(props, "u:debug", src->debugLevel, NULL) < 0)
- goto cleanup;
+ return NULL;
VIR_STEAL_PTR(ret, props);
-
- cleanup:
-
return ret;
}
driver = virStorageNetProtocolTypeToString(src->protocol);
if (!(uri = qemuBlockStorageSourceGetURI(src)))
- goto cleanup;
+ return NULL;
if (!(uristr = virURIFormat(uri)))
- goto cleanup;
+ return NULL;
if (src->auth) {
username = src->auth->username;
"S:password-secret", passwordalias,
NULL));
- cleanup:
-
return ret;
}
*/
if (VIR_STRDUP(target, src->path) < 0)
- goto cleanup;
+ return NULL;
/* Separate the target and lun */
if ((lunStr = strchr(target, '/'))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse target for lunStr '%s'"),
target);
- goto cleanup;
+ return NULL;
}
}
if (virSocketAddrNumericFamily(src->hosts[0].name) == AF_INET6) {
if (virAsprintf(&portal, "[%s]:%u",
src->hosts[0].name, src->hosts[0].port) < 0)
- goto cleanup;
+ return NULL;
} else {
if (virAsprintf(&portal, "%s:%u",
src->hosts[0].name, src->hosts[0].port) < 0)
- goto cleanup;
+ return NULL;
}
if (src->auth) {
"S:password-secret", objalias,
"S:initiator-name", src->initiator.iqn,
NULL));
- goto cleanup;
-
- cleanup:
return ret;
}
"S:export", src->path,
"S:tls-creds", src->tlsAlias,
NULL) < 0)
- goto cleanup;
+ return NULL;
- cleanup:
return ret;
}
keysecret = srcPriv->secinfo->s.aes.alias;
/* the auth modes are modelled after our old command line generator */
if (!(authmodes = virJSONValueNewArray()))
- goto cleanup;
+ return NULL;
if (!(mode = virJSONValueNewString("cephx")) ||
virJSONValueArrayAppend(authmodes, mode) < 0)
- goto cleanup;
+ return NULL;
mode = NULL;
if (!(mode = virJSONValueNewString("none")) ||
virJSONValueArrayAppend(authmodes, mode) < 0)
- goto cleanup;
+ return NULL;
mode = NULL;
}
"A:auth-client-required", &authmodes,
"S:key-secret", keysecret,
NULL) < 0)
- goto cleanup;
+ return NULL;
- cleanup:
return ret;
}
"a:server", &serverprops,
"s:vdi", src->path,
NULL) < 0)
- goto cleanup;
+ return NULL;
- cleanup:
return ret;
}
"a:server", &serverprops,
"S:user", username,
NULL) < 0)
- goto cleanup;
+ return NULL;
- cleanup:
return ret;
}
if (qemuBlockNodeNameValidate(src->nodestorage) < 0 ||
virJSONValueObjectAdd(fileprops, "S:node-name", src->nodestorage, NULL) < 0)
- goto cleanup;
+ return NULL;
if (!legacy) {
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, fileprops) < 0)
- goto cleanup;
+ return NULL;
if (virJSONValueObjectAdd(fileprops,
"b:read-only", src->readonly,
"s:discard", "unmap",
NULL) < 0)
- goto cleanup;
+ return NULL;
}
VIR_STEAL_PTR(ret, fileprops);
-
- cleanup:
return ret;
}
virJSONValuePtr props)
{
VIR_AUTOPTR(virJSONValue) encprops = NULL;
- int ret = -1;
if (qemuBlockStorageSourceGetCryptoProps(src, &encprops) < 0)
return -1;
if (virJSONValueObjectAdd(props,
"s:driver", format,
"A:encrypt", &encprops, NULL) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
return NULL;
if (qemuBlockStorageSourceGetBlockdevGetCacheProps(src, props) < 0)
- goto cleanup;
+ return NULL;
VIR_STEAL_PTR(ret, props);
-
- cleanup:
return ret;
}
virJSONValuePtr ret = NULL;
if (!(props = qemuBlockStorageSourceGetBlockdevFormatCommonProps(src)))
- goto cleanup;
+ return NULL;
switch ((virStorageFileFormat) src->format) {
case VIR_STORAGE_FILE_FAT:
* put a raw layer on top */
case VIR_STORAGE_FILE_RAW:
if (qemuBlockStorageSourceGetFormatRawProps(src, props) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_STORAGE_FILE_QCOW2:
if (qemuBlockStorageSourceGetFormatQcow2Props(src, props) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_STORAGE_FILE_QCOW:
if (qemuBlockStorageSourceGetFormatQcowGenericProps(src, "qcow", props) < 0)
- goto cleanup;
+ return NULL;
break;
/* formats without any special parameters */
virReportError(VIR_ERR_INTERNAL_ERROR,
_("mishandled storage format '%s'"),
virStorageFileFormatTypeToString(src->format));
- goto cleanup;
+ return NULL;
case VIR_STORAGE_FILE_LAST:
default:
virReportEnumRangeError(virStorageFileFormat, src->format);
- goto cleanup;
+ return NULL;
}
if (driver &&
virJSONValueObjectAdd(props, "s:driver", driver, NULL) < 0)
- goto cleanup;
+ return NULL;
VIR_STEAL_PTR(ret, props);
-
- cleanup:
-
return ret;
}
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("storage format '%s' does not support backing store"),
virStorageFileFormatTypeToString(src->format));
- goto cleanup;
+ return NULL;
}
if (!(props = qemuBlockStorageSourceGetBlockdevFormatProps(src)))
- goto cleanup;
+ return NULL;
if (virJSONValueObjectAppendString(props, "file", src->nodestorage) < 0)
- goto cleanup;
+ return NULL;
if (src->backingStore && backingSupported) {
if (virStorageSourceHasBacking(src)) {
if (virJSONValueObjectAppendString(props, "backing",
src->backingStore->nodeformat) < 0)
- goto cleanup;
+ return NULL;
} else {
/* chain is terminated, indicate that no detection should happen
* in qemu */
if (virJSONValueObjectAppendNull(props, "backing") < 0)
- goto cleanup;
+ return NULL;
}
}
VIR_STEAL_PTR(ret, props);
-
- cleanup:
return ret;
}
if (!(data->formatProps = qemuBlockStorageSourceGetBlockdevProps(src)) ||
!(data->storageProps = qemuBlockStorageSourceGetBackendProps(src, false)))
- goto cleanup;
+ return NULL;
data->storageNodeName = src->nodestorage;
data->formatNodeName = src->nodeformat;
VIR_STEAL_PTR(ret, data);
-
- cleanup:
return ret;
}
const char *format = virStorageFileFormatTypeToString(newsrc->format);
VIR_AUTOFREE(char *) device = NULL;
VIR_AUTOFREE(char *) source = NULL;
- int ret = -1;
if (!(device = qemuAliasDiskDriveFromDisk(disk)))
- goto cleanup;
+ return -1;
if (qemuGetDriveSourceString(newsrc, NULL, &source) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONTransactionAdd(actions, "blockdev-snapshot-sync",
"s:device", device,
"s:format", format,
"S:mode", reuse ? "existing" : NULL,
NULL) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}