From: Markus Armbruster <armbru@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Peter Lieven <pl@kamp.de>,
"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, 07 Nov 2017 11:22:33 +0100 [thread overview]
Message-ID: <877ev24cd2.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20171020100853.GF21393@stefanha-x1.localdomain> (Stefan Hajnoczi's message of "Fri, 20 Oct 2017 12:08:53 +0200")
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.
next prev parent reply other threads:[~2017-11-07 10:22 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 [this message]
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
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=877ev24cd2.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=kwolf@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 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.