From: Eric Blake <eblake@redhat.com>
To: Eyal Moscovici <eyal.moscovici@oracle.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
liran.alon@oracle.com, Yoav Elnekave <yoav.elnekave@oracle.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH 2/2] qemu-img: Add --start-offset and --max-length to map
Date: Wed, 29 Apr 2020 10:04:53 -0500 [thread overview]
Message-ID: <30f82564-3807-89d4-e7b1-923868f15705@redhat.com> (raw)
In-Reply-To: <20200322091117.79443-3-eyal.moscovici@oracle.com>
On 3/22/20 4:11 AM, Eyal Moscovici wrote:
> The mapping operation of large disks especially ones stored over a
> long chain of QCOW2 files can take a long time to finish.
> Additionally when mapping fails there was no way recover by
> restarting the mapping from the failed location.
>
> The new options, --start-offset and --max-length allows the user to
> divide these type of map operations into shorter independent tasks.
>
> Acked-by: Mark Kanda <mark.kanda@oracle.com>
> Co-developed-by: Yoav Elnekave <yoav.elnekave@oracle.com>
> Signed-off-by: Yoav Elnekave <yoav.elnekave@oracle.com>
> Signed-off-by: Eyal Moscovici <eyal.moscovici@oracle.com>
> ---
> docs/tools/qemu-img.rst | 2 +-
> qemu-img-cmds.hx | 4 ++--
> qemu-img.c | 30 +++++++++++++++++++++++++++++-
> 3 files changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst
> index 0080f83a76..924e89f679 100644
> --- a/docs/tools/qemu-img.rst
> +++ b/docs/tools/qemu-img.rst
> @@ -519,7 +519,7 @@ Command description:
> ``ImageInfoSpecific*`` QAPI object (e.g. ``ImageInfoSpecificQCow2``
> for qcow2 images).
>
> -.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--output=OFMT] [-U] FILENAME
> +.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--start-offset=offset] [--max-length=len] [--output=OFMT] [-U] FILENAME
Consistency with the rest of the line says this should be
[--start-offset=OFFSET] [--max-length=LEN]
>
> Dump the metadata of image *FILENAME* and its backing file chain.
> In particular, this commands dumps the allocation state of every sector
> diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
> index c9c54de1df..35f832816f 100644
> --- a/qemu-img-cmds.hx
> +++ b/qemu-img-cmds.hx
> @@ -63,9 +63,9 @@ SRST
> ERST
>
> DEF("map", img_map,
> - "map [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [-U] filename")
> + "map [--object objectdef] [--image-opts] [-f fmt] [--start-offset=offset] [--max-length=len] [--output=ofmt] [-U] filename")
this one is fine,
> SRST
> -.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--output=OFMT] [-U] FILENAME
> +.. option:: map [--object OBJECTDEF] [--image-opts] [-f FMT] [--start-offset=OFFSET] [--max-length=LEN] [--output=OFMT] [-U] FILENAME
this one has the same problem as the .rst.
> @@ -3005,6 +3009,26 @@ static int img_map(int argc, char **argv)
> case OPTION_OUTPUT:
> output = optarg;
> break;
> + case 's':
> + start_offset = cvtnum(optarg);
> + if (start_offset < 0) {
> + error_report("Invalid start offset specified! You may use "
> + "k, M, G, T, P or E suffixes for ");
> + error_report("kilobytes, megabytes, gigabytes, terabytes, "
> + "petabytes and exabytes.");
Pre-existing elsewhere in the file, but this seems rather verbose -
shouldn't we have cvtnum() (or another wrapper function) give this extra
information about what is valid, rather than open-coding it at every
client of cvtnum()?
> + return 1;
> + }
> + break;
> + case 'l':
> + max_length = cvtnum(optarg);
> + if (max_length < 0) {
> + error_report("Invalid max length specified! You may use "
> + "k, M, G, T, P or E suffixes for ");
> + error_report("kilobytes, megabytes, gigabytes, terabytes, "
> + "petabytes and exabytes.");
> + return 1;
> + }
> + break;
> case OPTION_OBJECT: {
> QemuOpts *opts;
> opts = qemu_opts_parse_noisily(&qemu_object_opts,
> @@ -3050,7 +3074,11 @@ static int img_map(int argc, char **argv)
> printf("[");
> }
>
> + curr.start = start_offset;
> length = blk_getlength(blk);
> + if (max_length != -1) {
> + length = MIN(start_offset + max_length, length);
> + }
Pre-existing, but where does this code check for length == -1? But your
MIN() doesn't make it any worse (if we fail to get length, we merely
skip the loop).
> while (curr.start + curr.length < length) {
> int64_t offset = curr.start + curr.length;
> int64_t n;
>
Overall, the idea makes sense to me. But I'm not sure which maintainer
should actually incorporate the patch.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2020-04-29 15:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-22 9:11 [PATCH 0/2] Additional parameters for qemu_img map Eyal Moscovici
2020-03-22 9:11 ` [PATCH 1/2] qemu-img: refactor dump_map_entry JSON format output Eyal Moscovici
2020-04-29 14:58 ` Eric Blake
2020-05-06 9:55 ` Eyal Moscovici
2020-03-22 9:11 ` [PATCH 2/2] qemu-img: Add --start-offset and --max-length to map Eyal Moscovici
2020-04-29 15:04 ` Eric Blake [this message]
2020-05-06 9:52 ` Eyal Moscovici
2020-04-29 13:39 ` [PATCH 0/2] Additional parameters for qemu_img map John Snow
2020-05-06 21:34 ` [PATCH v2 0/5] " Eyal Moscovici
2020-05-06 21:34 ` [PATCH v2 1/5] qemu-img: remove check that cvtnum value > MAX_INT Eyal Moscovici
2020-05-06 21:49 ` Eric Blake
2020-05-12 9:39 ` Eyal Moscovici
2020-05-12 14:14 ` Eric Blake
2020-05-06 21:34 ` [PATCH v2 2/5] qemu_img: add error report to cvtnum Eyal Moscovici
2020-05-06 21:59 ` Eric Blake
2020-05-12 9:44 ` Eyal Moscovici
2020-05-06 21:34 ` [PATCH v2 3/5] qemu-img: validate image length in img_map Eyal Moscovici
2020-05-06 22:01 ` Eric Blake
2020-05-06 21:34 ` [PATCH v2 4/5] qemu-img: refactor dump_map_entry JSON format output Eyal Moscovici
2020-05-06 21:34 ` [PATCH v2 5/5] qemu-img: Add --start-offset and --max-length to map Eyal Moscovici
2020-05-06 22:04 ` Eric Blake
2020-05-12 9:48 ` Eyal Moscovici
2020-05-06 21:45 ` [PATCH v2 0/5] Additional parameters for qemu_img map Eric Blake
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=30f82564-3807-89d4-e7b1-923868f15705@redhat.com \
--to=eblake@redhat.com \
--cc=eyal.moscovici@oracle.com \
--cc=kwolf@redhat.com \
--cc=liran.alon@oracle.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=yoav.elnekave@oracle.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).