Skip to contentSkip to conversation

Prevent disk data loss when closing qemu

PATCH dunrong huang 4 participants 7 messages May 16, 2012 – May 24, 2012 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

What's the difference of these two method to call bdrv_close_all?

If you close qemu window, the main_loop will return immediately, and call bdrv_close_all.

2012/5/16 Pavel Dovgaluk <[email protected]>

Quoted 28 lines

Prevent disk data loss when closing qemu window.

---
 vl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +1 -1
index 23ab3a3..b6cfd29 100644
@@ -3650,10 +3650,10 @@ int main(int argc, char **argv, char **envp)
    }
 
    os_setup_post();
+    atexit(bdrv_close_all);
 
    resume_all_vcpus();
    main_loop();
-    bdrv_close_all();
    pause_all_vcpus();
    net_cleanup();
    res_free();
Signature · 4 lines
linuxer and emacser and pythoner living in beijing
blog: http://mathslinux.org
twitter: https://twitter.com/mathslinux
google+: https://plus.google.com/118129852578326338750
#2 lore raw

I use qemu under Windows and it has two windows when executes - console and SDL ones. When I close SDL window main loop function terminates correctly, and when I close console window to terminate qemu then the code after main loop is not executed.

Pavel Dovgaluk

From: dunrong huang [mailto:[email protected]]
Sent: Wednesday, May 16, 2012 12:17 PM
To: Pavel Dovgaluk
Cc: qemu-devel
Subject: Re: [Qemu-devel] [PATCH] Prevent disk data loss when closing qemu

What's the difference of these two method to call bdrv_close_all?

If you close qemu window, the main_loop will return immediately, and call bdrv_close_all. 2012/5/16 Pavel Dovgaluk <[email protected]>
Prevent disk data loss when closing qemu window.

---
 vl.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
vl.c +0 -0
index 23ab3a3..b6cfd29 100644
@@ -3650,10 +3650,10 @@ int main(int argc, char **argv, char **envp)

    }

    os_setup_post();
+    atexit(bdrv_close_all);

    resume_all_vcpus();
    main_loop();
-    bdrv_close_all();
    pause_all_vcpus();
    net_cleanup();
    res_free();

Signature · 4 lines
linuxer and emacser and pythoner living in beijing
blog: http://mathslinux.org
twitter: https://twitter.com/mathslinux
google+: https://plus.google.com/118129852578326338750
#3 lore raw

Am 16.05.2012 12:16, schrieb Pavel Dovgaluk:

Quoted 3 lines

I use qemu under Windows and it has two windows when executes - console and SDL ones. When I close SDL window main loop function terminates correctly, and when I close console window to terminate qemu then the code after main loop is not executed.

Is there no way to catch this case and use the regular shutdown mechanism there as well?

I'm not against your patch and it's probably 1.1 material, but there may be more shutdown logic that we're missing if you close the console window.

Kevin

#4 lore raw

Il 22/05/2012 10:51, Kevin Wolf ha scritto:

Quoted 10 lines

Am 16.05.2012 12:16, schrieb Pavel Dovgaluk:

Quoted 3 lines

I use qemu under Windows and it has two windows when executes - console and SDL ones. When I close SDL window main loop function terminates correctly, and when I close console window to terminate qemu then the code after main loop is not executed.

Is there no way to catch this case and use the regular shutdown mechanism there as well?

I'm not against your patch and it's probably 1.1 material, but there may be more shutdown logic that we're missing if you close the console window.

Looks like qemu_ctrl_handler (in os-win32.c) needs to do something like termsig_handler (in os-posix.c) instead of a plain exit.

Paolo

#5 lore raw
Quoted 7 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini Il 22/05/2012 10:51, Kevin Wolf ha scritto:

Quoted 5 lines

Am 16.05.2012 12:16, schrieb Pavel Dovgaluk:

Quoted 3 lines

I use qemu under Windows and it has two windows when executes - console and SDL ones. When I close SDL window main loop function terminates correctly, and when I close console window to terminate qemu then the code after main loop is not executed.

Quoted 8 lines
Quoted 5 lines

Is there no way to catch this case and use the regular shutdown mechanism there as well?

I'm not against your patch and it's probably 1.1 material, but there may be more shutdown logic that we're missing if you close the console window.

Looks like qemu_ctrl_handler (in os-win32.c) needs to do something like termsig_handler (in os-posix.c) instead of a plain exit.

I tried to call qemu_system_shutdown_request() instead of exit() there, but Windows kills qemu
before it finishes cleanup work.

Pavel Dovgaluk

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Il 23/05/2012 08:48, Pavel Dovgaluk ha scritto:

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

I'm not against your patch and it's probably 1.1 material, but there may be more shutdown logic that we're missing if you close the console window.

Looks like qemu_ctrl_handler (in os-win32.c) needs to do something like termsig_handler (in os-posix.c) instead of a plain exit.

I tried to call qemu_system_shutdown_request() instead of exit() there, but Windows kills qemu
before it finishes cleanup work.

Uff...
http://stackoverflow.com/questions/3640633/c-setconsolectrlhandler-routine-issue
says more or less what you have to do.

Paolo

#8 lore raw
Quoted 7 lines

From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo Bonzini Il 23/05/2012 08:48, Pavel Dovgaluk ha scritto:

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

I'm not against your patch and it's probably 1.1 material, but there may be more shutdown logic that we're missing if you close the console window.

Looks like qemu_ctrl_handler (in os-win32.c) needs to do something like termsig_handler (in os-posix.c) instead of a plain exit.

Quoted 7 lines
Quoted 1 line

I tried to call qemu_system_shutdown_request() instead of exit() there, but Windows kills

qemu

Quoted 1 line

before it finishes cleanup work.

Uff...
http://stackoverflow.com/questions/3640633/c-setconsolectrlhandler-routine-issue
says more or less what you have to do.

Thank you!
I have prepared another patch based on this information.

Pavel Dovgaluk