From: Max Reitz <mreitz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
Nir Soffer <nsoffer@redhat.com>,
Maor Lipchuk <mlipchuk@redhat.com>,
Alberto Garcia <berto@igalia.com>
Subject: Re: [Qemu-devel] [PATCH v8 1/9] block: add bdrv_measure() API
Date: Fri, 30 Jun 2017 15:51:09 +0200 [thread overview]
Message-ID: <b3a700eb-19fa-1e5f-48c0-dafba5bda07b@redhat.com> (raw)
In-Reply-To: <20170614153557.3319-2-stefanha@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2718 bytes --]
On 2017-06-14 17:35, Stefan Hajnoczi wrote:
> 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 <stefanha@redhat.com>
> Reviewed-by: Alberto Garcia <berto@igalia.com>
> ---
> v6:
> * Change bdrv_measure() return type to BlockMeasureInfo * [Eric]
> * Clarify that holes in sparse POSIX files are still counted [Eric]
> ---
> qapi/block-core.json | 25 +++++++++++++++++++++++++
> include/block/block.h | 2 ++
> include/block/block_int.h | 2 ++
> block.c | 35 +++++++++++++++++++++++++++++++++++
> 4 files changed, 64 insertions(+)
[...]
> diff --git a/block.c b/block.c
> index fa1d06d..056400a 100644
> --- a/block.c
> +++ b/block.c
> @@ -3446,6 +3446,41 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
> return -ENOTSUP;
> }
>
> +/*
> + * bdrv_measure:
> + * @drv: Format driver
> + * @opts: Creation options for new image
> + * @in_bs: Existing image containing data for new image (may be NULL)
> + * @errp: Error object
> + * Returns: A #BlockMeasureInfo (free using qapi_free_BlockMeasureInfo())
> + * or NULL on error
> + *
> + * 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.
Well, it's a bit weird that qcow2 just doesn't do this, then. :-)
I'm not really complaining (I think it's the best for qcow2 to ignore
this, at least for now), but maybe an s/are/may be/ would be more
appropriate...
(I wouldn't have complained if I hadn't replied to patch 7 anyway.)
Max
> + *
> + * 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.
> + *
> + * If an error occurs the @errp pointer is set.
> + */
> +BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts,
> + BlockDriverState *in_bs, Error **errp)
> +{
> + if (!drv->bdrv_measure) {
> + error_setg(errp, "Block driver '%s' does not support size measurement",
> + drv->format_name);
> + return NULL;
> + }
> +
> + return drv->bdrv_measure(opts, in_bs, errp);
> +}
> +
> /**
> * Return number of sectors on success, -errno on error.
> */
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 498 bytes --]
next prev parent reply other threads:[~2017-06-30 13:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-14 15:35 [Qemu-devel] [PATCH v8 0/9] qemu-img: add measure sub-command Stefan Hajnoczi
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 1/9] block: add bdrv_measure() API Stefan Hajnoczi
2017-06-30 13:51 ` Max Reitz [this message]
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 2/9] raw-format: add bdrv_measure() support Stefan Hajnoczi
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 3/9] qcow2: extract preallocation calculation function Stefan Hajnoczi
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 4/9] qcow2: make refcount size calculation conservative Stefan Hajnoczi
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 5/9] qcow2: extract image creation option parsing Stefan Hajnoczi
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 6/9] qcow2: add bdrv_measure() support Stefan Hajnoczi
2017-06-16 10:25 ` Alberto Garcia
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 7/9] qemu-img: add measure subcommand Stefan Hajnoczi
2017-06-16 10:50 ` Alberto Garcia
2017-06-30 13:49 ` Max Reitz
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 8/9] qemu-iotests: support per-format golden output files Stefan Hajnoczi
2017-06-14 15:35 ` [Qemu-devel] [PATCH v8 9/9] iotests: add test 178 for qemu-img measure Stefan Hajnoczi
2017-06-16 10:51 ` Alberto Garcia
2017-06-30 13:55 ` [Qemu-devel] [PATCH v8 0/9] qemu-img: add measure sub-command Max Reitz
2017-07-05 12:59 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3a700eb-19fa-1e5f-48c0-dafba5bda07b@redhat.com \
--to=mreitz@redhat.com \
--cc=berto@igalia.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mlipchuk@redhat.com \
--cc=nsoffer@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).