qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v2 0/3] block: Warn about usage of growing formats over non-growable protocols
Date: Fri, 8 May 2015 12:08:32 +0200	[thread overview]
Message-ID: <20150508100832.GC4318@noname.redhat.com> (raw)
In-Reply-To: <554B7BBC.2040508@redhat.com>

Am 07.05.2015 um 16:50 hat Paolo Bonzini geschrieben:
> On 07/05/2015 16:34, Kevin Wolf wrote:
> > Am 07.05.2015 um 16:16 hat Paolo Bonzini geschrieben:
> >>
> >>
> >> On 07/05/2015 16:07, Kevin Wolf wrote:
> >>> This is not right for two reasons: The first is that this is
> >>> BlockBackend code
> >>
> >> I think it would take effect for the qemu-nbd case though.
> > 
> > Oh, you want to change the server code rather than the client?
> 
> Yes.

Actually, considering all the information in this thread, I'm inclined
that we should change both sides. qemu-nbd because ENOSPC might be what
clients expect by analogy with Linux block devices, even if the
behaviour for accesses beyond the device size isn't specified in the NBD
protocol and the server might just do anything. As long as the behaviour
is undefined, it's nice to do what most people may expect.

And as the real fix change the nbd client, because even if new qemu-nbd
versions will be nice, we shouldn't rely on undefined behaviour. We know
that old qemu-nbd servers won't produce ENOSPC and I'm not sure what
other NBD servers do.

> > Wait... Are you saying that NBD sends a (platform specific) errno value
> > over the network? :-/
> 
> Yes. :/  That said, at least the error codes that Linux places in
> /usr/include/asm/errno-base.h seem to be pretty much standard---at least
> Windows and most Unices share them---with the exception of EAGAIN.
> 
> I'll send a patch to NBD to standardize the set of error codes that it
> sends.

Thanks, that will be helpful in the future.

Is this the right place to look up the spec?
http://sourceforge.net/p/nbd/code/ci/master/tree/doc/proto.txt

If so, the commands seem to be hopelessly underspecified, especially
with respect to error conditions. And where it says something about
errors, it doesn't make sense: The server is forbidden to reply to a
NBD_CMD_FLUSH if it failed... (qemu-nbd ignores this, obviously)

> > In theory, what error code the NBD server needs to send should be
> > specified by the NBD protocol. Am I right to assume that it doesn't do
> > that?
> 
> Nope.
> 
> > In any case, I'm not sure whether qemu's internal error code
> > should change just for NBD. Producing the right error code for the
> > protocol is the job of nbd_co_receive_request().
> 
> Ok, so it shouldn't reach blk_check_request at all.  But then, we should
> aim at making blk_check_request's checks assertions.

Sounds fair as a goal, but I don't think all devices have such checks
yet. We've fixed the most common devices (IDE, scsi-disk and virtio-blk)
just a while ago.

> >>> and it wouldn't even take effect for the qcow2 case
> >>> where we're writing past EOF only on the protocol layer. The second is
> >>> that -ENOSPC is only for writes and not for reads.
> >>
> >> This is right.
> >>
> >> Reads in the kernel return 0, but in QEMU we do not want that.  The code
> >> currently returns -EIO, but perhaps -EINVAL is a better match.  It also
> >> happens to be what Linux returns for discards.
> > 
> > Perhaps it is, yes. It shouldn't make a difference for guests anyway.
> > (Unlike -ENOSPC for writes, which would trigger werror=enospc! That's
> > most likely not what we want.)
> 
> Yes, we want the check duplicated in all BlockBackend users.  Most of
> them already do it, see the work that Markus did last year I think.

I wouldn't call it duplicated because the action to take is different
for each device, but yes, the check belongs there.

Kevin

  reply	other threads:[~2015-05-08 10:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19 19:03 [Qemu-devel] [PATCH v2 0/3] block: Warn about usage of growing formats over non-growable protocols Max Reitz
2015-03-19 19:03 ` [Qemu-devel] [PATCH v2 1/3] iotests: Make nested read in 072 and 089 read-only Max Reitz
2015-03-19 19:23   ` Eric Blake
2015-03-19 19:03 ` [Qemu-devel] [PATCH v2 2/3] block: Introduce BDS.growing Max Reitz
2015-03-19 20:11   ` Eric Blake
2015-03-19 19:03 ` [Qemu-devel] [PATCH v2 3/3] block: Introduce BlockDriver.requires_growing_file Max Reitz
2015-03-19 20:18   ` Eric Blake
2015-05-05  9:46 ` [Qemu-devel] [PATCH v2 0/3] block: Warn about usage of growing formats over non-growable protocols Stefan Hajnoczi
2015-05-06 13:04   ` Max Reitz
2015-05-06 15:30     ` Paolo Bonzini
2015-05-06 16:12       ` [Qemu-devel] [Qemu-block] " Max Reitz
2015-05-06 16:20         ` Paolo Bonzini
2015-05-06 16:37           ` Max Reitz
2015-05-06 16:47             ` Paolo Bonzini
2015-05-06 17:23               ` Max Reitz
2015-05-07 12:20                 ` Paolo Bonzini
2015-05-07 12:29                   ` Kevin Wolf
2015-05-07 12:47                     ` Paolo Bonzini
2015-05-07 13:20                       ` Kevin Wolf
2015-05-07 13:55                         ` Paolo Bonzini
2015-05-07 14:07                           ` Kevin Wolf
2015-05-07 14:16                             ` Paolo Bonzini
2015-05-07 14:34                               ` Kevin Wolf
2015-05-07 14:50                                 ` Paolo Bonzini
2015-05-08 10:08                                   ` Kevin Wolf [this message]
2015-05-08 10:16                                     ` Paolo Bonzini
2015-05-08 10:34                                       ` Kevin Wolf
2015-05-08 11:00                                         ` Paolo Bonzini
2015-05-08 12:58                                     ` Max Reitz

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=20150508100832.GC4318@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.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).