From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570244139419.35811427243266; Wed, 15 Mar 2017 02:30:44 -0700 (PDT) Received: from localhost ([::1]:35362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5GU-0000dG-R3 for importer@patchew.org; Wed, 15 Mar 2017 05:30:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Fg-0000bL-Mq for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:29:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5Ff-0000L4-I2 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:29:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5Ff-0000KA-99 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:29:51 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42EB180462; Wed, 15 Mar 2017 09:29:51 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2F9TlGs023282; Wed, 15 Mar 2017 05:29:49 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 42EB180462 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 42EB180462 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:33 +0800 Message-Id: <20170315092940.1367-2-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 15 Mar 2017 09:29:51 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 1/8] block: add bdrv_measure() API 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_measure() provides a conservative maximum for the size of a new image. This information is handy if storage needs to be allocated (e.g. a SAN or an LVM volume) ahead of time. Signed-off-by: Stefan Hajnoczi --- qapi/block-core.json | 19 +++++++++++++++++++ include/block/block.h | 4 ++++ include/block/block_int.h | 2 ++ block.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+) diff --git a/qapi/block-core.json b/qapi/block-core.json index 786b39e..673569d 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -463,6 +463,25 @@ '*dirty-bitmaps': ['BlockDirtyInfo'] } } =20 ## +# @BlockMeasureInfo: +# +# Image size calculation information. This structure describes the size +# requirements for creating a new image. +# +# @required-bytes: Amount of space required for image creation. This valu= e is +# the host file size including sparse file regions. A ne= w 5 +# GB raw file therefore has a required size of 5 GB, not 0 +# bytes. +# +# @fully-allocated-bytes: Space required once data has been written to all +# sectors +# +# Since: 2.10 +## +{ 'struct': 'BlockMeasureInfo', + 'data': {'required-bytes': 'int', 'fully-allocated-bytes': 'int'} } + +## # @query-block: # # Get a list of BlockInfo for all virtual block devices. diff --git a/include/block/block.h b/include/block/block.h index 5149260..43c789f 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -298,6 +298,10 @@ int bdrv_truncate(BdrvChild *child, int64_t offset); int64_t bdrv_nb_sectors(BlockDriverState *bs); int64_t bdrv_getlength(BlockDriverState *bs); int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); +void bdrv_measure(BlockDriver *drv, QemuOpts *opts, + BlockDriverState *in_bs, + BlockMeasureInfo *info, + Error **errp); void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr); void bdrv_refresh_limits(BlockDriverState *bs, Error **errp); int bdrv_commit(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 6c699ac..45a7fbe 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -201,6 +201,8 @@ struct BlockDriver { int64_t (*bdrv_getlength)(BlockDriverState *bs); bool has_variable_length; int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs); + void (*bdrv_measure)(QemuOpts *opts, BlockDriverState *in_bs, + BlockMeasureInfo *info, Error **errp); =20 int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov); diff --git a/block.c b/block.c index cb57370..532a4d1 100644 --- a/block.c +++ b/block.c @@ -3260,6 +3260,39 @@ int64_t bdrv_get_allocated_file_size(BlockDriverStat= e *bs) return -ENOTSUP; } =20 +/* + * bdrv_measure: + * @drv: Format driver + * @opts: Creation options + * @in_bs: Existing image containing data for new image (may be NULL) + * @info: Result object + * @errp: Error object + * + * Calculate file size required to create a new image. + * + * If @in_bs is given then space for allocated clusters and zero clusters + * from that image are included in the calculation. If @opts contains a + * backing file that is shared by @in_bs then backing clusters are omitted + * from the calculation. + * + * If @in_bs is NULL then the calculation includes no allocated clusters + * unless a preallocation option is given in @opts. + * + * Note that @in_bs may use a different BlockDriver from @drv. + */ +void bdrv_measure(BlockDriver *drv, QemuOpts *opts, + BlockDriverState *in_bs, BlockMeasureInfo *info, + Error **errp) +{ + if (!drv->bdrv_measure) { + error_setg(errp, "Block driver '%s' does not support size measurem= ent", + drv->format_name); + return; + } + + drv->bdrv_measure(opts, in_bs, info, errp); +} + /** * Return number of sectors on success, -errno on error. */ --=20 2.9.3 From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570360350603.9371403953738; Wed, 15 Mar 2017 02:32:40 -0700 (PDT) Received: from localhost ([::1]:35373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5IL-00021f-2P for importer@patchew.org; Wed, 15 Mar 2017 05:32:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Fk-0000dH-Db for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:29:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5Fj-0000MD-Jy for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:29:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47146) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5Fj-0000Lh-De for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:29:55 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D4ED811A7; Wed, 15 Mar 2017 09:29:55 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2F9TqLo007809; Wed, 15 Mar 2017 05:29:54 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7D4ED811A7 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7D4ED811A7 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:34 +0800 Message-Id: <20170315092940.1367-3-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 15 Mar 2017 09:29:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 2/8] raw-format: add bdrv_measure() support 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Maximum size calculation is trivial for the raw format: it's just the requested image size (because there is no metadata). Signed-off-by: Stefan Hajnoczi --- block/raw-format.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/block/raw-format.c b/block/raw-format.c index 86fbc65..cc88540 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -312,6 +312,27 @@ static int64_t raw_getlength(BlockDriverState *bs) return s->size; } =20 +static void raw_measure(QemuOpts *opts, BlockDriverState *in_bs, + BlockMeasureInfo *info, + Error **errp) +{ + if (in_bs) { + int64_t ssize =3D bdrv_getlength(in_bs); + if (ssize < 0) { + error_setg_errno(errp, -ssize, "Unable to get image size"); + return; + } + info->required_bytes =3D ssize; + } else { + info->required_bytes =3D + ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), + BDRV_SECTOR_SIZE); + } + + /* Unallocated sectors count towards the file size in raw images */ + info->fully_allocated_bytes =3D info->required_bytes; +} + static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { return bdrv_get_info(bs->file->bs, bdi); @@ -477,6 +498,7 @@ BlockDriver bdrv_raw =3D { .bdrv_truncate =3D &raw_truncate, .bdrv_getlength =3D &raw_getlength, .has_variable_length =3D true, + .bdrv_measure =3D &raw_measure, .bdrv_get_info =3D &raw_get_info, .bdrv_refresh_limits =3D &raw_refresh_limits, .bdrv_probe_blocksizes =3D &raw_probe_blocksizes, --=20 2.9.3 From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570456889691.1776421700271; Wed, 15 Mar 2017 02:34:16 -0700 (PDT) Received: from localhost ([::1]:35377 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Jt-0003LI-Gy for importer@patchew.org; Wed, 15 Mar 2017 05:34:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Fp-0000gu-6I for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5Fo-0000Q7-0U for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52504) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5Fn-0000Pu-Np for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:29:59 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5B0D369C4; Wed, 15 Mar 2017 09:29:59 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2F9TvNd030399; Wed, 15 Mar 2017 05:29:58 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B5B0D369C4 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B5B0D369C4 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:35 +0800 Message-Id: <20170315092940.1367-4-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 15 Mar 2017 09:29:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 3/8] qcow2: extract preallocation calculation function 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Calculating the preallocated image size will be needed to implement .bdrv_measure(). Extract the code out into a separate function. Signed-off-by: Stefan Hajnoczi --- block/qcow2.c | 134 +++++++++++++++++++++++++++++++++---------------------= ---- 1 file changed, 76 insertions(+), 58 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 6a92d2e..7c702f4 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2095,6 +2095,79 @@ static int preallocate(BlockDriverState *bs) return 0; } =20 +/** + * qcow2_calc_prealloc_size: + * @total_size: virtual disk size in bytes + * @cluster_size: cluster size in bytes + * @refcount_order: refcount bits power-of-2 exponent + * + * Returns: Total number of bytes required for the fully allocated image + * (including metadata). + */ +static int64_t qcow2_calc_prealloc_size(int64_t total_size, + size_t cluster_size, + int refcount_order) +{ + /* Note: The following calculation does not need to be exact; if it is= a + * bit off, either some bytes will be "leaked" (which is fine) or we + * will need to increase the file size by some bytes (which is fine, + * too, as long as the bulk is allocated here). Therefore, using + * floating point arithmetic is fine. */ + int64_t meta_size =3D 0; + uint64_t nreftablee, nrefblocke, nl1e, nl2e; + int64_t aligned_total_size =3D align_offset(total_size, cluster_size); + int cluster_bits =3D ctz32(cluster_size); + int refblock_bits, refblock_size; + /* refcount entry size in bytes */ + double rces =3D (1 << refcount_order) / 8.; + + /* see qcow2_open() */ + refblock_bits =3D cluster_bits - (refcount_order - 3); + refblock_size =3D 1 << refblock_bits; + + /* header: 1 cluster */ + meta_size +=3D cluster_size; + + /* total size of L2 tables */ + nl2e =3D aligned_total_size / cluster_size; + nl2e =3D align_offset(nl2e, cluster_size / sizeof(uint64_t)); + meta_size +=3D nl2e * sizeof(uint64_t); + + /* total size of L1 tables */ + nl1e =3D nl2e * sizeof(uint64_t) / cluster_size; + nl1e =3D align_offset(nl1e, cluster_size / sizeof(uint64_t)); + meta_size +=3D nl1e * sizeof(uint64_t); + + /* total size of refcount blocks + * + * note: every host cluster is reference-counted, including metadata + * (even refcount blocks are recursively included). + * Let: + * a =3D total_size (this is the guest disk size) + * m =3D meta size not including refcount blocks and refcount tables + * c =3D cluster size + * y1 =3D number of refcount blocks entries + * y2 =3D meta size including everything + * rces =3D refcount entry size in bytes + * then, + * y1 =3D (y2 + a)/c + * y2 =3D y1 * rces + y1 * rces * sizeof(u64) / c + m + * we can get y1: + * y1 =3D (a + m) / (c - rces - rces * sizeof(u64) / c) + */ + nrefblocke =3D (aligned_total_size + meta_size + cluster_size) + / (cluster_size - rces - rces * sizeof(uint64_t) + / cluster_size); + meta_size +=3D DIV_ROUND_UP(nrefblocke, refblock_size) * cluster_size; + + /* total size of refcount tables */ + nreftablee =3D nrefblocke / refblock_size; + nreftablee =3D align_offset(nreftablee, cluster_size / sizeof(uint64_t= )); + meta_size +=3D nreftablee * sizeof(uint64_t); + + return meta_size + aligned_total_size; +} + static int qcow2_create2(const char *filename, int64_t total_size, const char *backing_file, const char *backing_for= mat, int flags, size_t cluster_size, PreallocMode prea= lloc, @@ -2133,64 +2206,9 @@ static int qcow2_create2(const char *filename, int64= _t total_size, int ret; =20 if (prealloc =3D=3D PREALLOC_MODE_FULL || prealloc =3D=3D PREALLOC_MOD= E_FALLOC) { - /* Note: The following calculation does not need to be exact; if i= t is a - * bit off, either some bytes will be "leaked" (which is fine) or = we - * will need to increase the file size by some bytes (which is fin= e, - * too, as long as the bulk is allocated here). Therefore, using - * floating point arithmetic is fine. */ - int64_t meta_size =3D 0; - uint64_t nreftablee, nrefblocke, nl1e, nl2e; - int64_t aligned_total_size =3D align_offset(total_size, cluster_si= ze); - int refblock_bits, refblock_size; - /* refcount entry size in bytes */ - double rces =3D (1 << refcount_order) / 8.; - - /* see qcow2_open() */ - refblock_bits =3D cluster_bits - (refcount_order - 3); - refblock_size =3D 1 << refblock_bits; - - /* header: 1 cluster */ - meta_size +=3D cluster_size; - - /* total size of L2 tables */ - nl2e =3D aligned_total_size / cluster_size; - nl2e =3D align_offset(nl2e, cluster_size / sizeof(uint64_t)); - meta_size +=3D nl2e * sizeof(uint64_t); - - /* total size of L1 tables */ - nl1e =3D nl2e * sizeof(uint64_t) / cluster_size; - nl1e =3D align_offset(nl1e, cluster_size / sizeof(uint64_t)); - meta_size +=3D nl1e * sizeof(uint64_t); - - /* total size of refcount blocks - * - * note: every host cluster is reference-counted, including metada= ta - * (even refcount blocks are recursively included). - * Let: - * a =3D total_size (this is the guest disk size) - * m =3D meta size not including refcount blocks and refcount ta= bles - * c =3D cluster size - * y1 =3D number of refcount blocks entries - * y2 =3D meta size including everything - * rces =3D refcount entry size in bytes - * then, - * y1 =3D (y2 + a)/c - * y2 =3D y1 * rces + y1 * rces * sizeof(u64) / c + m - * we can get y1: - * y1 =3D (a + m) / (c - rces - rces * sizeof(u64) / c) - */ - nrefblocke =3D (aligned_total_size + meta_size + cluster_size) - / (cluster_size - rces - rces * sizeof(uint64_t) - / cluster_size); - meta_size +=3D DIV_ROUND_UP(nrefblocke, refblock_size) * cluster_s= ize; - - /* total size of refcount tables */ - nreftablee =3D nrefblocke / refblock_size; - nreftablee =3D align_offset(nreftablee, cluster_size / sizeof(uint= 64_t)); - meta_size +=3D nreftablee * sizeof(uint64_t); - - qemu_opt_set_number(opts, BLOCK_OPT_SIZE, - aligned_total_size + meta_size, &error_abort); + int64_t prealloc_size =3D + qcow2_calc_prealloc_size(total_size, cluster_size, refcount_or= der); + qemu_opt_set_number(opts, BLOCK_OPT_SIZE, prealloc_size, &error_ab= ort); qemu_opt_set(opts, BLOCK_OPT_PREALLOC, PreallocMode_lookup[preallo= c], &error_abort); } --=20 2.9.3 From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570267580451.196972139393; Wed, 15 Mar 2017 02:31:07 -0700 (PDT) Received: from localhost ([::1]:35368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Gr-0000tR-7n for importer@patchew.org; Wed, 15 Mar 2017 05:31:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Ft-0000kq-VI for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5Fs-0000S3-Kp for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5Fs-0000Qp-Br for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:04 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EA6BC05AA54; Wed, 15 Mar 2017 09:30:04 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2F9U1jt023360; Wed, 15 Mar 2017 05:30:02 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5EA6BC05AA54 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5EA6BC05AA54 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:36 +0800 Message-Id: <20170315092940.1367-5-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 15 Mar 2017 09:30:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 4/8] qcow2: extract image creation option parsing 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The image creation options parsed by qcow2_create() are also needed to implement .bdrv_measure(). Extract the parsing code, including input validation. Signed-off-by: Stefan Hajnoczi --- block/qcow2.c | 109 +++++++++++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 7c702f4..19be468 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2168,24 +2168,73 @@ static int64_t qcow2_calc_prealloc_size(int64_t tot= al_size, return meta_size + aligned_total_size; } =20 -static int qcow2_create2(const char *filename, int64_t total_size, - const char *backing_file, const char *backing_for= mat, - int flags, size_t cluster_size, PreallocMode prea= lloc, - QemuOpts *opts, int version, int refcount_order, - Error **errp) +static size_t qcow2_opt_get_cluster_size_del(QemuOpts *opts, Error **errp) { + size_t cluster_size; int cluster_bits; - QDict *options; =20 - /* Calculate cluster_bits */ + cluster_size =3D qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, + DEFAULT_CLUSTER_SIZE); cluster_bits =3D ctz32(cluster_size); if (cluster_bits < MIN_CLUSTER_BITS || cluster_bits > MAX_CLUSTER_BITS= || (1 << cluster_bits) !=3D cluster_size) { error_setg(errp, "Cluster size must be a power of two between %d a= nd " "%dk", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - = 10)); - return -EINVAL; + return 0; } + return cluster_size; +} + +static int qcow2_opt_get_version_del(QemuOpts *opts, Error **errp) +{ + char *buf; + int ret; + + buf =3D qemu_opt_get_del(opts, BLOCK_OPT_COMPAT_LEVEL); + if (!buf) { + ret =3D 3; /* default */ + } else if (!strcmp(buf, "0.10")) { + ret =3D 2; + } else if (!strcmp(buf, "1.1")) { + ret =3D 3; + } else { + error_setg(errp, "Invalid compatibility level: '%s'", buf); + ret =3D -EINVAL; + } + g_free(buf); + return ret; +} + +static uint64_t qcow2_opt_get_refcount_bits_del(QemuOpts *opts, int versio= n, + Error **errp) +{ + uint64_t refcount_bits; + + refcount_bits =3D qemu_opt_get_number_del(opts, BLOCK_OPT_REFCOUNT_BIT= S, 16); + if (refcount_bits > 64 || !is_power_of_2(refcount_bits)) { + error_setg(errp, "Refcount width must be a power of two and may no= t " + "exceed 64 bits"); + return 0; + } + + if (version < 3 && refcount_bits !=3D 16) { + error_setg(errp, "Different refcount widths than 16 bits require " + "compatibility level 1.1 or above (use compat=3D1.1 or " + "greater)"); + return 0; + } + + return refcount_bits; +} + +static int qcow2_create2(const char *filename, int64_t total_size, + const char *backing_file, const char *backing_for= mat, + int flags, size_t cluster_size, PreallocMode prea= lloc, + QemuOpts *opts, int version, int refcount_order, + Error **errp) +{ + QDict *options; =20 /* * Open the image file and write a minimal qcow2 header. @@ -2235,7 +2284,7 @@ static int qcow2_create2(const char *filename, int64_= t total_size, *header =3D (QCowHeader) { .magic =3D cpu_to_be32(QCOW_MAGIC), .version =3D cpu_to_be32(version), - .cluster_bits =3D cpu_to_be32(cluster_bits), + .cluster_bits =3D cpu_to_be32(ctz32(cluster_size)), .size =3D cpu_to_be64(0), .l1_table_offset =3D cpu_to_be64(0), .l1_size =3D cpu_to_be32(0), @@ -2371,8 +2420,8 @@ static int qcow2_create(const char *filename, QemuOpt= s *opts, Error **errp) int flags =3D 0; size_t cluster_size =3D DEFAULT_CLUSTER_SIZE; PreallocMode prealloc; - int version =3D 3; - uint64_t refcount_bits =3D 16; + int version; + uint64_t refcount_bits; int refcount_order; Error *local_err =3D NULL; int ret; @@ -2385,8 +2434,12 @@ static int qcow2_create(const char *filename, QemuOp= ts *opts, Error **errp) if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ENCRYPT, false)) { flags |=3D BLOCK_FLAG_ENCRYPT; } - cluster_size =3D qemu_opt_get_size_del(opts, BLOCK_OPT_CLUSTER_SIZE, - DEFAULT_CLUSTER_SIZE); + cluster_size =3D qcow2_opt_get_cluster_size_del(opts, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret =3D -EINVAL; + goto finish; + } buf =3D qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC); prealloc =3D qapi_enum_parse(PreallocMode_lookup, buf, PREALLOC_MODE__MAX, PREALLOC_MODE_OFF, @@ -2396,16 +2449,10 @@ static int qcow2_create(const char *filename, QemuO= pts *opts, Error **errp) ret =3D -EINVAL; goto finish; } - g_free(buf); - buf =3D qemu_opt_get_del(opts, BLOCK_OPT_COMPAT_LEVEL); - if (!buf) { - /* keep the default */ - } else if (!strcmp(buf, "0.10")) { - version =3D 2; - } else if (!strcmp(buf, "1.1")) { - version =3D 3; - } else { - error_setg(errp, "Invalid compatibility level: '%s'", buf); + + version =3D qcow2_opt_get_version_del(opts, &local_err); + if (local_err) { + error_propagate(errp, local_err); ret =3D -EINVAL; goto finish; } @@ -2428,19 +2475,9 @@ static int qcow2_create(const char *filename, QemuOp= ts *opts, Error **errp) goto finish; } =20 - refcount_bits =3D qemu_opt_get_number_del(opts, BLOCK_OPT_REFCOUNT_BIT= S, - refcount_bits); - if (refcount_bits > 64 || !is_power_of_2(refcount_bits)) { - error_setg(errp, "Refcount width must be a power of two and may no= t " - "exceed 64 bits"); - ret =3D -EINVAL; - goto finish; - } - - if (version < 3 && refcount_bits !=3D 16) { - error_setg(errp, "Different refcount widths than 16 bits require " - "compatibility level 1.1 or above (use compat=3D1.1 or " - "greater)"); + refcount_bits =3D qcow2_opt_get_refcount_bits_del(opts, version, &loca= l_err); + if (local_err) { + error_propagate(errp, local_err); ret =3D -EINVAL; goto finish; } --=20 2.9.3 From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570534972844.6260192112375; Wed, 15 Mar 2017 02:35:34 -0700 (PDT) Received: from localhost ([::1]:35384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5LA-0004Kq-OQ for importer@patchew.org; Wed, 15 Mar 2017 05:35:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Fx-0000oZ-50 for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5Fw-0000Vx-4N for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55190) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5Fv-0000Ub-TL for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:08 -0400 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EFE9E81243; Wed, 15 Mar 2017 09:30:07 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0430F2D582; Wed, 15 Mar 2017 09:30:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EFE9E81243 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EFE9E81243 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:37 +0800 Message-Id: <20170315092940.1367-6-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 15 Mar 2017 09:30:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 5/8] qcow2: add bdrv_measure() support 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use qcow2_calc_prealloc_size() to get the required file size. Signed-off-by: Stefan Hajnoczi --- TODO: * Query block status and only count allocated clusters if in_bs !=3D NULL * Exclude backing file clusters if in_bs !=3D NULL and -o backing_file=3D is given --- block/qcow2.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 19be468..a4caf97 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2940,6 +2940,58 @@ static coroutine_fn int qcow2_co_flush_to_os(BlockDr= iverState *bs) return 0; } =20 +static void qcow2_measure(QemuOpts *opts, BlockDriverState *in_bs, + BlockMeasureInfo *info, Error **errp) +{ + Error *local_err =3D NULL; + uint64_t allocated_bytes =3D 0; + uint64_t prealloc_size; + uint64_t size; + uint64_t refcount_bits; + size_t cluster_size; + int version; + + size =3D ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), + BDRV_SECTOR_SIZE); + + cluster_size =3D qcow2_opt_get_cluster_size_del(opts, &local_err); + if (local_err) { + goto err; + } + + version =3D qcow2_opt_get_version_del(opts, &local_err); + if (local_err) { + goto err; + } + + refcount_bits =3D qcow2_opt_get_refcount_bits_del(opts, version, &loca= l_err); + if (local_err) { + goto err; + } + + if (in_bs) { + int64_t ssize =3D bdrv_getlength(in_bs); + if (ssize < 0) { + error_setg_errno(errp, -ssize, "Unable to get image size"); + return; + } + + size =3D ssize; + + /* TODO How many clusters are allocated modulo backing file in opt= s? */ + } + + prealloc_size =3D qcow2_calc_prealloc_size(size, cluster_size, + ctz32(refcount_bits)); + info->required_bytes =3D prealloc_size - (align_offset(size, cluster_s= ize) - + allocated_bytes); + info->fully_allocated_bytes =3D prealloc_size; + return; + +err: + error_propagate(errp, local_err); +} + static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { BDRVQcow2State *s =3D bs->opaque; @@ -3487,6 +3539,7 @@ BlockDriver bdrv_qcow2 =3D { .bdrv_snapshot_delete =3D qcow2_snapshot_delete, .bdrv_snapshot_list =3D qcow2_snapshot_list, .bdrv_snapshot_load_tmp =3D qcow2_snapshot_load_tmp, + .bdrv_measure =3D qcow2_measure, .bdrv_get_info =3D qcow2_get_info, .bdrv_get_specific_info =3D qcow2_get_specific_info, =20 --=20 2.9.3 From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570366200366.14560736412545; Wed, 15 Mar 2017 02:32:46 -0700 (PDT) Received: from localhost ([::1]:35374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5IR-00029t-UK for importer@patchew.org; Wed, 15 Mar 2017 05:32:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5G5-0000y1-UL for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5G0-0000ZA-LH for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47334) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5G0-0000Yl-DR for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:12 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 790E880F6D; Wed, 15 Mar 2017 09:30:12 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2F9U9tx014255; Wed, 15 Mar 2017 05:30:11 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 790E880F6D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 790E880F6D From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:38 +0800 Message-Id: <20170315092940.1367-7-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 15 Mar 2017 09:30:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 6/8] qemu-img: add measure subcommand 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The measure subcommand calculates the size required by a new image file. This can be used by users or management tools that need to allocate space on an LVM volume, SAN LUN, etc before creating or converting an image file. Suggested-by: Maor Lipchuk Signed-off-by: Stefan Hajnoczi --- qemu-img.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ qemu-img-cmds.hx | 9 +++ 2 files changed, 222 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index 98b836b..e8c6dcc 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -59,6 +59,7 @@ enum { OPTION_PATTERN =3D 260, OPTION_FLUSH_INTERVAL =3D 261, OPTION_NO_DRAIN =3D 262, + OPTION_SIZE =3D 263, }; =20 typedef enum OutputFormat { @@ -4287,6 +4288,218 @@ out: return 0; } =20 +static void dump_json_block_measure_info(BlockMeasureInfo *info) +{ + QString *str; + QObject *obj; + Visitor *v =3D qobject_output_visitor_new(&obj); + + visit_type_BlockMeasureInfo(v, NULL, &info, &error_abort); + visit_complete(v, &obj); + str =3D qobject_to_json_pretty(obj); + assert(str !=3D NULL); + printf("%s\n", qstring_get_str(str)); + qobject_decref(obj); + visit_free(v); + QDECREF(str); +} + +static int img_measure(int argc, char **argv) +{ + static const struct option long_options[] =3D { + {"help", no_argument, 0, 'h'}, + {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, + {"object", required_argument, 0, OPTION_OBJECT}, + {"output", required_argument, 0, OPTION_OUTPUT}, + {"size", required_argument, 0, OPTION_SIZE}, + {0, 0, 0, 0} + }; + OutputFormat output_format =3D OFORMAT_HUMAN; + BlockBackend *in_blk =3D NULL; + BlockDriver *drv; + const char *filename =3D NULL; + const char *fmt =3D NULL; + const char *out_fmt =3D "raw"; + char *options =3D NULL; + char *snapshot_name =3D NULL; + QemuOpts *opts =3D NULL; + QemuOpts *object_opts =3D NULL; + QemuOpts *sn_opts =3D NULL; + QemuOptsList *create_opts =3D NULL; + bool image_opts =3D false; + uint64_t img_size =3D ~0ULL; + BlockMeasureInfo info; + Error *local_err =3D NULL; + int ret =3D 1; + int c; + + while ((c =3D getopt_long(argc, argv, "hf:O:o:l:", + long_options, NULL)) !=3D -1) { + switch (c) { + case '?': + case 'h': + help(); + break; + case 'f': + fmt =3D optarg; + break; + case 'O': + out_fmt =3D optarg; + break; + case 'o': + if (!is_valid_option_list(optarg)) { + error_report("Invalid option list: %s", optarg); + goto out; + } + if (!options) { + options =3D g_strdup(optarg); + } else { + char *old_options =3D options; + options =3D g_strdup_printf("%s,%s", options, optarg); + g_free(old_options); + } + break; + case 'l': + if (strstart(optarg, SNAPSHOT_OPT_BASE, NULL)) { + sn_opts =3D qemu_opts_parse_noisily(&internal_snapshot_opt= s, + optarg, false); + if (!sn_opts) { + error_report("Failed in parsing snapshot param '%s'", + optarg); + goto out; + } + } else { + snapshot_name =3D optarg; + } + break; + case OPTION_OBJECT: + object_opts =3D qemu_opts_parse_noisily(&qemu_object_opts, + optarg, true); + if (!object_opts) { + goto out; + } + break; + case OPTION_IMAGE_OPTS: + image_opts =3D true; + break; + case OPTION_OUTPUT: + if (!strcmp(optarg, "json")) { + output_format =3D OFORMAT_JSON; + } else if (!strcmp(optarg, "human")) { + output_format =3D OFORMAT_HUMAN; + } else { + error_report("--output must be used with human or json " + "as argument."); + goto out; + } + break; + case OPTION_SIZE: + { + int64_t sval; + + sval =3D cvtnum(optarg); + if (sval < 0) { + if (sval =3D=3D -ERANGE) { + error_report("Image size must be less than 8 EiB!"); + } else { + error_report("Invalid image size specified! You may us= e " + "k, M, G, T, P or E suffixes for "); + error_report("kilobytes, megabytes, gigabytes, terabyt= es, " + "petabytes and exabytes."); + } + goto out; + } + img_size =3D (uint64_t)sval; + } + break; + } + } + + if (qemu_opts_foreach(&qemu_object_opts, + user_creatable_add_opts_foreach, + NULL, NULL)) { + goto out; + } + + if (argc - optind > 1) { + error_report("At most one filename argument is allowed."); + goto out; + } else if (argc - optind =3D=3D 1) { + filename =3D argv[optind]; + } + + if (!filename && + (object_opts || image_opts || fmt || snapshot_name || sn_opts)) { + error_report("--object, --image-opts, -f, and -l " + "require a filename argument."); + goto out; + } + if (filename && img_size !=3D ~0ULL) { + error_report("--size N cannot be used together with a filename."); + goto out; + } + if (!filename && img_size =3D=3D ~0ULL) { + error_report("Either --size N or one filename must be specified."); + goto out; + } + + if (filename) { + in_blk =3D img_open(image_opts, filename, fmt, 0, false, false); + if (!in_blk) { + goto out; + } + } + + drv =3D bdrv_find_format(out_fmt); + if (!drv) { + error_report("Unknown file format '%s'", out_fmt); + goto out; + } + if (!drv->create_opts) { + error_report("Format driver '%s' does not support image creation", + drv->format_name); + goto out; + } + + create_opts =3D qemu_opts_append(create_opts, drv->create_opts); + opts =3D qemu_opts_create(create_opts, NULL, 0, &error_abort); + if (options) { + qemu_opts_do_parse(opts, options, NULL, &local_err); + if (local_err) { + error_report_err(local_err); + error_report("Invalid options for file format '%s'", out_fmt); + goto out; + } + } + if (img_size !=3D ~0ULL) { + qemu_opt_set_number(opts, BLOCK_OPT_SIZE, img_size, &error_abort); + } + + bdrv_measure(drv, opts, in_blk ? blk_bs(in_blk) : NULL, &info, &local_= err); + if (local_err) { + error_report_err(local_err); + goto out; + } + + if (output_format =3D=3D OFORMAT_HUMAN) { + printf("required bytes: %" PRIu64 "\n", info.required_bytes); + printf("fully allocated bytes: %" PRIu64 "\n", + info.fully_allocated_bytes); + } else { + dump_json_block_measure_info(&info); + } + + ret =3D 0; + +out: + qemu_opts_del(object_opts); + qemu_opts_del(opts); + qemu_opts_del(sn_opts); + qemu_opts_free(create_opts); + g_free(options); + blk_unref(in_blk); + return ret; +} =20 static const img_cmd_t img_cmds[] =3D { #define DEF(option, callback, arg_string) \ diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index 9c9702c..57ef70f 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -85,5 +85,14 @@ DEF("amend", img_amend, "amend [--object objectdef] [--image-opts] [-p] [-q] [-f fmt] [-t cach= e] -o options filename") STEXI @item amend [--object @var{objectdef}] [--image-opts] [-p] [-q] [-f @var{f= mt}] [-t @var{cache}] -o @var{options} @var{filename} +ETEXI + +DEF("measure", img_measure, +"measure [--output=3Dofmt] [-O output_fmt] [-o options] [--size N | [--obj= ect objectdef] [--image-opts] [-f fmt] [-l snapshot_param] filename]") +STEXI +@item measure [--output=3D@var{ofmt}] [-O @var{output_fmt}] [-o @var{optio= ns}] [--size @var{N} | [--object @var{objectdef}] [--image-opts] [-f @var{f= mt}] [-l @var{snapshot_param}] @var{filename}] +ETEXI + +STEXI @end table ETEXI --=20 2.9.3 From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570593674369.7238947191506; Wed, 15 Mar 2017 02:36:33 -0700 (PDT) Received: from localhost ([::1]:35391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5M7-0004wL-7r for importer@patchew.org; Wed, 15 Mar 2017 05:36:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5G7-0000zK-Hr for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5G4-0000ad-Gg for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5G4-0000aR-AP for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D2413D941; Wed, 15 Mar 2017 09:30:16 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2F9UDPq024189; Wed, 15 Mar 2017 05:30:15 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D2413D941 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D2413D941 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:39 +0800 Message-Id: <20170315092940.1367-8-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 15 Mar 2017 09:30:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 7/8] qemu-iotests: support per-format golden output files 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some tests produce format-dependent output. Either the difference is filtered out and ignored, or the test case is format-specific so we don't need to worry about per-format output differences. There is a third case: the test script is the same for all image formats and the format-dependent output is relevant. An ugly workaround is to copy-paste the test into multiple per-format test cases. This duplicates code and is not maintainable. This patch allows test cases to add per-format golden output files so a single test case can work correctly when format-dependent output must be checked: 123.out.qcow2 123.out.raw 123.out.vmdk ... This naming scheme is not composable with 123.out.nocache or 123.pc.out, two other scenarios where output files are split. I don't think it matters since few test cases need these features. Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/check | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 4b1c674..29553cf 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -338,6 +338,11 @@ do reference=3D"$reference_machine" fi =20 + reference_format=3D"$source_iotests/$seq.out.$IMGFMT" + if [ -f "$reference_format" ]; then + reference=3D"$reference_format" + fi + if [ "$CACHEMODE" =3D "none" ]; then [ -f "$source_iotests/$seq.out.nocache" ] && reference=3D"= $source_iotests/$seq.out.nocache" fi --=20 2.9.3 From nobody Fri May 3 10:50:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489570460118719.9028208651441; Wed, 15 Mar 2017 02:34:20 -0700 (PDT) Received: from localhost ([::1]:35378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5Jy-0003Oq-Ow for importer@patchew.org; Wed, 15 Mar 2017 05:34:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1co5G9-000113-IR for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1co5G8-0000bf-Bc for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51502) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1co5G8-0000bE-2f for qemu-devel@nongnu.org; Wed, 15 Mar 2017 05:30:20 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1DED8635CB; Wed, 15 Mar 2017 09:30:20 +0000 (UTC) Received: from localhost (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2F9UHQT008090; Wed, 15 Mar 2017 05:30:19 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1DED8635CB Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=stefanha@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1DED8635CB From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 15 Mar 2017 17:29:40 +0800 Message-Id: <20170315092940.1367-9-stefanha@redhat.com> In-Reply-To: <20170315092940.1367-1-stefanha@redhat.com> References: <20170315092940.1367-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 15 Mar 2017 09:30:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v2 8/8] iotests: add test 178 for qemu-img measure 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: Kevin Wolf , John Snow , Nir Soffer , Maor Lipchuk , Stefan Hajnoczi , Alberto Garcia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/178 | 75 ++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/178.out.qcow2 | 33 ++++++++++++++++++ tests/qemu-iotests/178.out.raw | 33 ++++++++++++++++++ tests/qemu-iotests/group | 1 + 4 files changed, 142 insertions(+) create mode 100755 tests/qemu-iotests/178 create mode 100644 tests/qemu-iotests/178.out.qcow2 create mode 100644 tests/qemu-iotests/178.out.raw diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178 new file mode 100755 index 0000000..8db1241 --- /dev/null +++ b/tests/qemu-iotests/178 @@ -0,0 +1,75 @@ +#!/bin/bash +# +# qemu-img measure sub-command tests +# +# Copyright (C) 2017 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 . +# + +# creator +owner=3Dstefanha@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +here=3D`pwd` +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.pattern + +_supported_fmt raw qcow2 +_supported_proto file +_supported_os Linux + +echo "Input validation" +echo + +_make_test_img 1G + +$QEMU_IMG measure # missing arguments +$QEMU_IMG measure --size 2G "$TEST_IMG" # only one allowed +$QEMU_IMG measure "$TEST_IMG" a # only one filename allowed +$QEMU_IMG measure --object secret,id=3Dsec0,data=3DMTIzNDU2,format=3Dbase6= 4 # missing filename +$QEMU_IMG measure --image-opts # missing filename +$QEMU_IMG measure -f qcow2 # missing filename +$QEMU_IMG measure -l snap1 # missing filename +$QEMU_IMG measure -o , # invalid option list +$QEMU_IMG measure -l snapshot.foo # invalid snapshot option +$QEMU_IMG measure --output foo # invalid output format +$QEMU_IMG measure --size -1 # invalid image size +$QEMU_IMG measure -O foo "$TEST_IMG" # unknown image file format + +echo +echo "Size calculation" +echo + +for ofmt in human json; do + $QEMU_IMG measure --output=3D$ofmt -O "$IMGFMT" --size 2G + $QEMU_IMG measure --output=3D$ofmt -f "$IMGFMT" -O "$IMGFMT" "$TEST_IM= G" +done + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.= qcow2 new file mode 100644 index 0000000..3fe3f5f --- /dev/null +++ b/tests/qemu-iotests/178.out.qcow2 @@ -0,0 +1,33 @@ +QA output created by 178 +Input validation + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 +qemu-img: Either --size N or one filename must be specified. +qemu-img: --size N cannot be used together with a filename. +qemu-img: At most one filename argument is allowed. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: Invalid option list: , +qemu-img: Invalid parameter 'snapshot.foo' +qemu-img: Failed in parsing snapshot param 'snapshot.foo' +qemu-img: --output must be used with human or json as argument. +qemu-img: Image size must be less than 8 EiB! +qemu-img: Unknown file format 'foo' + +Size calculation + +required bytes: 589824 +fully allocated bytes: 2148073472 +required bytes: 327680 +fully allocated bytes: 1074069504 +{ + "required-bytes": 589824, + "fully-allocated-bytes": 2148073472 +} +{ + "required-bytes": 327680, + "fully-allocated-bytes": 1074069504 +} +*** done diff --git a/tests/qemu-iotests/178.out.raw b/tests/qemu-iotests/178.out.raw new file mode 100644 index 0000000..4b89dd0 --- /dev/null +++ b/tests/qemu-iotests/178.out.raw @@ -0,0 +1,33 @@ +QA output created by 178 +Input validation + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1073741824 +qemu-img: Either --size N or one filename must be specified. +qemu-img: --size N cannot be used together with a filename. +qemu-img: At most one filename argument is allowed. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: Invalid option list: , +qemu-img: Invalid parameter 'snapshot.foo' +qemu-img: Failed in parsing snapshot param 'snapshot.foo' +qemu-img: --output must be used with human or json as argument. +qemu-img: Image size must be less than 8 EiB! +qemu-img: Unknown file format 'foo' + +Size calculation + +required bytes: 2147483648 +fully allocated bytes: 2147483648 +required bytes: 1073741824 +fully allocated bytes: 1073741824 +{ + "required-bytes": 2147483648, + "fully-allocated-bytes": 2147483648 +} +{ + "required-bytes": 1073741824, + "fully-allocated-bytes": 1073741824 +} +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 1f4bf03..846f962 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -168,3 +168,4 @@ 173 rw auto 174 auto 175 auto quick +178 auto quick --=20 2.9.3