qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_snapshot_table()
Date: Wed, 31 Jul 2019 10:59:03 +0200	[thread overview]
Message-ID: <400fcddf-d1c4-c4bf-8536-403c02a9687b@redhat.com> (raw)
In-Reply-To: <e21f44ce-89d9-d51b-b461-6f939a3f98e9@redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 1956 bytes --]

On 30.07.19 20:53, Eric Blake wrote:
> On 7/30/19 12:25 PM, Max Reitz wrote:
>> Reading the snapshot table can fail.  That is a problem when we want to
>> repair the image.
>>
>> Therefore, stop reading the snapshot table in qcow2_do_open() in check
>> mode.  Instead, add a new function qcow2_check_read_snapshot_table()
>> that reads the snapshot table at a later point.  In the future, we want
>> to handle errors here and fix them.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>  block/qcow2.h          |  4 +++
>>  block/qcow2-snapshot.c | 58 ++++++++++++++++++++++++++++++++
>>  block/qcow2.c          | 76 ++++++++++++++++++++++++++++++++----------
>>  3 files changed, 120 insertions(+), 18 deletions(-)
>>
> 
>> +++ b/block/qcow2-snapshot.c
>> @@ -321,6 +321,64 @@ fail:
>>      return ret;
>>  }
>>  
>> +int coroutine_fn qcow2_check_read_snapshot_table(BlockDriverState *bs,
>> +                                                 BdrvCheckResult *result,
>> +                                                 BdrvCheckMode fix)
>> +{
>> +    BDRVQcow2State *s = bs->opaque;
>> +    Error *local_err = NULL;
>> +    int ret;
>> +    struct {
>> +        uint32_t nb_snapshots;
>> +        uint64_t snapshots_offset;
>> +    } QEMU_PACKED snapshot_table_pointer;
>> +
>> +    /* qcow2_do_open() discards this information in check mode */
>> +    ret = bdrv_pread(bs->file, 60, &snapshot_table_pointer,
>> +                     sizeof(snapshot_table_pointer));
> 
> Should that '60' be a named constant or offsetof() expression?  (I know,
> you just copied this instance from elsewhere)

Well, I copied it from the specification. O:-)

You’re completely right.  It should be offsetof(QCowHeader, nb_snapshots).

(I blame the fact that I had started writing the test by this point, so
I was already immersed in so many magic numbers.)

> Reviewed-by: Eric Blake <eblake@redhat.com>



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-07-31  8:59 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 17:24 [Qemu-devel] [PATCH for-4.2 00/13] qcow2: Let check -r all repair some snapshot bits Max Reitz
2019-07-30 17:24 ` [Qemu-devel] [PATCH for-4.2 01/13] qcow2: Add Error ** to qcow2_read_snapshots() Max Reitz
2019-07-30 17:41   ` Eric Blake
2019-07-30 17:24 ` [Qemu-devel] [PATCH for-4.2 02/13] qcow2: Keep unknown extra snapshot data Max Reitz
2019-07-30 17:56   ` Eric Blake
2019-07-31  8:54     ` Max Reitz
2019-08-16  2:09       ` Max Reitz
2019-07-30 17:24 ` [Qemu-devel] [PATCH for-4.2 03/13] qcow2: Make qcow2_write_snapshots() public Max Reitz
2019-07-30 17:57   ` Eric Blake
2019-07-30 17:24 ` [Qemu-devel] [PATCH for-4.2 04/13] qcow2: Put qcow2_upgrade() into an own function Max Reitz
2019-07-30 18:00   ` Eric Blake
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 05/13] qcow2: Write v3-compliant snapshot list on upgrade Max Reitz
2019-07-30 18:10   ` Eric Blake
2019-07-31  8:56     ` Max Reitz
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 06/13] qcow2: Separate qcow2_check_read_snapshot_table() Max Reitz
2019-07-30 18:53   ` Eric Blake
2019-07-31  8:59     ` Max Reitz [this message]
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 07/13] qcow2: Add qcow2_check_fix_snapshot_table() Max Reitz
2019-07-30 18:54   ` Eric Blake
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 08/13] qcow2: Fix broken snapshot table entries Max Reitz
2019-07-30 19:02   ` Eric Blake
2019-07-31  9:06     ` Max Reitz
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 09/13] qcow2: Fix overly long snapshot tables Max Reitz
2019-07-30 19:08   ` Eric Blake
2019-07-31  9:22     ` Max Reitz
2019-08-16 18:06       ` Max Reitz
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 10/13] qcow2: Repair snapshot table with too many entries Max Reitz
2019-07-30 19:10   ` Eric Blake
2019-07-31  9:25     ` Max Reitz
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 11/13] qcow2: Fix v3 snapshot table entry compliancy Max Reitz
2019-07-30 19:12   ` Eric Blake
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 12/13] iotests: Add peek_file* functions Max Reitz
2019-07-30 19:22   ` Eric Blake
2019-07-31  9:27     ` Max Reitz
2019-07-30 17:25 ` [Qemu-devel] [PATCH for-4.2 13/13] iotests: Test qcow2's snapshot table handling Max Reitz
2019-07-30 19:56   ` Eric Blake
2019-07-31  9:36     ` Max Reitz
2019-07-30 17:39 ` [Qemu-devel] [PATCH for-4.2 00/13] qcow2: Let check -r all repair some snapshot bits 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=400fcddf-d1c4-c4bf-8536-403c02a9687b@redhat.com \
    --to=mreitz@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).