qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Asias He <asias@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel <qemu-devel@nongnu.org>,
	MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Subject: Re: [Qemu-devel] [PATCH] block: Produce zeros when protocols reading beyond end of file
Date: Mon, 19 Aug 2013 14:09:24 +0200	[thread overview]
Message-ID: <20130819120924.GC3591@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <20130819063614.GA14101@hj.localdomain>

On Mon, Aug 19, 2013 at 02:36:14PM +0800, Asias He wrote:
> On Fri, Aug 16, 2013 at 10:41:36AM +0200, Stefan Hajnoczi wrote:
> > On Mon, Aug 5, 2013 at 10:11 AM, Asias He <asias@redhat.com> wrote:
> > A simple but ugly way to fix this is for block.c to also have a
> > ->zero_beyond_eof flag which enables the behavior you are adding.
> > qcow2_load_vmstate() would disable ->zero_beyond_eof temporarily in
> > addition to enabling ->growable.
> 
> I am wondering why the ->growable logic is introduced in the first
> place.  Adding yet another this kind of flag looks realy ugly ;(

bs->growable serves two functions:

1. It means you can read/write beyond the end of the file, for example,
   when creating a new image file.  Normally BlockDriverState rejects
   requests beyond the EOF.

2. qcow2 uses it as a hack to implement the vmstate area after the end
   of regular guest data.  This is the ugly part but it always worked up
   until now.

#1 is a legitimate use case.  You don't always know how big the file
will end up so it's much more convenient to grow on demand, instead of
having to bdrv_truncate() all the time.

#2 is hacky but hard to solve without duplicating the bounce buffer and
coroutine wrapping logic in bdrv_pread() (Kevin has suggested calling
bdrv_co_readv() internally instead of bdrv_pread()).

Stefan

      reply	other threads:[~2013-08-19 12:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05  8:11 [Qemu-devel] [PATCH] block: Produce zeros when protocols reading beyond end of file Asias He
2013-08-05 12:41 ` Kevin Wolf
2013-08-06  1:53   ` [Qemu-devel] [PATCH v2] " Asias He
2013-08-06  2:02     ` Fam Zheng
2013-08-06  2:38       ` Asias He
2013-08-07  8:04         ` Stefan Hajnoczi
2013-08-13 13:50     ` Stefan Hajnoczi
2013-08-22 12:13     ` Stefan Hajnoczi
2013-08-16  8:41 ` [Qemu-devel] [PATCH] " Stefan Hajnoczi
2013-08-19  6:36   ` Asias He
2013-08-19 12:09     ` Stefan Hajnoczi [this message]

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=20130819120924.GC3591@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=asias@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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).