thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-block-Fix-invalidate_cache-error-path-for-parent-act.patch

ae23c9
From 6123c29fcf385010a683061fd7f948f256713b48 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Fri, 17 May 2019 14:23:15 +0100
ae23c9
Subject: [PATCH 4/5] block: Fix invalidate_cache error path for parent
ae23c9
 activation
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20190517142315.16266-2-kwolf@redhat.com>
ae23c9
Patchwork-id: 88024
ae23c9
O-Subject: [RHEL-8.1 qemu-kvm PATCH 1/1] block: Fix invalidate_cache error path for parent activation
ae23c9
Bugzilla: 1673010
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ae23c9
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
ae23c9
ae23c9
bdrv_co_invalidate_cache() clears the BDRV_O_INACTIVE flag before
ae23c9
actually activating a node so that the correct permissions etc. are
ae23c9
taken. In case of errors, the flag must be restored so that the next
ae23c9
call to bdrv_co_invalidate_cache() retries activation.
ae23c9
ae23c9
Restoring the flag was missing in the error path for a failed
ae23c9
parent->role->activate() call. The consequence is that this attempt to
ae23c9
activate all images correctly fails because we still set errp, however
ae23c9
on the next attempt BDRV_O_INACTIVE is already clear, so we return
ae23c9
success without actually retrying the failed action.
ae23c9
ae23c9
An example where this is observable in practice is migration to a QEMU
ae23c9
instance that has a raw format block node attached to a guest device
ae23c9
with share-rw=off (the default) while another process holds
ae23c9
BLK_PERM_WRITE for the same image. In this case, all activation steps
ae23c9
before parent->role->activate() succeed because raw can tolerate other
ae23c9
writers to the image. Only the parent callback (in particular
ae23c9
blk_root_activate()) tries to implement the share-rw=on property and
ae23c9
requests exclusive write permissions. This fails when the migration
ae23c9
completes and correctly displays an error. However, a manual 'cont' will
ae23c9
incorrectly resume the VM without calling blk_root_activate() again.
ae23c9
ae23c9
This case is described in more detail in the following bug report:
ae23c9
https://bugzilla.redhat.com/show_bug.cgi?id=1531888
ae23c9
ae23c9
Fix this by correctly restoring the BDRV_O_INACTIVE flag in the error
ae23c9
path.
ae23c9
ae23c9
Cc: qemu-stable@nongnu.org
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Tested-by: Markus Armbruster <armbru@redhat.com>
ae23c9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
(cherry picked from commit 78fc3b3a26c145eebcdee992988644974b243a74)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 block.c | 1 +
ae23c9
 1 file changed, 1 insertion(+)
ae23c9
ae23c9
diff --git a/block.c b/block.c
ae23c9
index d0f0dc6..82b16df 100644
ae23c9
--- a/block.c
ae23c9
+++ b/block.c
ae23c9
@@ -4417,6 +4417,7 @@ static void coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs,
ae23c9
         if (parent->role->activate) {
ae23c9
             parent->role->activate(parent, &local_err);
ae23c9
             if (local_err) {
ae23c9
+                bs->open_flags |= BDRV_O_INACTIVE;
ae23c9
                 error_propagate(errp, local_err);
ae23c9
                 return;
ae23c9
             }
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9