]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block/file-posix: do not fail on unlock bytes
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Fri, 29 Mar 2019 11:04:54 +0000 (14:04 +0300)
committerKevin Wolf <kwolf@redhat.com>
Tue, 2 Apr 2019 10:04:44 +0000 (12:04 +0200)
bdrv_replace_child() calls bdrv_check_perm() with error_abort on
loosening permissions. However file-locking operations may fail even
in this case, for example on NFS. And this leads to Qemu crash.

Let's avoid such errors. Note, that we ignore such things anyway on
permission update commit and abort.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/file-posix.c

index db4cccbe51a8849861be820b26225e6e88320592..1cf4ee49eb1602dda7e6d9a5e3d4276cb58f7eda 100644 (file)
@@ -815,6 +815,18 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
 
     switch (op) {
     case RAW_PL_PREPARE:
+        if ((s->perm | new_perm) == s->perm &&
+            (s->shared_perm & new_shared) == s->shared_perm)
+        {
+            /*
+             * We are going to unlock bytes, it should not fail. If it fail due
+             * to some fs-dependent permission-unrelated reasons (which occurs
+             * sometimes on NFS and leads to abort in bdrv_replace_child) we
+             * can't prevent such errors by any check here. And we ignore them
+             * anyway in ABORT and COMMIT.
+             */
+            return 0;
+        }
         ret = raw_apply_lock_bytes(s, s->fd, s->perm | new_perm,
                                    ~s->shared_perm | ~new_shared,
                                    false, errp);