From: Kevin Wolf <kwolf@redhat.com>
To: Peter Lieven <pl@kamp.de>
Cc: Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@gmail.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
qemu block <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-block] Clean Block Driver Shutdown
Date: Tue, 7 Nov 2017 12:11:01 +0100 [thread overview]
Message-ID: <20171107111101.GB4706@localhost.localdomain> (raw)
In-Reply-To: <8197c6f4-06c6-8b7e-23d1-31a08796493d@kamp.de>
Am 07.11.2017 um 11:48 hat Peter Lieven geschrieben:
> Am 07.11.2017 um 11:22 schrieb Markus Armbruster:
> > Stefan Hajnoczi <stefanha@gmail.com> writes:
> >
> > > On Tue, Oct 17, 2017 at 01:46:25PM +0200, Kevin Wolf wrote:
> > > > Am 17.10.2017 um 12:33 hat Peter Lieven geschrieben:
> > > > > I noticed that Qemu quits at several points with an exit() if the
> > > > > supplied parameters in the commandline are incorrect. This at some
> > > > > stages happens after there have already been connections to storage
> > > > > backends established.
> > > > Maybe we need to come to the conclusion that exit() is always wrong,
> > > > even during the initialisation.
> > > >
> > > > > These connections are not cleanly shut down in this case. For posix
> > > > > file backends that doesn't matter, but for other backends this leads
> > > > > to errors. E.g. iSCSI Targets log an aborted iSCSI connection due to
> > > > > tcp reset.
> > > > >
> > > > > I wonder what is the best way to fix this. A simply call to
> > > > > bdrv_close_all() in an atexit handler seems to work. But is this a
> > > > > good solution? Maybe register this handler only until the VM starts.
> > > > > Or do we need an atexit handler in each block driver that requires a
> > > > > clean shutdown?
> > > > No, definitely not code in every single block driver. We need to make
> > > > sure to properly clean up what has been started.
> > > >
> > > > An atexit handler is probably relatively easy. I think it would be
> > > > cleaner to have proper error paths even in main(), like in every other
> > > > function. I'm not sure if this would be reasonably easy to achieve,
> > > > though.
> > > I agree that converting from exit(3) to real error handling is cleanest.
> > > Doing so would also be a good opportunity to consolidate ad-hoc
> > > fprintf(stderr) and error_report() calls.
> > error_report() & exit() assume a certain context. They're good enough
> > when the assumption obviously holds.
> >
> > We also use them in code that can run when the assumption doesn't hold.
> > Sometimes because the code acquired new users, sometimes because the
> > code was always wrong. Regardless, these are bugs in need of fixing.
> >
> > We also use them in code that currently happens to run only when the
> > assumption holds. Trap for the unwary, cleanup can make sense, but is
> > hardly a priority.
>
> Of course, no priority, but how would you then handle block drivers
> that need a clean shutdown? Register atexit handlers for them?
These are cases where the assumption doesn't hold, so they might in fact
be a priority.
I'm not sure if there are any cases of the assumption obviously holding
apart from the first two calls in main(), but at least we know that the
assumption obviously breaks after creating block devices starting in
vl.c:4654, which at least includes the rest of main() itself as well as
the creation of the machine and the device models.
Kevin
prev parent reply other threads:[~2017-11-07 11:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-17 10:33 [Qemu-devel] Clean Block Driver Shutdown Peter Lieven
2017-10-17 11:46 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2017-10-17 11:49 ` Peter Lieven
2017-10-20 10:08 ` Stefan Hajnoczi
2017-11-07 10:22 ` Markus Armbruster
2017-11-07 10:48 ` Peter Lieven
2017-11-07 11:02 ` Markus Armbruster
2017-11-07 11:09 ` Peter Lieven
2017-11-07 11:11 ` Kevin Wolf [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=20171107111101.GB4706@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--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).