From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCR9B-00089Z-FW for qemu-devel@nongnu.org; Mon, 13 Jun 2016 08:39:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCR96-0001Mc-09 for qemu-devel@nongnu.org; Mon, 13 Jun 2016 08:39:16 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:42757 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCR95-0001HB-Ix for qemu-devel@nongnu.org; Mon, 13 Jun 2016 08:39:11 -0400 From: "Denis V. Lunev" Date: Mon, 13 Jun 2016 15:38:55 +0300 Message-Id: <1465821535-6664-1-git-send-email-den@openvz.org> Subject: [Qemu-devel] [PATCH 1/1] block: fix libvirt snapshot with existing bitmaps List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: den@openvz.org, Vladimir Sementsov-Ogievskiy , Kevin Wolf , Max Reitz From: Vladimir Sementsov-Ogievskiy Fix the following bug: # virsh start test Domain test started # virsh qemu-monitor-command test \ '{"execute":"block-dirty-bitmap-add",\ "arguments":{"node":"drive0","name":"ab"}}' {"return":{},"id":"libvirt-36"}'}' # virsh snapshot-create test error: Unable to read from monitor: Connection reset by peer Actually, assert "assert(pos < hb->size)" in hbitmap_iter_init fires, because qcow2_save_vmstate just writes to bs (not to bs->file->bs) after the end of the drive. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Denis V. Lunev CC: Kevin Wolf CC: Max Reitz --- block/dirty-bitmap.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 4902ca5..7b636ee 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -364,6 +364,11 @@ void bdrv_set_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors) { BdrvDirtyBitmap *bitmap; + + if (cur_sector >= bdrv_nb_sectors(bs)) { + return; + } + QLIST_FOREACH(bitmap, &bs->dirty_bitmaps, list) { if (!bdrv_dirty_bitmap_enabled(bitmap)) { continue; -- 2.1.4