2012-08-03 09:27:07 +00:00
|
|
|
/*
|
|
|
|
* lock_daemon_dispatch.c: lock management daemon dispatch
|
|
|
|
*
|
2015-03-16 14:02:41 +00:00
|
|
|
* Copyright (C) 2006-2015 Red Hat, Inc.
|
2012-08-03 09:27:07 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2015-03-16 14:02:41 +00:00
|
|
|
#include "rpc/virnetdaemon.h"
|
2012-08-03 09:27:07 +00:00
|
|
|
#include "rpc/virnetserverclient.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2013-05-03 12:43:12 +00:00
|
|
|
#include "virstring.h"
|
2012-08-03 09:27:07 +00:00
|
|
|
#include "lock_daemon.h"
|
|
|
|
#include "lock_protocol.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2015-03-11 12:58:42 +00:00
|
|
|
#include "virthreadjob.h"
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_RPC
|
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("locking.lock_daemon_dispatch");
|
|
|
|
|
|
|
|
#include "lock_daemon_dispatch_stubs.h"
|
|
|
|
|
2012-08-03 09:27:07 +00:00
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolAcquireResourceArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
unsigned int flags = args->flags;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
virLockSpacePtr lockspace;
|
|
|
|
unsigned int newFlags;
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
virCheckFlagsGoto(VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED |
|
2018-10-02 13:10:18 +00:00
|
|
|
VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE, cleanup);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-16 17:32:42 +00:00
|
|
|
if (!priv->ownerId) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("lock owner details have not been registered"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Lockspace for path %s does not exist"),
|
|
|
|
args->path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
newFlags = 0;
|
|
|
|
if (flags & VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED)
|
|
|
|
newFlags |= VIR_LOCK_SPACE_ACQUIRE_SHARED;
|
|
|
|
if (flags & VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE)
|
|
|
|
newFlags |= VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE;
|
|
|
|
|
|
|
|
if (virLockSpaceAcquireResource(lockspace,
|
|
|
|
args->name,
|
|
|
|
priv->ownerPid,
|
|
|
|
newFlags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchCreateResource(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolCreateResourceArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
unsigned int flags = args->flags;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
virLockSpacePtr lockspace;
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
virCheckFlagsGoto(0, cleanup);
|
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-16 17:32:42 +00:00
|
|
|
if (!priv->ownerId) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("lock owner details have not been registered"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Lockspace for path %s does not exist"),
|
|
|
|
args->path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virLockSpaceCreateResource(lockspace, args->name) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchDeleteResource(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolDeleteResourceArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
unsigned int flags = args->flags;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
virLockSpacePtr lockspace;
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
virCheckFlagsGoto(0, cleanup);
|
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-16 17:32:42 +00:00
|
|
|
if (!priv->ownerId) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("lock owner details have not been registered"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Lockspace for path %s does not exist"),
|
|
|
|
args->path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virLockSpaceDeleteResource(lockspace, args->name) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchNew(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolNewArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
unsigned int flags = args->flags;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
virLockSpacePtr lockspace;
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
virCheckFlagsGoto(0, cleanup);
|
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-16 17:32:42 +00:00
|
|
|
if (!priv->ownerId) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("lock owner details have not been registered"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!args->path || STREQ(args->path, "")) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("the default lockspace already exists"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-01-15 18:38:16 +00:00
|
|
|
if (virLockDaemonFindLockSpace(lockDaemon, args->path) != NULL) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Lockspace for path %s already exists"),
|
|
|
|
args->path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
virResetLastError();
|
|
|
|
|
|
|
|
lockspace = virLockSpaceNew(args->path);
|
|
|
|
virLockDaemonAddLockSpace(lockDaemon, args->path, lockspace);
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchRegister(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolRegisterArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
unsigned int flags = args->flags;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
virCheckFlagsGoto(0, cleanup);
|
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-16 17:32:42 +00:00
|
|
|
if (!args->owner.id) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
2015-04-16 17:32:42 +00:00
|
|
|
_("lock owner details have not been registered"));
|
2012-08-03 09:27:07 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2019-10-20 11:49:46 +00:00
|
|
|
priv->ownerName = g_strdup(args->owner.name);
|
2012-08-03 09:27:07 +00:00
|
|
|
memcpy(priv->ownerUUID, args->owner.uuid, VIR_UUID_BUFLEN);
|
|
|
|
priv->ownerId = args->owner.id;
|
|
|
|
priv->ownerPid = args->owner.pid;
|
|
|
|
VIR_DEBUG("ownerName=%s ownerId=%d ownerPid=%lld",
|
|
|
|
priv->ownerName, priv->ownerId, (unsigned long long)priv->ownerPid);
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchReleaseResource(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolReleaseResourceArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
unsigned int flags = args->flags;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
virLockSpacePtr lockspace;
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
virCheckFlagsGoto(0, cleanup);
|
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-16 17:32:42 +00:00
|
|
|
if (!priv->ownerId) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("lock owner details have not been registered"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Lockspace for path %s does not exist"),
|
|
|
|
args->path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virLockSpaceReleaseResource(lockspace,
|
|
|
|
args->name,
|
|
|
|
priv->ownerPid) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchRestrict(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolRestrictArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
unsigned int flags = args->flags;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
virCheckFlagsGoto(0, cleanup);
|
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2015-04-16 17:32:42 +00:00
|
|
|
if (!priv->ownerId) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("lock owner details have not been registered"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->restricted = true;
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2019-10-14 12:45:33 +00:00
|
|
|
virLockSpaceProtocolDispatchCreateLockSpace(virNetServerPtr server G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetServerClientPtr client,
|
2019-10-14 12:45:33 +00:00
|
|
|
virNetMessagePtr msg G_GNUC_UNUSED,
|
2012-08-03 09:27:07 +00:00
|
|
|
virNetMessageErrorPtr rerr,
|
|
|
|
virLockSpaceProtocolCreateLockSpaceArgs *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
|
|
|
virLockDaemonClientPtr priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
virLockSpacePtr lockspace;
|
|
|
|
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_lock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
|
|
|
|
if (priv->restricted) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_DENIED, "%s",
|
|
|
|
_("lock manager connection has been restricted"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-01-15 18:38:16 +00:00
|
|
|
if (virLockDaemonFindLockSpace(lockDaemon, args->path) != NULL) {
|
2012-08-03 09:27:07 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("Lockspace for path %s already exists"),
|
|
|
|
args->path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(lockspace = virLockSpaceNew(args->path)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virLockDaemonAddLockSpace(lockDaemon, args->path, lockspace) < 0) {
|
|
|
|
virLockSpaceFree(lockspace);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
2014-03-25 06:51:47 +00:00
|
|
|
cleanup:
|
2012-08-03 09:27:07 +00:00
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
2020-08-05 07:56:18 +00:00
|
|
|
g_mutex_unlock(&priv->lock);
|
2012-08-03 09:27:07 +00:00
|
|
|
return rv;
|
|
|
|
}
|