yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-file-posix-do-not-fail-on-unlock-bytes.patch

ae23c9
From 87240c5fcfb3e3ba68c5c87d2175f2dd98921a7e Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Wed, 3 Apr 2019 17:13:15 +0100
ae23c9
Subject: [PATCH 08/11] block/file-posix: do not fail on unlock bytes
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20190403171315.20841-9-mreitz@redhat.com>
ae23c9
Patchwork-id: 85406
ae23c9
O-Subject: [RHEL-8.1 qemu-kvm PATCH 8/8] block/file-posix: do not fail on unlock bytes
ae23c9
Bugzilla: 1694148
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
ae23c9
ae23c9
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
ae23c9
bdrv_replace_child() calls bdrv_check_perm() with error_abort on
ae23c9
loosening permissions. However file-locking operations may fail even
ae23c9
in this case, for example on NFS. And this leads to Qemu crash.
ae23c9
ae23c9
Let's avoid such errors. Note, that we ignore such things anyway on
ae23c9
permission update commit and abort.
ae23c9
ae23c9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
(cherry picked from commit 696aaaed579ac5bf5fa336216909b46d3d8f07a8)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 block/file-posix.c | 12 ++++++++++++
ae23c9
 1 file changed, 12 insertions(+)
ae23c9
ae23c9
diff --git a/block/file-posix.c b/block/file-posix.c
ae23c9
index deecf58..5fb5a9a 100644
ae23c9
--- a/block/file-posix.c
ae23c9
+++ b/block/file-posix.c
ae23c9
@@ -800,6 +800,18 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
ae23c9
 
ae23c9
     switch (op) {
ae23c9
     case RAW_PL_PREPARE:
ae23c9
+        if ((s->perm | new_perm) == s->perm &&
ae23c9
+            (s->shared_perm & new_shared) == s->shared_perm)
ae23c9
+        {
ae23c9
+            /*
ae23c9
+             * We are going to unlock bytes, it should not fail. If it fail due
ae23c9
+             * to some fs-dependent permission-unrelated reasons (which occurs
ae23c9
+             * sometimes on NFS and leads to abort in bdrv_replace_child) we
ae23c9
+             * can't prevent such errors by any check here. And we ignore them
ae23c9
+             * anyway in ABORT and COMMIT.
ae23c9
+             */
ae23c9
+            return 0;
ae23c9
+        }
ae23c9
         ret = raw_apply_lock_bytes(s, s->fd, s->perm | new_perm,
ae23c9
                                    ~s->shared_perm | ~new_shared,
ae23c9
                                    false, errp);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9