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