* [PATCH] block-migration: Ensure we don't crash during migration cleanup
@ 2023-07-31 20:33 Fabiano Rosas
2023-08-08 8:29 ` Claudio Fontana
2023-08-08 17:08 ` Stefan Hajnoczi
0 siblings, 2 replies; 4+ messages in thread
From: Fabiano Rosas @ 2023-07-31 20:33 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-block, Stefan Hajnoczi, Fam Zheng, Juan Quintela, Peter Xu,
Leonardo Bras
We can fail the blk_insert_bs() at init_blk_migration(), leaving the
BlkMigDevState without a dirty_bitmap and BlockDriverState. Account
for the possibly missing elements when doing cleanup.
Fix the following crashes:
Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
359 BlockDriverState *bs = bitmap->bs;
#0 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
#1 0x0000555555bba331 in unset_dirty_tracking () at ../migration/block.c:371
#2 0x0000555555bbad98 in block_migration_cleanup_bmds () at ../migration/block.c:681
Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
7073 QLIST_FOREACH_SAFE(blocker, &bs->op_blockers[op], list, next) {
#0 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
#1 0x0000555555e9734a in bdrv_op_unblock_all (bs=0x0, reason=0x0) at ../block.c:7095
#2 0x0000555555bbae13 in block_migration_cleanup_bmds () at ../migration/block.c:690
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
migration/block.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/migration/block.c b/migration/block.c
index b9580a6c7e..86c2256a2b 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -368,7 +368,9 @@ static void unset_dirty_tracking(void)
BlkMigDevState *bmds;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
- bdrv_release_dirty_bitmap(bmds->dirty_bitmap);
+ if (bmds->dirty_bitmap) {
+ bdrv_release_dirty_bitmap(bmds->dirty_bitmap);
+ }
}
}
@@ -676,13 +678,18 @@ static int64_t get_remaining_dirty(void)
static void block_migration_cleanup_bmds(void)
{
BlkMigDevState *bmds;
+ BlockDriverState *bs;
AioContext *ctx;
unset_dirty_tracking();
while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
- bdrv_op_unblock_all(blk_bs(bmds->blk), bmds->blocker);
+
+ bs = blk_bs(bmds->blk);
+ if (bs) {
+ bdrv_op_unblock_all(bs, bmds->blocker);
+ }
error_free(bmds->blocker);
/* Save ctx, because bmds->blk can disappear during blk_unref. */
--
2.35.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block-migration: Ensure we don't crash during migration cleanup
2023-07-31 20:33 [PATCH] block-migration: Ensure we don't crash during migration cleanup Fabiano Rosas
@ 2023-08-08 8:29 ` Claudio Fontana
2023-08-08 17:08 ` Stefan Hajnoczi
1 sibling, 0 replies; 4+ messages in thread
From: Claudio Fontana @ 2023-08-08 8:29 UTC (permalink / raw)
To: Fabiano Rosas, qemu-devel, Kevin Wolf, Hanna Reitz
Cc: qemu-block, Stefan Hajnoczi, Fam Zheng, Juan Quintela, Peter Xu,
Leonardo Bras
added Kevin and Hanna for block, since this seems still untouched?
Thanks,
Claudio
On 7/31/23 22:33, Fabiano Rosas wrote:
> We can fail the blk_insert_bs() at init_blk_migration(), leaving the
> BlkMigDevState without a dirty_bitmap and BlockDriverState. Account
> for the possibly missing elements when doing cleanup.
>
> Fix the following crashes:
>
> Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
> 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
> 359 BlockDriverState *bs = bitmap->bs;
> #0 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
> #1 0x0000555555bba331 in unset_dirty_tracking () at ../migration/block.c:371
> #2 0x0000555555bbad98 in block_migration_cleanup_bmds () at ../migration/block.c:681
>
> Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
> 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
> 7073 QLIST_FOREACH_SAFE(blocker, &bs->op_blockers[op], list, next) {
> #0 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
> #1 0x0000555555e9734a in bdrv_op_unblock_all (bs=0x0, reason=0x0) at ../block.c:7095
> #2 0x0000555555bbae13 in block_migration_cleanup_bmds () at ../migration/block.c:690
>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
> migration/block.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/migration/block.c b/migration/block.c
> index b9580a6c7e..86c2256a2b 100644
> --- a/migration/block.c
> +++ b/migration/block.c
> @@ -368,7 +368,9 @@ static void unset_dirty_tracking(void)
> BlkMigDevState *bmds;
>
> QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
> - bdrv_release_dirty_bitmap(bmds->dirty_bitmap);
> + if (bmds->dirty_bitmap) {
> + bdrv_release_dirty_bitmap(bmds->dirty_bitmap);
> + }
> }
> }
>
> @@ -676,13 +678,18 @@ static int64_t get_remaining_dirty(void)
> static void block_migration_cleanup_bmds(void)
> {
> BlkMigDevState *bmds;
> + BlockDriverState *bs;
> AioContext *ctx;
>
> unset_dirty_tracking();
>
> while ((bmds = QSIMPLEQ_FIRST(&block_mig_state.bmds_list)) != NULL) {
> QSIMPLEQ_REMOVE_HEAD(&block_mig_state.bmds_list, entry);
> - bdrv_op_unblock_all(blk_bs(bmds->blk), bmds->blocker);
> +
> + bs = blk_bs(bmds->blk);
> + if (bs) {
> + bdrv_op_unblock_all(bs, bmds->blocker);
> + }
> error_free(bmds->blocker);
>
> /* Save ctx, because bmds->blk can disappear during blk_unref. */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block-migration: Ensure we don't crash during migration cleanup
2023-07-31 20:33 [PATCH] block-migration: Ensure we don't crash during migration cleanup Fabiano Rosas
2023-08-08 8:29 ` Claudio Fontana
@ 2023-08-08 17:08 ` Stefan Hajnoczi
2023-08-09 9:02 ` Claudio Fontana
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2023-08-08 17:08 UTC (permalink / raw)
To: Fabiano Rosas
Cc: qemu-devel, qemu-block, Fam Zheng, Juan Quintela, Peter Xu,
Leonardo Bras, qemu-stable
[-- Attachment #1: Type: text/plain, Size: 1840 bytes --]
On Mon, Jul 31, 2023 at 05:33:38PM -0300, Fabiano Rosas wrote:
> We can fail the blk_insert_bs() at init_blk_migration(), leaving the
> BlkMigDevState without a dirty_bitmap and BlockDriverState. Account
> for the possibly missing elements when doing cleanup.
>
> Fix the following crashes:
>
> Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
> 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
> 359 BlockDriverState *bs = bitmap->bs;
> #0 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
> #1 0x0000555555bba331 in unset_dirty_tracking () at ../migration/block.c:371
> #2 0x0000555555bbad98 in block_migration_cleanup_bmds () at ../migration/block.c:681
>
> Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
> 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
> 7073 QLIST_FOREACH_SAFE(blocker, &bs->op_blockers[op], list, next) {
> #0 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
> #1 0x0000555555e9734a in bdrv_op_unblock_all (bs=0x0, reason=0x0) at ../block.c:7095
> #2 0x0000555555bbae13 in block_migration_cleanup_bmds () at ../migration/block.c:690
>
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
> migration/block.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
Sorry, I missed this patch!
If this needs to be in QEMU 8.1 (-rc3 is being tagged today), please
reply and provide a justification. At this point only security fixes and
showstoppers will be merged. Thanks!
Applied to my block-next tree for QEMU 8.2:
https://gitlab.com/stefanha/qemu/commits/block-next
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block-migration: Ensure we don't crash during migration cleanup
2023-08-08 17:08 ` Stefan Hajnoczi
@ 2023-08-09 9:02 ` Claudio Fontana
0 siblings, 0 replies; 4+ messages in thread
From: Claudio Fontana @ 2023-08-09 9:02 UTC (permalink / raw)
To: Stefan Hajnoczi, Fabiano Rosas
Cc: qemu-devel, qemu-block, Fam Zheng, Juan Quintela, Peter Xu,
Leonardo Bras, qemu-stable
On 8/8/23 19:08, Stefan Hajnoczi wrote:
> On Mon, Jul 31, 2023 at 05:33:38PM -0300, Fabiano Rosas wrote:
>> We can fail the blk_insert_bs() at init_blk_migration(), leaving the
>> BlkMigDevState without a dirty_bitmap and BlockDriverState. Account
>> for the possibly missing elements when doing cleanup.
>>
>> Fix the following crashes:
>>
>> Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
>> 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
>> 359 BlockDriverState *bs = bitmap->bs;
>> #0 0x0000555555ec83ef in bdrv_release_dirty_bitmap (bitmap=0x0) at ../block/dirty-bitmap.c:359
>> #1 0x0000555555bba331 in unset_dirty_tracking () at ../migration/block.c:371
>> #2 0x0000555555bbad98 in block_migration_cleanup_bmds () at ../migration/block.c:681
>>
>> Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault.
>> 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
>> 7073 QLIST_FOREACH_SAFE(blocker, &bs->op_blockers[op], list, next) {
>> #0 0x0000555555e971ff in bdrv_op_unblock (bs=0x0, op=BLOCK_OP_TYPE_BACKUP_SOURCE, reason=0x0) at ../block.c:7073
>> #1 0x0000555555e9734a in bdrv_op_unblock_all (bs=0x0, reason=0x0) at ../block.c:7095
>> #2 0x0000555555bbae13 in block_migration_cleanup_bmds () at ../migration/block.c:690
>>
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>> migration/block.c | 11 +++++++++--
>> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> Sorry, I missed this patch!
>
> If this needs to be in QEMU 8.1 (-rc3 is being tagged today), please
> reply and provide a justification. At this point only security fixes and
> showstoppers will be merged. Thanks!
>
> Applied to my block-next tree for QEMU 8.2:
> https://gitlab.com/stefanha/qemu/commits/block-next
>
> Stefan
Thanks, and in my personal view I think it's ok for 8.2, IIUC it happens during the migration to file work which is not in 8.1 anyway,
Fabiano correct me here if I am wrong,
Ciao,
Claudio
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-09 9:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-31 20:33 [PATCH] block-migration: Ensure we don't crash during migration cleanup Fabiano Rosas
2023-08-08 8:29 ` Claudio Fontana
2023-08-08 17:08 ` Stefan Hajnoczi
2023-08-09 9:02 ` Claudio Fontana
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).