partsep = "p";
else
partsep = "";
- if (VIR_STRDUP_QUIET(canonical_path, path) < 0)
- return 2;
+ canonical_path = g_strdup(path);
} else {
if (virFileResolveLink(path, &canonical_path) != 0)
return 2;
addVol = true;
if (VIR_ALLOC(vol) < 0)
return -1;
- if (VIR_STRDUP(vol->name, partname) < 0)
- goto error;
+ vol->name = g_strdup(partname);
}
if (vol->target.path == NULL) {
- if (VIR_STRDUP(devpath, groups[0]) < 0)
- goto error;
+ devpath = g_strdup(groups[0]);
/* Now figure out the stable path
*
if (vol->key == NULL) {
/* XXX base off a unique key of the underlying disk */
- if (VIR_STRDUP(vol->key, vol->target.path) < 0)
- goto error;
+ vol->key = g_strdup(vol->target.path);
}
if (vol->source.extents == NULL) {
goto error;
}
- if (VIR_STRDUP(vol->source.extents[0].path,
- def->source.devices[0].path) < 0)
- goto error;
+ vol->source.extents[0].path = g_strdup(def->source.devices[0].path);
}
/* set partition type */
_("extended partition already exists"));
return -1;
}
- if (VIR_STRDUP(*partFormat, partedFormat) < 0)
- return -1;
+ *partFormat = g_strdup(partedFormat);
} else {
/* create primary partition as long as it is possible
and after that check if an extended partition exists
}
}
} else {
- if (VIR_STRDUP(*partFormat, "primary") < 0)
- return -1;
+ *partFormat = g_strdup("primary");
}
return 0;
}
goto cleanup;
src->nhost = 1;
- if (VIR_STRDUP(src->hosts[0].name, state->host) < 0 ||
- VIR_STRDUP(src->dir, path) < 0)
- goto cleanup;
+ src->hosts[0].name = g_strdup(state->host);
+ src->dir = g_strdup(path);
src->format = VIR_STORAGE_POOL_NETFS_NFS;
ret = 0;
if (VIR_ALLOC(ret) < 0)
return NULL;
- if (VIR_STRDUP(ret->volname, name) < 0)
- goto error;
+ ret->volname = g_strdup(name);
if (virAsprintf(&ret->dir, "%s%s", dir ? dir : "/",
trailing_slash ? "" : "/") < 0)
goto error;
* extended to allow alternate transport */
if (VIR_ALLOC(ret->uri) < 0)
goto error;
- if (VIR_STRDUP(ret->uri->scheme, "gluster") < 0)
- goto error;
- if (VIR_STRDUP(ret->uri->server, def->source.hosts[0].name) < 0)
- goto error;
+ ret->uri->scheme = g_strdup("gluster");
+ ret->uri->server = g_strdup(def->source.hosts[0].name);
if (virAsprintf(&ret->uri->path, "/%s%s", ret->volname, ret->dir) < 0)
goto error;
ret->uri->port = def->source.hosts[0].port;
if (name) {
VIR_FREE(vol->name);
- if (VIR_STRDUP(vol->name, name) < 0)
- return -1;
+ vol->name = g_strdup(name);
}
if (virAsprintf(&path, "%s%s%s", state->volname, state->dir,
state->uri->path = tmp;
/* the path is unique enough to serve as a volume key */
- if (VIR_STRDUP(vol->key, vol->target.path) < 0)
- return -1;
+ vol->key = g_strdup(vol->target.path);
return 0;
}
for (tmp_addr = addr; tmp_addr; tmp_addr = tmp_addr->next) {
g_autofree char *target = NULL;
- if (VIR_STRDUP(target, tmp_addr->target_name) < 0)
- goto cleanup;
+ target = g_strdup(tmp_addr->target_name);
if (VIR_APPEND_ELEMENT(tmp_targets, tmp_ntargets, target) < 0)
goto cleanup;
is_new_vol = true;
vol->type = VIR_STORAGE_VOL_BLOCK;
- if (VIR_STRDUP(vol->name, groups[0]) < 0)
- goto cleanup;
+ vol->name = g_strdup(groups[0]);
}
g_autofree char *pvname = NULL;
g_autofree char *vgname = NULL;
- if (VIR_STRDUP(pvname, groups[0]) < 0 ||
- VIR_STRDUP(vgname, groups[1]) < 0)
- return -1;
+ pvname = g_strdup(groups[0]);
+ vgname = g_strdup(groups[1]);
thisSource = NULL;
for (i = 0; i < sourceList->nsources; i++) {
}
/* XXX should use logical unit's UUID instead */
- if (VIR_STRDUP(vol->key, vol->target.path) < 0)
- return -1;
+ vol->key = g_strdup(vol->target.path);
if (virStoragePoolObjAddVol(pool, vol) < 0)
return -1;
if (STREQ(name, ""))
break;
- if (VIR_STRDUP(namedup, name) < 0)
- goto error;
+ namedup = g_strdup(name);
if (VIR_APPEND_ELEMENT(names, nnames, namedup) < 0)
goto error;
return -1;
}
- if (VIR_ALLOC(vol) < 0 || VIR_STRDUP(vol->name, diskInfo) < 0)
+ if (VIR_ALLOC(vol) < 0)
return -1;
+ vol->name = g_strdup(diskInfo);
+
vol->type = VIR_STORAGE_VOL_NETWORK;
if (virStorageBackendSheepdogRefreshVol(pool, vol) < 0)
return -1;
VIR_FREE(vol->target.path);
- if (VIR_STRDUP(vol->target.path, vol->name) < 0)
- return -1;
+ vol->target.path = g_strdup(vol->name);
return 0;
}
is_new_vol = true;
volume->type = VIR_STORAGE_VOL_BLOCK;
- if (VIR_STRDUP(volume->name, vol_name) < 0)
- goto cleanup;
+ volume->name = g_strdup(vol_name);
}
if (!volume->key)
def->target.path, vol->name) < 0)
return -1;
- if (VIR_STRDUP(vol->key, vol->target.path) < 0)
- goto cleanup;
+ vol->key = g_strdup(vol->target.path);
volmode_needed = virStorageBackendZFSVolModeNeeded();
if (volmode_needed < 0)
goto error;
if (privileged) {
- if (VIR_STRDUP(driver->configDir,
- SYSCONFDIR "/libvirt/storage") < 0 ||
- VIR_STRDUP(driver->autostartDir,
- SYSCONFDIR "/libvirt/storage/autostart") < 0 ||
- VIR_STRDUP(driver->stateDir,
- RUNSTATEDIR "/libvirt/storage") < 0)
- goto error;
+ driver->configDir = g_strdup(SYSCONFDIR "/libvirt/storage");
+ driver->autostartDir = g_strdup(SYSCONFDIR "/libvirt/storage/autostart");
+ driver->stateDir = g_strdup(RUNSTATEDIR "/libvirt/storage");
} else {
configdir = virGetUserConfigDirectory();
rundir = virGetUserRuntimeDirectory();
* interaction and we can just lookup the backend in the callback
* routine in order to call the refresh API.
*/
- if (VIR_ALLOC(cbdata) < 0 ||
- VIR_STRDUP(cbdata->pool_name, def->name) < 0)
- goto cleanup;
- if (voldef->type == VIR_STORAGE_VOL_PLOOP &&
- VIR_STRDUP(cbdata->vol_path, voldef->target.path) < 0)
+ if (VIR_ALLOC(cbdata) < 0)
goto cleanup;
+ cbdata->pool_name = g_strdup(def->name);
+ if (voldef->type == VIR_STORAGE_VOL_PLOOP)
+ cbdata->vol_path = g_strdup(voldef->target.path);
virStoragePoolObjIncrAsyncjobs(obj);
voldef->in_use++;
return -1;
}
} else {
- if (VIR_STRDUP(target->perms->label, filecon) < 0) {
- freecon(filecon);
- return -1;
- }
+ target->perms->label = g_strdup(filecon);
freecon(filecon);
}
}
unsigned int dir_create_flags;
g_autofree char *parent = NULL;
- if (VIR_STRDUP(parent, def->target.path) < 0)
- return -1;
+ parent = g_strdup(def->target.path);
if (!(p = strrchr(parent, '/'))) {
virReportError(VIR_ERR_INVALID_ARG,
_("path '%s' is not absolute"),
src->format = VIR_STORAGE_POOL_NETFS_GLUSTERFS;
src->dir = g_steal_pointer(&volname);
} else if (pooltype == VIR_STORAGE_POOL_GLUSTER) {
- if (VIR_STRDUP(src->dir, "/") < 0)
- goto cleanup;
+ src->dir = g_strdup("/");
src->name = g_steal_pointer(&volname);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
goto cleanup;
src->nhost = 1;
- if (VIR_STRDUP(src->hosts[0].name, host) < 0)
- goto cleanup;
+ src->hosts[0].name = g_strdup(host);
}
ret = nnodes;
if (VIR_ALLOC(vol) < 0)
goto cleanup;
- if (VIR_STRDUP(vol->name, ent->d_name) < 0)
- goto cleanup;
+ vol->name = g_strdup(ent->d_name);
vol->type = VIR_STORAGE_VOL_FILE;
if (virAsprintf(&vol->target.path, "%s/%s",
def->target.path, vol->name) < 0)
goto cleanup;
- if (VIR_STRDUP(vol->key, vol->target.path) < 0)
- goto cleanup;
+ vol->key = g_strdup(vol->target.path);
if ((err = virStorageBackendRefreshVolTargetUpdate(vol)) < 0) {
if (err == -2) {
def->target.perms.uid = target->perms->uid;
def->target.perms.gid = target->perms->gid;
VIR_FREE(def->target.perms.label);
- if (VIR_STRDUP(def->target.perms.label, target->perms->label) < 0)
- goto cleanup;
+ def->target.perms.label = g_strdup(target->perms->label);
ret = 0;
cleanup:
goto cleanup;
while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
- if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0)
- goto cleanup;
+ *block_device = g_strdup(block_dirent->d_name);
VIR_DEBUG("Block device is '%s'", *block_device);
goto cleanup;
} else {
blockp++;
- if (VIR_STRDUP(*block_device, blockp) < 0)
- goto cleanup;
+ *block_device = g_strdup(blockp);
VIR_DEBUG("Block device is '%s'", *block_device);
}
return NULL;
}
} else {
- if (VIR_STRDUP(src, def->source.devices[0].path) < 0)
- return NULL;
+ src = g_strdup(def->source.devices[0].path);
}
return src;
}