]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virtlockd: Don't report error if lockspace exists
authorJim Fehlig <jfehlig@suse.com>
Wed, 30 Jun 2021 22:36:42 +0000 (16:36 -0600)
committerJim Fehlig <jfehlig@suse.com>
Wed, 7 Jul 2021 15:40:38 +0000 (09:40 -0600)
When the qemu or libxl driver is configured to use lockd and
file_lockspace_dir is set, virtlockd emits an error when libvirtd
is retarted

May 25 15:44:31 virt81 virtlockd[7723]: Requested operation is not
valid: Lockspace for path /data/libvirtd/lockspace already exists

There is really no need to fail when the lockspace already exists,
paricularly since the user is expected to create the lockspace
specified in file_lockspace_dir. Failure to do so will prevent
starting any domains

virsh start test
error: Failed to start domain 'test'
error: Unable to open/create resource /data/libvirtd/lockspace/de22c4bf931e7c48b49e8ca64b477d44e78a51543e534df488b05ccd08ec5caa: No such file or directory

Also, virLockManagerLockDaemonSetupLockspace already has logic to ignore
the error. Since callers are not interested in the error, change
virtlockd to not report or return an error when the specified lockspace
already exists.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/locking/lock_daemon_dispatch.c
src/locking/lock_driver_lockd.c

index e8b98324536ab3b7b0db47fb1c3bf6ff4aee8891..13e688f2e2c6b304f0b3f102244937cee9139a4b 100644 (file)
@@ -405,9 +405,8 @@ virLockSpaceProtocolDispatchCreateLockSpace(virNetServer *server G_GNUC_UNUSED,
     }
 
     if (virLockDaemonFindLockSpace(lockDaemon, args->path) != NULL) {
-        virReportError(VIR_ERR_OPERATION_INVALID,
-                       _("Lockspace for path %s already exists"),
-                       args->path);
+        VIR_DEBUG("Lockspace for path %s already exists", args->path);
+        rv = 0;
         goto cleanup;
     }
 
index 3a7386af304c9ee3f14c1bc46b066f6d5f144c9d..87afdbfb784f05aceb0bebcd7e25e140cf42a6af 100644 (file)
@@ -281,15 +281,8 @@ static int virLockManagerLockDaemonSetupLockspace(const char *path)
                                 VIR_LOCK_SPACE_PROTOCOL_PROC_CREATE_LOCKSPACE,
                                 0, NULL, NULL, NULL,
                                 (xdrproc_t)xdr_virLockSpaceProtocolCreateLockSpaceArgs, (char*)&args,
-                                (xdrproc_t)xdr_void, NULL) < 0) {
-        if (virGetLastErrorCode() == VIR_ERR_OPERATION_INVALID) {
-            /* The lockspace already exists */
-            virResetLastError();
-            rv = 0;
-        } else {
-            goto cleanup;
-        }
-    }
+                                (xdrproc_t)xdr_void, NULL) < 0)
+        goto cleanup;
 
     rv = 0;