qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: "Li Qiang" <liq3ea@gmail.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] util: check the return value of fcntl in qemu_set_{block, noblock}
Date: Thu, 13 Dec 2018 11:27:35 +0000	[thread overview]
Message-ID: <CAFEAcA_rBakXJZuPGgcsvC9m75oeTbg=q-=mOCFJuungF-VR8g@mail.gmail.com> (raw)
In-Reply-To: <20181213101940.GC5171@redhat.com>

On Thu, 13 Dec 2018 at 10:19, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Wed, Dec 12, 2018 at 06:09:37PM -0800, Li Qiang wrote:
> > Assert that the return value is not an error. This is like commit
> > 7e6478e7d4f for qemu_set_cloexec.
> >
> > Signed-off-by: Li Qiang <liq3ea@gmail.com>
> > ---
> >  util/oslib-posix.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> > index c1bee2a581..4ce1ba9ca4 100644
> > --- a/util/oslib-posix.c
> > +++ b/util/oslib-posix.c
> > @@ -233,14 +233,18 @@ void qemu_set_block(int fd)
> >  {
> >      int f;
> >      f = fcntl(fd, F_GETFL);
> > -    fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
> > +    assert(f != -1);
>
> This leads to *awful* diagnostics. We need to print something
> useful when it fails so we stand a chance of understanding what
> is wrong.

It's the same thing we do in qemu_set_cloexec(), though,
and nobody's complained about that that I know of. I think
we need to understand whether we're getting asserts in
vhost_user_test because of something silly like passing -1
as the fd, or because the fcntl() can legitimately fail.
If the former, the assert isn't a big deal because when
we hit it in newly developed code the problem is going
to be obvious when run under a debugger. If the latter,
we need to actually pass out the error status and fix
all the callers to check it...

thanks
-- PMM

  reply	other threads:[~2018-12-13 11:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13  2:09 [Qemu-devel] [PATCH] util: check the return value of fcntl in qemu_set_{block, noblock} Li Qiang
2018-12-13  6:57 ` no-reply
2018-12-13  9:31   ` Peter Maydell
2018-12-13  9:56     ` Li Qiang
2018-12-13 10:17       ` Daniel P. Berrangé
2018-12-13 10:38         ` Li Qiang
2018-12-13 10:19 ` Daniel P. Berrangé
2018-12-13 11:27   ` Peter Maydell [this message]
2018-12-13 12:28     ` Markus Armbruster
2018-12-13 12:39       ` Daniel P. Berrangé
2018-12-13 12:54         ` Peter Maydell
2018-12-13 14:40           ` Markus Armbruster
2018-12-13 14:43         ` Markus Armbruster

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='CAFEAcA_rBakXJZuPGgcsvC9m75oeTbg=q-=mOCFJuungF-VR8g@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=berrange@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@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).