virNetClientProgram **prog)
{
virNetClient *client = NULL;
- char *lockdpath;
- char *daemonPath = NULL;
+ g_autofree char *lockdpath = NULL;
+ g_autofree char *daemonPath = NULL;
*prog = NULL;
if (virNetClientAddProgram(client, *prog) < 0)
goto error;
- VIR_FREE(daemonPath);
- VIR_FREE(lockdpath);
-
return client;
error:
- VIR_FREE(daemonPath);
- VIR_FREE(lockdpath);
virNetClientClose(client);
virObjectUnref(client);
virObjectUnref(*prog);
unsigned int flags)
{
virLockManagerLockDaemonPrivate *priv = lock->privateData;
- char *newName = NULL;
- char *newLockspace = NULL;
+ g_autofree char *newName = NULL;
+ g_autofree char *newLockspace = NULL;
bool autoCreate = false;
- int ret = -1;
virCheckFlags(VIR_LOCK_MANAGER_RESOURCE_READONLY |
VIR_LOCK_MANAGER_RESOURCE_SHARED, -1);
if (params || nparams) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unexpected parameters for disk resource"));
- goto cleanup;
+ return -1;
}
if (!driver->autoDiskLease) {
if (!(flags & (VIR_LOCK_MANAGER_RESOURCE_SHARED |
driver->lvmLockSpaceDir) {
VIR_DEBUG("Trying to find an LVM UUID for %s", name);
if (virLockManagerGetLVMKey(name, &newName) < 0)
- goto cleanup;
+ return -1;
if (newName) {
VIR_DEBUG("Got an LVM UUID %s for %s", newName, name);
driver->scsiLockSpaceDir) {
VIR_DEBUG("Trying to find an SCSI ID for %s", name);
if (virStorageFileGetSCSIKey(name, &newName, false) < 0)
- goto cleanup;
+ return -1;
if (newName) {
VIR_DEBUG("Got an SCSI ID %s for %s", newName, name);
if (driver->fileLockSpaceDir) {
newLockspace = g_strdup(driver->fileLockSpaceDir);
if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &newName) < 0)
- goto cleanup;
+ return -1;
autoCreate = true;
VIR_DEBUG("Using indirect lease %s for %s", newName, name);
} else {
if (params[i].value.ul != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Offset must be zero for this lock manager"));
- goto cleanup;
+ return -1;
}
} else if (STREQ(params[i].key, "lockspace")) {
lockspace = params[i].value.str;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected parameter %s for lease resource"),
params[i].key);
- goto cleanup;
+ return -1;
}
}
if (!path || !lockspace) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing path or lockspace for lease resource"));
- goto cleanup;
+ return -1;
}
newLockspace = g_strdup_printf("%s/%s", path, lockspace);
newName = g_strdup(name);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown lock manager object type %d"),
type);
- goto cleanup;
+ return -1;
}
VIR_EXPAND_N(priv->resources, priv->nresources, 1);
priv->resources[priv->nresources-1].flags |=
VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE;
- ret = 0;
- cleanup:
- VIR_FREE(newLockspace);
- VIR_FREE(newName);
- return ret;
+ return 0;
}
const char *configFile)
{
g_autoptr(virConf) conf = NULL;
- int ret = -1;
- char *user = NULL;
- char *group = NULL;
+ g_autofree char *user = NULL;
+ g_autofree char *group = NULL;
if (access(configFile, R_OK) == -1) {
if (errno != ENOENT) {
return -1;
if (virConfGetValueBool(conf, "auto_disk_leases", &driver->autoDiskLease) < 0)
- goto cleanup;
+ return -1;
if (virConfGetValueString(conf, "disk_lease_dir", &driver->autoDiskLeasePath) < 0)
- goto cleanup;
+ return -1;
if (virConfGetValueUInt(conf, "host_id", &driver->hostID) < 0)
- goto cleanup;
+ return -1;
driver->requireLeaseForDisks = !driver->autoDiskLease;
if (virConfGetValueBool(conf, "require_lease_for_disks", &driver->requireLeaseForDisks) < 0)
- goto cleanup;
+ return -1;
if (virConfGetValueUInt(conf, "io_timeout", &driver->io_timeout) < 0)
- goto cleanup;
+ return -1;
if (virConfGetValueString(conf, "user", &user) < 0)
- goto cleanup;
+ return -1;
if (user &&
virGetUserID(user, &driver->user) < 0)
- goto cleanup;
+ return -1;
if (virConfGetValueString(conf, "group", &group) < 0)
- goto cleanup;
+ return -1;
if (group &&
virGetGroupID(group, &driver->group) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- VIR_FREE(user);
- VIR_FREE(group);
- return ret;
+ return 0;
}
static int
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *path;
- char *args = NULL;
- int ret = -1;
+ g_autofree char *args = NULL;
int rv;
switch (action) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Failure action %s is not supported by sanlock"),
virDomainLockFailureTypeToString(action));
- goto cleanup;
+ return -1;
}
virBufferEscape(&buf, '\\', "\\ ", "%s", vmuri);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Sanlock helper path is longer than %d: '%s'"),
SANLK_HELPER_PATH_LEN - 1, path);
- goto cleanup;
+ return -1;
}
if (strlen(args) >= SANLK_HELPER_ARGS_LEN) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Sanlock helper arguments are longer than %d:"
" '%s'"),
SANLK_HELPER_ARGS_LEN - 1, args);
- goto cleanup;
+ return -1;
}
if ((rv = sanlock_killpath(sock, 0, path, args)) < 0) {
_("Failed to register lock failure"
" action"));
}
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- VIR_FREE(args);
- return ret;
+ return 0;
}
static int virLockManagerSanlockAcquire(virLockManager *lock,