Skip to content

Commit

Permalink
blockdev: fix missed target unref for drive-backup
Browse files Browse the repository at this point in the history
If the bitmap can't be used for whatever reason, we skip putting down
the reference. Fix that.

In practice, this means that if you attempt to gracefully exit QEMU
after a backup command being rejected, bdrv_close_all will fail and
tell you some unpleasant things via assert().

Reported-by: aihua liang <[email protected]>
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1703916
Signed-off-by: John Snow <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
jnsnow authored and kevmw committed Jun 4, 2019
1 parent ac6fb43 commit 4da26f1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3546,20 +3546,18 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
if (set_backing_hd) {
bdrv_set_backing_hd(target_bs, source, &local_err);
if (local_err) {
bdrv_unref(target_bs);
goto out;
goto unref;
}
}

if (backup->has_bitmap) {
bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
if (!bmap) {
error_setg(errp, "Bitmap '%s' could not be found", backup->bitmap);
bdrv_unref(target_bs);
goto out;
goto unref;
}
if (bdrv_dirty_bitmap_check(bmap, BDRV_BITMAP_DEFAULT, errp)) {
goto out;
goto unref;
}
}
if (!backup->auto_finalize) {
Expand All @@ -3573,12 +3571,13 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn,
backup->sync, bmap, backup->compress,
backup->on_source_error, backup->on_target_error,
job_flags, NULL, NULL, txn, &local_err);
bdrv_unref(target_bs);
if (local_err != NULL) {
error_propagate(errp, local_err);
goto out;
goto unref;
}

unref:
bdrv_unref(target_bs);
out:
aio_context_release(aio_context);
return job;
Expand Down

0 comments on commit 4da26f1

Please sign in to comment.