From patchwork Mon Jan 28 20:01:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Shinkevich X-Patchwork-Id: 10784691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B37D4922 for ; Mon, 28 Jan 2019 20:09:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FFD52BFEB for ; Mon, 28 Jan 2019 20:09:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92CFC2BFF6; Mon, 28 Jan 2019 20:09:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9C8AD2BFEB for ; Mon, 28 Jan 2019 20:09:24 +0000 (UTC) Received: from localhost ([127.0.0.1]:38053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goDDf-00066X-VS for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Jan 2019 15:09:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goD6K-0000xV-89 for qemu-devel@nongnu.org; Mon, 28 Jan 2019 15:01:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goD6I-0003Gy-DO for qemu-devel@nongnu.org; Mon, 28 Jan 2019 15:01:48 -0500 Received: from relay.sw.ru ([185.231.240.75]:38188) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goD6F-0003BC-JF; Mon, 28 Jan 2019 15:01:46 -0500 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1goD62-0005cN-2T; Mon, 28 Jan 2019 23:01:30 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 28 Jan 2019 23:01:27 +0300 Message-Id: <1548705688-1027522-2-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548705688-1027522-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1548705688-1027522-1-git-send-email-andrey.shinkevich@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 v9 1/2] qemu-img info lists bitmap directory entries 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, armbru@redhat.com, mreitz@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In the 'Format specific information' section of the 'qemu-img info' command output, the supplemental information about existing QCOW2 bitmaps will be shown, such as a bitmap name, flags and granularity: image: /vz/vmprivate/VM1/harddisk.hdd file format: qcow2 virtual size: 64G (68719476736 bytes) disk size: 3.0M cluster_size: 1048576 Format specific information: compat: 1.1 lazy refcounts: true bitmaps: [0]: flags: [0]: in-use [1]: auto name: back-up1 unknown flags: 4 granularity: 65536 [1]: flags: [0]: in-use [1]: auto name: back-up2 unknown flags: 8 granularity: 65536 refcount bits: 16 corrupt: false As the print of the qcow2 specific information expanded by adding the bitmap parameters to the 'qemu-img info' command output, it requires amendment of the output benchmark in the following tests: 060, 065, 082, 198, and 206. Signed-off-by: Andrey Shinkevich Reviewed-by: Eric Blake --- block/qapi.c | 6 +++++ block/qcow2-bitmap.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++ block/qcow2.c | 13 ++++++++++ block/qcow2.h | 2 ++ qapi/block-core.json | 42 +++++++++++++++++++++++++++++- tests/qemu-iotests/060.out | 1 + tests/qemu-iotests/065 | 16 ++++++------ tests/qemu-iotests/082.out | 7 +++++ tests/qemu-iotests/198.out | 2 ++ tests/qemu-iotests/206.out | 5 ++++ 10 files changed, 149 insertions(+), 9 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index c66f949..0fde98c 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -38,6 +38,7 @@ #include "qapi/qmp/qstring.h" #include "sysemu/block-backend.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, BlockDriverState *bs, Error **errp) @@ -868,6 +869,11 @@ void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, if (info->has_format_specific) { func_fprintf(f, "Format specific information:\n"); + if (info->format_specific && + info->format_specific->type == IMAGE_INFO_SPECIFIC_KIND_QCOW2 && + info->format_specific->u.qcow2.data->has_bitmaps == false) { + warn_report("Failed to load bitmap list"); + } bdrv_image_info_specific_dump(func_fprintf, f, info->format_specific); } } diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c index b946301..ae842eb 100644 --- a/block/qcow2-bitmap.c +++ b/block/qcow2-bitmap.c @@ -1006,6 +1006,70 @@ fail: return false; } +static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags) +{ + Qcow2BitmapInfoFlagsList *list = NULL; + Qcow2BitmapInfoFlagsList **plist = &list; + + if (flags & BME_FLAG_IN_USE) { + Qcow2BitmapInfoFlagsList *entry = g_new0(Qcow2BitmapInfoFlagsList, 1); + entry->value = QCOW2_BITMAP_INFO_FLAGS_IN_USE; + *plist = entry; + plist = &entry->next; + } + if (flags & BME_FLAG_AUTO) { + Qcow2BitmapInfoFlagsList *entry = g_new0(Qcow2BitmapInfoFlagsList, 1); + entry->value = QCOW2_BITMAP_INFO_FLAGS_AUTO; + *plist = entry; + } + return list; +} + +/* + * qcow2_get_bitmap_info_list() + * Returns a list of QCOW2 bitmap details. + * In case of no bitmaps, the function returns NULL and + * the @errp parameter is not set (for a 0-length list in the QMP). + * When bitmap information can not be obtained, the function returns + * NULL and the @errp parameter is set (for omitting the list in QMP). + */ +Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, + Error **errp) +{ + BDRVQcow2State *s = bs->opaque; + Qcow2BitmapList *bm_list; + Qcow2Bitmap *bm; + Qcow2BitmapInfoList *list = NULL; + Qcow2BitmapInfoList **plist = &list; + + if (s->nb_bitmaps == 0) { + return NULL; + } + + bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, + s->bitmap_directory_size, errp); + if (bm_list == NULL) { + return NULL; + } + + QSIMPLEQ_FOREACH(bm, bm_list, entry) { + Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1); + Qcow2BitmapInfoList *obj = g_new0(Qcow2BitmapInfoList, 1); + info->granularity = 1U << bm->granularity_bits; + info->name = g_strdup(bm->name); + info->flags = get_bitmap_info_flags(bm->flags); + info->unknown_flags = bm->flags & BME_RESERVED_FLAGS; + info->has_unknown_flags = !!info->unknown_flags; + obj->value = info; + *plist = obj; + plist = &obj->next; + } + + bitmap_list_free(bm_list); + + return list; +} + int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, bool *header_updated, Error **errp) { diff --git a/block/qcow2.c b/block/qcow2.c index 4897aba..07b99ee 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4386,8 +4386,14 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){ .compat = g_strdup("0.10"), .refcount_bits = s->refcount_bits, + .has_bitmaps = true, /* To handle error check properly */ + .bitmaps = NULL, /* Unsupported for version 2 */ }; } else if (s->qcow_version == 3) { + Qcow2BitmapInfoList *bitmaps; + Error *local_err = NULL; + + bitmaps = qcow2_get_bitmap_info_list(bs, &local_err); *spec_info->u.qcow2.data = (ImageInfoSpecificQCow2){ .compat = g_strdup("1.1"), .lazy_refcounts = s->compatible_features & @@ -4397,7 +4403,14 @@ static ImageInfoSpecific *qcow2_get_specific_info(BlockDriverState *bs) QCOW2_INCOMPAT_CORRUPT, .has_corrupt = true, .refcount_bits = s->refcount_bits, + .has_bitmaps = !local_err, + .bitmaps = bitmaps, }; + /* + * If an error occurs in obtaining bitmaps, ignore + * it to show other QCOW2 specific information. + */ + error_free(local_err); } else { /* if this assertion fails, this probably means a new version was * added without having it covered here */ diff --git a/block/qcow2.h b/block/qcow2.h index 438a1de..13e8964 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -684,6 +684,8 @@ int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res, void **refcount_table, int64_t *refcount_table_size); bool qcow2_load_dirty_bitmaps(BlockDriverState *bs, Error **errp); +Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs, + Error **errp); int qcow2_reopen_bitmaps_rw_hint(BlockDriverState *bs, bool *header_updated, Error **errp); int qcow2_reopen_bitmaps_rw(BlockDriverState *bs, Error **errp); diff --git a/qapi/block-core.json b/qapi/block-core.json index 91685be..3352562 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -69,6 +69,10 @@ # @encrypt: details about encryption parameters; only set if image # is encrypted (since 2.10) # +# @bitmaps: A list of qcow2 bitmap details (possibly empty, such as for +# v2 images which do not support bitmaps); absent if bitmap +# information could not be obtained (since 4.0) +# # Since: 1.7 ## { 'struct': 'ImageInfoSpecificQCow2', @@ -77,7 +81,8 @@ '*lazy-refcounts': 'bool', '*corrupt': 'bool', 'refcount-bits': 'int', - '*encrypt': 'ImageInfoSpecificQCow2Encryption' + '*encrypt': 'ImageInfoSpecificQCow2Encryption', + '*bitmaps': ['Qcow2BitmapInfo'] } } ## @@ -454,6 +459,41 @@ 'status': 'DirtyBitmapStatus'} } ## +# @Qcow2BitmapInfoFlags: +# +# An enumeration of flags that a bitmap can report to the user. +# +# @in-use: The bitmap was not saved correctly and may be inconsistent. +# +# @auto: The bitmap must reflect all changes of the virtual disk by any +# application that would write to this qcow2 file. +# +# Since: 4.0 +## +{ 'enum': 'Qcow2BitmapInfoFlags', + 'data': ['in-use', 'auto'] } + +## +# @Qcow2BitmapInfo: +# +# Qcow2 bitmap information. +# +# @name: the name of the bitmap +# +# @granularity: granularity of the bitmap in bytes +# +# @flags: flags of the bitmap +# +# @unknown-flags: unspecified flags if detected +# +# Since: 4.0 +## +{ 'struct': 'Qcow2BitmapInfo', + 'data': {'name': 'str', 'granularity': 'uint32', + 'flags': ['Qcow2BitmapInfoFlags'], + '*unknown-flags': 'uint32' } } + +## # @BlockLatencyHistogramInfo: # # Block latency histogram. diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out index af623cf..d0438b2 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -18,6 +18,7 @@ cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false + bitmaps: refcount bits: 16 corrupt: true can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065 index 8bac383..86406cb 100755 --- a/tests/qemu-iotests/065 +++ b/tests/qemu-iotests/065 @@ -88,23 +88,23 @@ class TestQMP(TestImageInfoSpecific): class TestQCow2(TestQemuImgInfo): '''Testing a qcow2 version 2 image''' img_options = 'compat=0.10' - json_compare = { 'compat': '0.10', 'refcount-bits': 16 } - human_compare = [ 'compat: 0.10', 'refcount bits: 16' ] + json_compare = { 'compat': '0.10', 'bitmaps': [], 'refcount-bits': 16 } + human_compare = [ 'compat: 0.10', 'bitmaps:', 'refcount bits: 16' ] class TestQCow3NotLazy(TestQemuImgInfo): '''Testing a qcow2 version 3 image with lazy refcounts disabled''' img_options = 'compat=1.1,lazy_refcounts=off' - json_compare = { 'compat': '1.1', 'lazy-refcounts': False, + json_compare = { 'compat': '1.1', 'lazy-refcounts': False, 'bitmaps': [], 'refcount-bits': 16, 'corrupt': False } - human_compare = [ 'compat: 1.1', 'lazy refcounts: false', + human_compare = [ 'compat: 1.1', 'lazy refcounts: false', 'bitmaps:', 'refcount bits: 16', 'corrupt: false' ] class TestQCow3Lazy(TestQemuImgInfo): '''Testing a qcow2 version 3 image with lazy refcounts enabled''' img_options = 'compat=1.1,lazy_refcounts=on' - json_compare = { 'compat': '1.1', 'lazy-refcounts': True, + json_compare = { 'compat': '1.1', 'lazy-refcounts': True, 'bitmaps': [], 'refcount-bits': 16, 'corrupt': False } - human_compare = [ 'compat: 1.1', 'lazy refcounts: true', + human_compare = [ 'compat: 1.1', 'lazy refcounts: true', 'bitmaps:', 'refcount bits: 16', 'corrupt: false' ] class TestQCow3NotLazyQMP(TestQMP): @@ -112,7 +112,7 @@ class TestQCow3NotLazyQMP(TestQMP): with lazy refcounts enabled''' img_options = 'compat=1.1,lazy_refcounts=off' qemu_options = 'lazy-refcounts=on' - compare = { 'compat': '1.1', 'lazy-refcounts': False, + compare = { 'compat': '1.1', 'lazy-refcounts': False, 'bitmaps': [], 'refcount-bits': 16, 'corrupt': False } @@ -121,7 +121,7 @@ class TestQCow3LazyQMP(TestQMP): with lazy refcounts disabled''' img_options = 'compat=1.1,lazy_refcounts=on' qemu_options = 'lazy-refcounts=off' - compare = { 'compat': '1.1', 'lazy-refcounts': True, + compare = { 'compat': '1.1', 'lazy-refcounts': True, 'bitmaps': [], 'refcount-bits': 16, 'corrupt': False } TestImageInfoSpecific = None diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index 0ce18c0..cfae9c4 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -18,6 +18,7 @@ cluster_size: 4096 Format specific information: compat: 1.1 lazy refcounts: true + bitmaps: refcount bits: 16 corrupt: false @@ -30,6 +31,7 @@ cluster_size: 8192 Format specific information: compat: 1.1 lazy refcounts: true + bitmaps: refcount bits: 16 corrupt: false @@ -276,6 +278,7 @@ cluster_size: 4096 Format specific information: compat: 1.1 lazy refcounts: true + bitmaps: refcount bits: 16 corrupt: false @@ -287,6 +290,7 @@ cluster_size: 8192 Format specific information: compat: 1.1 lazy refcounts: true + bitmaps: refcount bits: 16 corrupt: false @@ -529,6 +533,7 @@ cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: true + bitmaps: refcount bits: 16 corrupt: false @@ -540,6 +545,7 @@ cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false + bitmaps: refcount bits: 16 corrupt: false @@ -551,6 +557,7 @@ cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: true + bitmaps: refcount bits: 16 corrupt: false diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out index adb805c..aeee3c6 100644 --- a/tests/qemu-iotests/198.out +++ b/tests/qemu-iotests/198.out @@ -36,6 +36,7 @@ image: json:{"encrypt.key-secret": "sec0", "driver": "IMGFMT", "file": {"driver" file format: IMGFMT virtual size: 16M (16777216 bytes) Format specific information: + bitmaps: encrypt: ivgen alg: plain64 hash alg: sha256 @@ -79,6 +80,7 @@ file format: IMGFMT virtual size: 16M (16777216 bytes) backing file: TEST_DIR/t.IMGFMT.base Format specific information: + bitmaps: encrypt: ivgen alg: plain64 hash alg: sha256 diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out index 91f4db5..9758569 100644 --- a/tests/qemu-iotests/206.out +++ b/tests/qemu-iotests/206.out @@ -19,6 +19,7 @@ cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false + bitmaps: refcount bits: 16 corrupt: false @@ -41,6 +42,7 @@ cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false + bitmaps: refcount bits: 16 corrupt: false @@ -63,6 +65,7 @@ cluster_size: 2097152 Format specific information: compat: 1.1 lazy refcounts: true + bitmaps: refcount bits: 1 corrupt: false @@ -86,6 +89,7 @@ backing file: TEST_IMG.base backing file format: IMGFMT Format specific information: compat: 0.10 + bitmaps: refcount bits: 16 === Successful image creation (encrypted) === @@ -103,6 +107,7 @@ cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: false + bitmaps: refcount bits: 16 encrypt: ivgen alg: plain64 From patchwork Mon Jan 28 20:01:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Shinkevich X-Patchwork-Id: 10784687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFE21922 for ; Mon, 28 Jan 2019 20:06:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D9E02B832 for ; Mon, 28 Jan 2019 20:06:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E4D12BB27; Mon, 28 Jan 2019 20:06:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B6AFA2B832 for ; Mon, 28 Jan 2019 20:06:45 +0000 (UTC) Received: from localhost ([127.0.0.1]:38023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goDB5-0004UC-Uv for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Jan 2019 15:06:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goD6K-0000xf-EK for qemu-devel@nongnu.org; Mon, 28 Jan 2019 15:01:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goD6J-0003Hc-1o for qemu-devel@nongnu.org; Mon, 28 Jan 2019 15:01:48 -0500 Received: from relay.sw.ru ([185.231.240.75]:38194) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goD6I-0003BE-Qm; Mon, 28 Jan 2019 15:01:46 -0500 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1goD62-0005cN-BW; Mon, 28 Jan 2019 23:01:30 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Mon, 28 Jan 2019 23:01:28 +0300 Message-Id: <1548705688-1027522-3-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548705688-1027522-1-git-send-email-andrey.shinkevich@virtuozzo.com> References: <1548705688-1027522-1-git-send-email-andrey.shinkevich@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 v9 2/2] qemu-img info: bitmaps extension new test 239 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, armbru@redhat.com, mreitz@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A new test file 239 added to the qemu-iotests set. It checks the output format of 'qemu-img info' for bitmaps extension of qcow2 specific information. Signed-off-by: Andrey Shinkevich --- tests/qemu-iotests/239 | 60 +++++++++++++++++++++++++++++++ tests/qemu-iotests/239.out | 88 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 149 insertions(+) create mode 100755 tests/qemu-iotests/239 create mode 100644 tests/qemu-iotests/239.out diff --git a/tests/qemu-iotests/239 b/tests/qemu-iotests/239 new file mode 100755 index 0000000..233b58b --- /dev/null +++ b/tests/qemu-iotests/239 @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# +# Test for qcow2 bitmap printed information +# +# Copyright (c) 2018 Virtuozzo International GmbH +# +# 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 . +# + +import iotests +import json +from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \ + file_path, log + +disk = file_path('disk') +chunk = 256 + +def print_bitmap(): + log('bitmap info dump:') + result = json.loads(qemu_img_pipe('info', '--force-share', + '--output=json', disk)) + bitmaps = result['format-specific']['data']['bitmaps'] + log(bitmaps, indent=2) + +def add_bitmap(bitmap_number): + num = bitmap_number + granularity = 2**(13 + num) + bitmap_name = 'bitmap-' + str(num) + vm = iotests.VM().add_drive(disk) + vm.launch() + vm.qmp_log('block-dirty-bitmap-add', node='drive0', name=bitmap_name, + granularity=granularity, persistent=True) + vm.shutdown() + write = 'write {} {}K'.format((num-1)*chunk, chunk) + qemu_io('-f', iotests.imgfmt, '-c', write, disk) + +iotests.verify_image_format(supported_fmts=['qcow2']) +qemu_img_create('-f', iotests.imgfmt, disk, '1M') + +for num in range(1, 4): + add_bitmap(num) + print_bitmap() + log('') + +vm = iotests.VM().add_drive(disk) +vm.launch() +log('Check \"in-use\" flag') +print_bitmap() +vm.shutdown() diff --git a/tests/qemu-iotests/239.out b/tests/qemu-iotests/239.out new file mode 100644 index 0000000..efeca9f --- /dev/null +++ b/tests/qemu-iotests/239.out @@ -0,0 +1,88 @@ +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 16384, "name": "bitmap-1", "node": "drive0", "persistent": true}} +{"return": {}} +bitmap info dump: +[ + { + "flags": [ + "auto" + ], + "granularity": 16384, + "name": "bitmap-1" + } +] + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 32768, "name": "bitmap-2", "node": "drive0", "persistent": true}} +{"return": {}} +bitmap info dump: +[ + { + "flags": [ + "auto" + ], + "granularity": 16384, + "name": "bitmap-1" + }, + { + "flags": [ + "auto" + ], + "granularity": 32768, + "name": "bitmap-2" + } +] + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, "name": "bitmap-3", "node": "drive0", "persistent": true}} +{"return": {}} +bitmap info dump: +[ + { + "flags": [ + "auto" + ], + "granularity": 16384, + "name": "bitmap-1" + }, + { + "flags": [ + "auto" + ], + "granularity": 32768, + "name": "bitmap-2" + }, + { + "flags": [ + "auto" + ], + "granularity": 65536, + "name": "bitmap-3" + } +] + +Check "in-use" flag +bitmap info dump: +[ + { + "flags": [ + "in-use", + "auto" + ], + "granularity": 16384, + "name": "bitmap-1" + }, + { + "flags": [ + "in-use", + "auto" + ], + "granularity": 32768, + "name": "bitmap-2" + }, + { + "flags": [ + "in-use", + "auto" + ], + "granularity": 65536, + "name": "bitmap-3" + } +] diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 0f1c3f9..3e310c7 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -235,3 +235,4 @@ 235 auto quick 236 auto quick 238 auto quick +239 rw auto quick