From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
peter.maydell@linaro.org, vsementsov@virtuozzo.com,
"open list:qcow2" <qemu-block@nongnu.org>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH for 4.2-rc5 1/1] block/qcow2-bitmap: fix crash bug in qcow2_co_remove_persistent_dirty_bitmap
Date: Mon, 9 Dec 2019 12:03:15 -0500 [thread overview]
Message-ID: <aa4571a2-2386-a9f0-a9a2-a51dbf6b146f@redhat.com> (raw)
In-Reply-To: <20191209161607.20894-1-eblake@redhat.com>
Did you mean to mark this as [PULL] ?
On 12/9/19 11:16 AM, Eric Blake wrote:
> From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>
> Here is double bug:
>
> First, return error but not set errp. This may lead to:
> qmp block-dirty-bitmap-remove may report success when actually failed
>
> block-dirty-bitmap-remove used in a transaction will crash, as
> qmp_transaction will think that it returned success and will call
> block_dirty_bitmap_remove_commit which will crash, as state->bitmap is
> NULL
>
> Second (like in anecdote), this case is not an error at all. As it is
> documented in the comment above bdrv_co_remove_persistent_dirty_bitmap
> definition, absence of bitmap is not an error, and similar case handled
> at start of qcow2_co_remove_persistent_dirty_bitmap, it returns 0 when
> there is no bitmaps at all.
>
> But when there are some bitmaps, but not the requested one, it return
> error with errp unset.
>
> Fix that.
>
> Trigger:
> 1. create persistent bitmap A
> 2. shutdown vm (bitmap A is synced)
> 3. start vm
> 4. create persistent bitmap B
> 5. remove bitmap B - it fails (and crashes if in transaction)
>
> Potential workaround (rather invasive to ask clients to implement it):
> 1. create persistent bitmap A
> 2. shutdown vm
> 3. start vm
> 4. create persistent bitmap B
> 5. remember, that we want to remove bitmap B after vm shutdown
> ...
> some other operations
> ...
> 6. vm shutdown
> 7. start vm in stopped mode, and remove all bitmaps marked for removing
> 8. stop vm
>
> Fixes: b56a1e31759b750
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Message-Id: <20191205193049.30666-1-vsementsov@virtuozzo.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: John Snow <jsnow@redhat.com>
> [eblake: commit message tweaks]
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> block/qcow2-bitmap.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index 8abaf632fc7d..c6c8ebbe89d4 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -1469,8 +1469,10 @@ int coroutine_fn qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs,
> Qcow2BitmapList *bm_list;
>
> if (s->nb_bitmaps == 0) {
> - /* Absence of the bitmap is not an error: see explanation above
> - * bdrv_remove_persistent_dirty_bitmap() definition. */
> + /*
> + * Absence of the bitmap is not an error: see explanation above
> + * bdrv_co_remove_persistent_dirty_bitmap() definition.
> + */
> return 0;
> }
>
> @@ -1485,7 +1487,8 @@ int coroutine_fn qcow2_co_remove_persistent_dirty_bitmap(BlockDriverState *bs,
>
> bm = find_bitmap_by_name(bm_list, name);
> if (bm == NULL) {
> - ret = -EINVAL;
> + /* Absence of the bitmap is not an error, see above. */
> + ret = 0;
> goto out;
> }
>
--
—js
next prev parent reply other threads:[~2019-12-09 17:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 16:00 [PULL for 4.2-rc5 0/1] Bitmap fix for 2019-12-09 Eric Blake
2019-12-09 16:00 ` [PULL 1/1] pseries: Update SLOF firmware image Eric Blake
2019-12-09 16:13 ` Eric Blake
2019-12-09 16:13 ` Greg Kurz
2019-12-09 16:16 ` [PATCH for 4.2-rc5 1/1] block/qcow2-bitmap: fix crash bug in qcow2_co_remove_persistent_dirty_bitmap Eric Blake
2019-12-09 17:03 ` John Snow [this message]
2019-12-09 22:01 ` Eric Blake
2019-12-09 17:12 ` [PULL for 4.2-rc5 0/1] Bitmap fix for 2019-12-09 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aa4571a2-2386-a9f0-a9a2-a51dbf6b146f@redhat.com \
--to=jsnow@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).