All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Peter Lieven <pl@kamp.de>
Cc: codyprime@gmail.com, mreitz@redhat.com, jhf@kamp.de,
	qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V3] block/vhdx: add check for truncated image files
Date: Tue, 10 Sep 2019 13:15:30 +0200	[thread overview]
Message-ID: <20190910111530.GD4446@localhost.localdomain> (raw)
In-Reply-To: <e3964790-286f-5e65-01c7-c71c74c23475@kamp.de>

Am 05.09.2019 um 12:02 hat Peter Lieven geschrieben:
> Am 04.09.19 um 16:09 schrieb Kevin Wolf:
> > Am 03.09.2019 um 15:35 hat Peter Lieven geschrieben:
> > > qemu is currently not able to detect truncated vhdx image files.
> > > Add a basic check if all allocated blocks are reachable at open and
> > > report all errors during bdrv_co_check.
> > > 
> > > Signed-off-by: Peter Lieven <pl@kamp.de>
> > > ---
> > > V3: - check for bdrv_getlength failure [Kevin]
> > >      - use uint32_t for i [Kevin]
> > >      - check for BAT entry overflow [Kevin]
> > >      - break on !errcnt in second check
> > > 
> > > V2: - add error reporting [Kevin]
> > >      - use bdrv_getlength instead of bdrv_get_allocated_file_size [Kevin]
> > >      - factor out BAT entry check and add error reporting for region
> > >        overlaps
> > >      - already check on vhdx_open
> > Something still seems to be wrong with this patch:
> > 
> >      213      fail       [15:50:13] [15:50:14]      (last: 2s)    output mismatch (see 213.out.bad)
> >      --- /home/kwolf/source/qemu/tests/qemu-iotests/213.out  2019-06-28 14:19:50.065797707 +0200
> >      +++ /home/kwolf/source/qemu/tests/qemu-iotests/213.out.bad      2019-09-04 15:50:14.582053976 +0200
> >      @@ -46,10 +46,8 @@
> >       {"execute": "job-dismiss", "arguments": {"id": "job0"}}
> >       {"return": {}}
> > 
> >      -image: TEST_IMG
> >      -file format: IMGFMT
> >      -virtual size: 32 MiB (33554432 bytes)
> >      -cluster_size: 268435456
> >      +qemu-img: VHDX BAT entry 0 offset points after end of file. Image has probably been truncated.
> >      +qemu-img: Could not open 'TEST_IMG': Could not open 'TEST_IMG': Invalid argument
> > 
> >       === Invalid BlockdevRef ===
> > 
> > I can reproduce this manually with the following qemu-img invocations.
> > It seems all three options must be given to reproduce the error:
> > 
> >      $ ./qemu-img create -f vhdx -o block_size=268435456,subformat=fixed,block_state_zero=off /tmp/test.vhdx 32M
> >      Formatting '/tmp/test.vhdx', fmt=vhdx size=33554432 log_size=1048576 block_size=268435456 subformat=fixed block_state_zero=off
> >      $ ./qemu-img info /tmp/test.vhdx
> >      qemu-img: VHDX BAT entry 0 offset points after end of file. Image has probably been truncated.
> >      qemu-img: Could not open '/tmp/test.vhdx': Could not open '/tmp/test.vhdx': Invalid argument
> > 
> > If I add the offsets to the error message (would probably nice to have),
> > I get:
> > 
> >      qemu-img: VHDX BAT entry 0 offset 8388608 points after end of file (41943040). Image has probably been truncated.
> > 
> > So it seems that the file is large enough to hold 32M + metadata, but we
> > don't increase the file size to hold a full block (256M). Is this a
> > problem in the way we create images or are partial blocks at the end
> > expected?
> > 
> > Kevin
> 
> 
> A short look into the VHDX spec [1] seems to suggest that a VHDX File
> can only grow in Block increments.
> 
> See page 8 in the definition of blocks: "Allocation of new space for a
> virtual hard disk that supports dynamic growth of the virtual hard
> disk file is done in fixes size units defined as blocks."

Then I guess we need to fix the creation of VHDX images before we can
apply this patch because otherwise qemu-iotests fails.

Hm... And probably ignore the error for a partial final block anyway to
maintain compatibility with images created by older QEMU versions.

Kevin


  reply	other threads:[~2019-09-10 11:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-03 13:35 [Qemu-devel] [PATCH V3] block/vhdx: add check for truncated image files Peter Lieven
2019-09-04 14:09 ` Kevin Wolf
2019-09-05  9:49   ` Peter Lieven
2019-09-05 10:02   ` Peter Lieven
2019-09-10 11:15     ` Kevin Wolf [this message]
2019-09-10 11:49       ` Peter Lieven

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=20190910111530.GD4446@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=codyprime@gmail.com \
    --cc=jhf@kamp.de \
    --cc=mreitz@redhat.com \
    --cc=pl@kamp.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.