From: Paolo Bonzini <pbonzini@redhat.com>
To: Miroslav Rezanina <mrezanin@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH][RFC] Add compare subcommand for qemu-img
Date: Wed, 01 Aug 2012 12:52:09 +0200 [thread overview]
Message-ID: <50190A59.2050608@redhat.com> (raw)
In-Reply-To: <579280363.6931076.1343817896059.JavaMail.root@redhat.com>
Il 01/08/2012 12:44, Miroslav Rezanina ha scritto:
>>
>> Also, perhaps we can add a "strict" mode (-S) that would fail if the
>> images are of different size, and if a sector is allocated in one but
>> unallocated in the other?
>>
>> And a "silent" or "quiet" mode (-s or -q, your choice) that prints
>> nothing, too.
>>
>
> Good idea with additional modes. I'm not sure if strict should fail on
> allocated/unallocated - you can compare sparse/non-sparce when is this
> highly probable.
For that use case you probably know in advance that the size is the
same, so you can use normal non-strict mode.
Comparing allocated/unallocated on the other hand is helpful with unit
tests.
>> You can make total_sectors1/2 unsigned, and avoid the assignment.
>>
> This is using similar construct as img_convert I inspire in. I will
> change this in v2.
Oh, sorry then---consistency is better, please keep it as it is now.
>>> > > + bdrv_get_geometry(bs2,&bs_sectors);
>>> > > + total_sectors2 = bs_sectors;
>>> > > + total_sectors = total_sectors1;
>>> > > + progress_base = total_sectors;
>> >
>> > over_sectors = MAX(total_sectors1, total_sectors2);
>> > total_sector = MIN(total_sectors1, total_sectors2);
>> > over_num = over_sectors - total_sectors;
>> >
>>> > > + if (total_sectors1 != total_sectors2) {
>> >
>> > Using MAX/MIN as above, you can move this part to after you checked
>> > the
>> > common part of the image, so that images are read sequentially.
>> >
>> > You can still place the test here in strict mode. With the
>> > assignments
>> > given above, you can do the test simply like this:
>> >
>> > if (over_num > 0) {
>> > }
>> >
> I want to have this check prior common part check - we do not have
> to check rest of the image if we know there's something in this area
> of disk.
But if one of the two images is preallocated raw, or qcow2 with
preallocated metadata, or your filesystem does not support is_allocated
on raw images, then you're still reading all of the image just to check
against zeros.
Admittedly there is no single correct solution. Hopefully other
reviewers will break the tie.
Paolo
next prev parent reply other threads:[~2012-08-01 10:52 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1736118218.6697488.1343814369561.JavaMail.root@redhat.com>
2012-08-01 10:03 ` [Qemu-devel] [PATCH][RFC] Add compare subcommand for qemu-img Miroslav Rezanina
2012-08-01 10:22 ` Paolo Bonzini
2012-08-01 10:44 ` Miroslav Rezanina
2012-08-01 10:52 ` Paolo Bonzini [this message]
2012-08-02 10:06 ` Miroslav Rezanina
2012-08-02 11:11 ` Paolo Bonzini
2012-08-01 12:22 ` Stefan Hajnoczi
2012-08-01 13:21 ` Eric Blake
2012-08-01 13:23 ` Paolo Bonzini
2012-08-02 5:19 ` Miroslav Rezanina
2012-08-03 6:45 ` [Qemu-devel] [PATCH v2][RFC] " Miroslav Rezanina
2012-08-03 15:23 ` Eric Blake
2012-11-20 12:36 ` Kevin Wolf
2012-11-20 13:04 ` Miroslav Rezanina
2012-11-21 9:50 ` [Qemu-devel] [PATCH v3] " Miroslav Rezanina
2012-11-22 9:18 ` Stefan Hajnoczi
2012-11-27 8:03 ` [Qemu-devel] [PATCH v4] " Miroslav Rezanina
2012-11-30 14:22 ` Stefan Hajnoczi
2012-12-04 11:06 ` [Qemu-devel] [PATCH v5] " Miroslav Rezanina
2012-12-04 15:22 ` Stefan Hajnoczi
2012-12-06 12:24 ` [Qemu-devel] [PATCH v6] " Miroslav Rezanina
2012-12-11 9:16 ` Stefan Hajnoczi
2012-12-11 12:27 ` Kevin Wolf
2012-12-11 13:09 ` Miroslav Rezanina
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=50190A59.2050608@redhat.com \
--to=pbonzini@redhat.com \
--cc=mrezanin@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).