From nobody Mon Apr 29 07:25:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155233054163912.717780700122944; Mon, 11 Mar 2019 11:55:41 -0700 (PDT) Received: from localhost ([127.0.0.1]:38608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q5G-0007YU-Kz for importer@patchew.org; Mon, 11 Mar 2019 14:55:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q1h-0004rD-1e for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3Q1g-0005N5-4I for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:52 -0400 Received: from relay.sw.ru ([185.231.240.75]:42238) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3Q1f-0005K1-QI; Mon, 11 Mar 2019 14:51:52 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h3Q1c-0001S0-0T; Mon, 11 Mar 2019 21:51:48 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 11 Mar 2019 21:51:44 +0300 Message-Id: <20190311185147.52309-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190311185147.52309-1-vsementsov@virtuozzo.com> References: <20190311185147.52309-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 1/4] docs/interop/qcow2: Improve bitmap flag in_use specification X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, den@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We already use (we didn't notice it) IN_USE flag for marking bitmap metadata outdated, such as AUTO flag, which mirrors enabled/disabled bitmaps. No we are going to support bitmap resize, so it's good to write IN_USE meaning with more details. Signed-off-by: Vladimir Sementsov-Ogievskiy --- docs/interop/qcow2.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt index fb5cb47245..575a5f25e2 100644 --- a/docs/interop/qcow2.txt +++ b/docs/interop/qcow2.txt @@ -589,7 +589,19 @@ Structure of a bitmap directory entry: Bit 0: in_use The bitmap was not saved correctly and may be - inconsistent. + inconsistent. This inconsitency may touch both bi= tmap + data and metadata, and this mean that bitmap state + (its data and metadata) was changed but not stored + back to the image. This flag doesn't relate to fo= rmat + corruption, all fields are still correct from qco= w2 + point of view, they just may be outdated. + + Note: Currently, Qemu may change (additionally to + bitmap data) @auto flag and size of the bitmap du= ring + image resize. This mean, that not only bitmap data + may be outdated if @in_use flag set, but also val= ue of + @auto flag and bitmap size (which is indirectly + referenced by @bitmap_table_size). =20 1: auto The bitmap must reflect all changes of the virtual @@ -717,8 +729,8 @@ corresponding range of the virtual disk (see above) was= written to while the bitmap was 'enabled'. An unset bit means that this range was not written t= o. =20 The software doesn't have to sync the bitmap in the image file with its -representation in RAM after each write. Flag 'in_use' should be set while = the -bitmap is not synced. +representation in RAM after each write or metadata change. Flag 'in_use' +should be set while the bitmap is not synced. =20 In the image file the 'enabled' state is reflected by the 'auto' flag. If = this flag is set, the software must consider the bitmap as 'enabled' and start --=20 2.18.0 From nobody Mon Apr 29 07:25:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552330458443972.3752495736114; Mon, 11 Mar 2019 11:54:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:38569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q41-0006Zg-FS for importer@patchew.org; Mon, 11 Mar 2019 14:54:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q1h-0004r8-0r for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3Q1g-0005Mt-3Q for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:52 -0400 Received: from relay.sw.ru ([185.231.240.75]:42234) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3Q1f-0005Jz-QH; Mon, 11 Mar 2019 14:51:52 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h3Q1c-0001S0-8B; Mon, 11 Mar 2019 21:51:48 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 11 Mar 2019 21:51:45 +0300 Message-Id: <20190311185147.52309-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190311185147.52309-1-vsementsov@virtuozzo.com> References: <20190311185147.52309-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 2/4] block/qcow2-bitmap: Don't check size for IN_USE bitmap X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, den@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We are going to allow image resize when there are persistent bitmaps. It may lead to appearing of inconsistent bitmaps (IN_USE=3D1) with inconsistent size. But we still want to load them as inconsistent. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-bitmap.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 6adbe06b4d..141bc1e52c 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -462,10 +462,25 @@ static int check_dir_entry(BlockDriverState *bs, Qcow= 2BitmapDirEntry *entry) return len; } =20 - fail =3D (phys_bitmap_bytes > BME_MAX_PHYS_SIZE) || - (len > ((phys_bitmap_bytes * 8) << entry->granularity_bits)); + if (phys_bitmap_bytes > BME_MAX_PHYS_SIZE) { + return -EINVAL; + } =20 - return fail ? -EINVAL : 0; + if (!(entry->flags & BME_FLAG_IN_USE) && + (len > ((phys_bitmap_bytes * 8) << entry->granularity_bits))) + { + /* + * We've loaded valid bitmap (IN_USE not set) or we are going to s= tore + * valid bitmap. But allocated bitmap table size is not enough to = store + * such bitmap. + * + * Note, that it's OK to have invalid bitmap with invalid size dur= ing to + * bitmap was not correctly saved after image resize. + */ + return -EINVAL; + } + + return 0; } =20 static inline void bitmap_directory_to_be(uint8_t *dir, size_t size) --=20 2.18.0 From nobody Mon Apr 29 07:25:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552330667691925.8798755598908; Mon, 11 Mar 2019 11:57:47 -0700 (PDT) Received: from localhost ([127.0.0.1]:38627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q7O-0000iy-PP for importer@patchew.org; Mon, 11 Mar 2019 14:57:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q1h-0004rb-CC for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3Q1g-0005NE-4X for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:53 -0400 Received: from relay.sw.ru ([185.231.240.75]:42242) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3Q1f-0005Kp-QC; Mon, 11 Mar 2019 14:51:52 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h3Q1c-0001S0-Jl; Mon, 11 Mar 2019 21:51:48 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 11 Mar 2019 21:51:46 +0300 Message-Id: <20190311185147.52309-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190311185147.52309-1-vsementsov@virtuozzo.com> References: <20190311185147.52309-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 3/4] block/qcow2-bitmap: Allow resizes with persistent bitmaps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, den@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: John Snow Since we now load all bitmaps into memory anyway, we can just truncate them in-memory and then flush them back to disk. Just in case, we will still check and enforce that this shortcut is valid -- i.e. that any bitmap described on-disk is indeed in-memory and can be modified. If there are any inconsistent bitmaps, we refuse to allow the truncate as we do not actually load these bitmaps into memory, and it isn't safe or reasonable to attempt to truncate corrupted data. Signed-off-by: John Snow Signed-off-by: Vladimir Sementsov-Ogievskiy [vsementsov: drop bitmap flushing, fix block comments style] --- block/qcow2.h | 1 + block/qcow2-bitmap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ block/qcow2.c | 4 +--- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 9dd02df831..bbac694a84 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -689,6 +689,7 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDr= iverState *bs, int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, bool *header_update= d, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); +int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp); void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **er= rp); int qcow2_reopen_bitmaps_ro(BlockDriverState *bs, Error **errp); bool qcow2_can_store_new_dirty_bitmap(BlockDriverState *bs, diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index 141bc1e52c..6ffeae36c2 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1174,6 +1174,52 @@ int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Er= ror **errp) return qcow2_reopen_bitmaps_rw_hint(bs, NULL, errp); } =20 +/* Checks to see if it's safe to resize bitmaps */ +int qcow2_truncate_bitmaps_check(BlockDriverState *bs, Error **errp) +{ + BDRVQcow2State *s =3D bs->opaque; + Qcow2BitmapList *bm_list; + Qcow2Bitmap *bm; + int ret =3D 0; + + if (s->nb_bitmaps =3D=3D 0) { + return 0; + } + + bm_list =3D bitmap_list_load(bs, s->bitmap_directory_offset, + s->bitmap_directory_size, errp); + if (bm_list =3D=3D NULL) { + return -EINVAL; + } + + QSIMPLEQ_FOREACH(bm, bm_list, entry) { + BdrvDirtyBitmap *bitmap =3D bdrv_find_dirty_bitmap(bs, bm->name); + if (bitmap =3D=3D NULL) { + /* + * We rely on all bitmaps being in-memory to be able to resize= them, + * Otherwise, we'd need to resize them on disk explicitly + */ + error_setg(errp, "Cannot resize qcow2 with persistent bitmaps = that " + "were not loaded into memory"); + ret =3D -ENOTSUP; + goto out; + } + + /* + * The checks against readonly and busy are redundant, but certain= ly + * do no harm. checks against inconsistent are crucial: + */ + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { + ret =3D -ENOTSUP; + goto out; + } + } + +out: + bitmap_list_free(bm_list); + return ret; +} + /* store_bitmap_data() * Store bitmap to image, filling bitmap table accordingly. */ diff --git a/block/qcow2.c b/block/qcow2.c index 7fb2730f09..da2697f912 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3499,9 +3499,7 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, } =20 /* cannot proceed if image has bitmaps */ - if (s->nb_bitmaps) { - /* TODO: resize bitmaps in the image */ - error_setg(errp, "Can't resize an image which has bitmaps"); + if (qcow2_truncate_bitmaps_check(bs, errp)) { ret =3D -ENOTSUP; goto fail; } --=20 2.18.0 From nobody Mon Apr 29 07:25:26 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552330652410420.7314036850296; Mon, 11 Mar 2019 11:57:32 -0700 (PDT) Received: from localhost ([127.0.0.1]:38625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q73-0000TW-Rz for importer@patchew.org; Mon, 11 Mar 2019 14:57:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Q1i-0004sh-D0 for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3Q1g-0005NN-6N for qemu-devel@nongnu.org; Mon, 11 Mar 2019 14:51:54 -0400 Received: from relay.sw.ru ([185.231.240.75]:42248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3Q1f-0005Kq-Ou; Mon, 11 Mar 2019 14:51:52 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h3Q1d-0001S0-2q; Mon, 11 Mar 2019 21:51:49 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 11 Mar 2019 21:51:47 +0300 Message-Id: <20190311185147.52309-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190311185147.52309-1-vsementsov@virtuozzo.com> References: <20190311185147.52309-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 4/4] tests/qemu-iotests: add bitmap resize test 246 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, den@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: John Snow Test that we can actually resize qcow2 images with persistent bitmaps correctly. Throw some other goofy stuff at the test while we're at it, like adding bitmaps of different granularities and at different times. Signed-off-by: John Snow Signed-off-by: Vladimir Sementsov-Ogievskiy [vsmentsov: drop \n from the end of test output, test output changed a bit: some bitmaps goes in other order int the output] Tested-by: Eric Blake --- tests/qemu-iotests/246 | 114 ++++++++++++++ tests/qemu-iotests/246.out | 295 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 410 insertions(+) create mode 100755 tests/qemu-iotests/246 create mode 100644 tests/qemu-iotests/246.out diff --git a/tests/qemu-iotests/246 b/tests/qemu-iotests/246 new file mode 100755 index 0000000000..b0997a392f --- /dev/null +++ b/tests/qemu-iotests/246 @@ -0,0 +1,114 @@ +#!/usr/bin/env python +# +# Test persistent bitmap resizing. +# +# Copyright (c) 2019 John Snow for Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# owner=3Djsnow@redhat.com + +import iotests +from iotests import log + +iotests.verify_image_format(supported_fmts=3D['qcow2']) +size =3D 64 * 1024 * 1024 * 1024 +gran_small =3D 32 * 1024 +gran_large =3D 128 * 1024 + +def query_bitmaps(vm): + res =3D vm.qmp("query-block") + return { "bitmaps": { device['device']: device.get('dirty-bitmaps', []= ) for + device in res['return'] } } + +with iotests.FilePath('img') as img_path, \ + iotests.VM() as vm: + + log('--- Preparing image & VM ---\n') + iotests.qemu_img_create('-f', iotests.imgfmt, img_path, str(size)) + vm.add_drive(img_path) + + + log('--- 1st Boot (Establish Baseline Image) ---\n') + vm.launch() + + log('\n--- Adding bitmaps Small, Medium, Large, and Transient ---\n') + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"Small", granularity=3Dgran_small, persistent=3DTrue) + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"Medium", persistent=3DTrue) + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"Large", granularity=3Dgran_large, persistent=3DTrue) + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"Transient", persistent=3DFalse) + + log('--- Forcing flush of bitmaps to disk ---\n') + log(query_bitmaps(vm), indent=3D2) + vm.shutdown() + + + log('--- 2nd Boot (Grow Image) ---\n') + vm.launch() + log(query_bitmaps(vm), indent=3D2) + + log('--- Adding new bitmap, growing image, and adding 2nd new bitmap -= --') + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"New", persistent=3DTrue) + vm.qmp_log("human-monitor-command", + command_line=3D"block_resize drive0 70G") + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"Newtwo", persistent=3DTrue) + log(query_bitmaps(vm), indent=3D2) + + log('--- Forcing flush of bitmaps to disk ---\n') + vm.shutdown() + + + log('--- 3rd Boot (Shrink Image) ---\n') + vm.launch() + log(query_bitmaps(vm), indent=3D2) + + log('--- Adding "NewB" bitmap, removing "New" bitmap ---') + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"NewB", persistent=3DTrue) + vm.qmp_log("block-dirty-bitmap-remove", node=3D"drive0", + name=3D"New") + + log('--- Truncating image ---\n') + vm.qmp_log("human-monitor-command", + command_line=3D"block_resize drive0 50G") + + log('--- Adding "NewC" bitmap, removing "NewTwo" bitmap ---') + vm.qmp_log("block-dirty-bitmap-add", node=3D"drive0", + name=3D"NewC", persistent=3DTrue) + vm.qmp_log("block-dirty-bitmap-remove", node=3D"drive0", name=3D"Newtw= o") + + log('--- Forcing flush of bitmaps to disk ---\n') + vm.shutdown() + + + log('--- 4th Boot (Verification and Cleanup) ---\n') + vm.launch() + log(query_bitmaps(vm), indent=3D2) + + log('--- Removing all Bitmaps ---\n') + vm.qmp_log("block-dirty-bitmap-remove", node=3D"drive0", name=3D"Small= ") + vm.qmp_log("block-dirty-bitmap-remove", node=3D"drive0", name=3D"Mediu= m") + vm.qmp_log("block-dirty-bitmap-remove", node=3D"drive0", name=3D"Large= ") + vm.qmp_log("block-dirty-bitmap-remove", node=3D"drive0", name=3D"NewB") + vm.qmp_log("block-dirty-bitmap-remove", node=3D"drive0", name=3D"NewC") + log(query_bitmaps(vm), indent=3D2) + + log('\n--- Done ---') + vm.shutdown() diff --git a/tests/qemu-iotests/246.out b/tests/qemu-iotests/246.out new file mode 100644 index 0000000000..6671a11fdd --- /dev/null +++ b/tests/qemu-iotests/246.out @@ -0,0 +1,295 @@ +--- Preparing image & VM --- + +--- 1st Boot (Establish Baseline Image) --- + + +--- Adding bitmaps Small, Medium, Large, and Transient --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 32768, = "name": "Small", "node": "drive0", "persistent": true}} +{"return": {}} +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "Medium", "nod= e": "drive0", "persistent": true}} +{"return": {}} +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 131072,= "name": "Large", "node": "drive0", "persistent": true}} +{"return": {}} +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "Transient", "= node": "drive0", "persistent": false}} +{"return": {}} +--- Forcing flush of bitmaps to disk --- + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Transient", + "persistent": false, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 131072, + "name": "Large", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Medium", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 32768, + "name": "Small", + "persistent": true, + "recording": true, + "status": "active" + } + ] + } +} +--- 2nd Boot (Grow Image) --- + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 32768, + "name": "Small", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Medium", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 131072, + "name": "Large", + "persistent": true, + "recording": true, + "status": "active" + } + ] + } +} +--- Adding new bitmap, growing image, and adding 2nd new bitmap --- +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "New", "node":= "drive0", "persistent": true}} +{"return": {}} +{"execute": "human-monitor-command", "arguments": {"command-line": "block_= resize drive0 70G"}} +{"return": ""} +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "Newtwo", "nod= e": "drive0", "persistent": true}} +{"return": {}} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Newtwo", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "New", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 32768, + "name": "Small", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Medium", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 131072, + "name": "Large", + "persistent": true, + "recording": true, + "status": "active" + } + ] + } +} +--- Forcing flush of bitmaps to disk --- + +--- 3rd Boot (Shrink Image) --- + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "New", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Newtwo", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 32768, + "name": "Small", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Medium", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 131072, + "name": "Large", + "persistent": true, + "recording": true, + "status": "active" + } + ] + } +} +--- Adding "NewB" bitmap, removing "New" bitmap --- +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "NewB", "node"= : "drive0", "persistent": true}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "New", "nod= e": "drive0"}} +{"return": {}} +--- Truncating image --- + +{"execute": "human-monitor-command", "arguments": {"command-line": "block_= resize drive0 50G"}} +{"return": ""} +--- Adding "NewC" bitmap, removing "NewTwo" bitmap --- +{"execute": "block-dirty-bitmap-add", "arguments": {"name": "NewC", "node"= : "drive0", "persistent": true}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Newtwo", "= node": "drive0"}} +{"return": {}} +--- Forcing flush of bitmaps to disk --- + +--- 4th Boot (Verification and Cleanup) --- + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "NewB", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "NewC", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 32768, + "name": "Small", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "Medium", + "persistent": true, + "recording": true, + "status": "active" + }, + { + "busy": false, + "count": 0, + "granularity": 131072, + "name": "Large", + "persistent": true, + "recording": true, + "status": "active" + } + ] + } +} +--- Removing all Bitmaps --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Small", "n= ode": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Medium", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "Large", "n= ode": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "NewB", "no= de": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "NewC", "no= de": "drive0"}} +{"return": {}} +{ + "bitmaps": { + "drive0": [] + } +} + +--- Done --- diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index b5ca63cf72..0683f6e10d 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -241,3 +241,4 @@ 239 rw auto quick 240 auto quick 242 rw auto quick +246 rw auto quick --=20 2.18.0