qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] Clean Block Driver Shutdown


From: Peter Lieven
Subject: Re: [Qemu-block] Clean Block Driver Shutdown
Date: Tue, 17 Oct 2017 13:49:08 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

Am 17.10.2017 um 13:46 schrieb Kevin Wolf:
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.

A clean error path would obviously be a good idea. However,
the following seems to work:

diff --git a/vl.c b/vl.c
index 0723835..bed512c 100644
--- a/vl.c
+++ b/vl.c
@@ -3197,6 +3197,7 @@ int main(int argc, char **argv, char **envp)
     nb_nics = 0;

     bdrv_init_with_whitelist();
+    atexit(bdrv_close_all);

     autostart = 1;

Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]