Skip to contentSkip to conversation

Screen dump on shutdown?

Qemu-devel New Steve Fosdick 1 participant 2 messages Feb 17, 2009

lore
Share & tools
lore
#0 lore raw

How hard would it be to implement a feature where a screendump is taken to a predetermined file immediately before the virtual machine is powered off or rebooted?

The application I have in mind for this is when the guest fails to boot correctly. It would be useful if there was a screendump at the point the guest attempts an automatic reboot in order to gather at least some information about what went wrong.

Regards,
Steve.

#1 lore raw

PATCH 1/1 Screen dump on shutdown

After my earlier message about a screen dump taken at shutdown or reboot this turned out to be very simple to implement so I attach a patch which does that.

Regards,
Steve.

vl.c +11 -0
Index: vl.c
===================================================================
@@ -234,6 +234,7 @@
 int fd_bootchk = 1;
 int no_reboot = 0;
 int no_shutdown = 0;
+const char *sdump_file = NULL;
 int cursor_hide = 1;
 int graphic_rotate = 0;
 int daemonize = 0;
@@ -3578,6 +3579,8 @@
 
 void qemu_system_reset_request(void)
 {
+    if (sdump_file)
+        vga_hw_screen_dump(sdump_file);
     if (no_reboot) {
         shutdown_requested = 1;
     } else {
@@ -3589,6 +3592,8 @@
 
 void qemu_system_shutdown_request(void)
 {
+    if (sdump_file)
+        vga_hw_screen_dump(sdump_file);
     shutdown_requested = 1;
     if (cpu_single_env)
         cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT);
@@ -4045,6 +4050,7 @@
 #endif
            "-no-reboot      exit instead of rebooting\n"
            "-no-shutdown    stop before shutdown\n"
+           "-sdump file     screendump to file on shutdown or reset\n"
            "-loadvm [tag|id]\n"
            "                start right away with a saved state (loadvm in monitor)\n"
 #ifndef _WIN32
@@ -4174,6 +4180,7 @@
     QEMU_OPTION_enable_kvm,
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_no_shutdown,
+    QEMU_OPTION_sdump,
     QEMU_OPTION_loadvm,
     QEMU_OPTION_daemonize,
     QEMU_OPTION_option_rom,
@@ -4297,6 +4304,7 @@
 #endif
     { "no-reboot", 0, QEMU_OPTION_no_reboot },
     { "no-shutdown", 0, QEMU_OPTION_no_shutdown },
+    { "sdump", HAS_ARG, QEMU_OPTION_sdump },
     { "loadvm", HAS_ARG, QEMU_OPTION_loadvm },
     { "daemonize", 0, QEMU_OPTION_daemonize },
     { "option-rom", HAS_ARG, QEMU_OPTION_option_rom },
@@ -5179,6 +5187,9 @@
             case QEMU_OPTION_no_shutdown:
                 no_shutdown = 1;
                 break;
+            case QEMU_OPTION_sdump:
+                sdump_file = optarg;
+                break;
             case QEMU_OPTION_show_cursor:
                 cursor_hide = 0;
                 break;
qemu-doc.texi +4 -0
Index: qemu-doc.texi
===================================================================
@@ -1107,6 +1107,10 @@
 This allows for instance switching to monitor to commit changes to the
 disk image.
 
+@item -sdump @var{file}
+Write a screen dump to the specified file immediately before a
+shutdown or reboot.
+
 @item -loadvm @var{file}
 Start right away with a saved state (@code{loadvm} in monitor)