From: Jan K. <jan...@we...> - 2008-01-19 15:52:07
|
Guido Guenther wrote: > On Tue, Jan 08, 2008 at 01:34:30PM +0900, Jun Koi wrote: >> Sorry for my ignorance, but .... what is the effect of this patch? So >> I can shutdown guest VM cleanly, or smt else?? > system_powerdown in the commmand monitor now simulates the pressing of > the acpi power button. This allows you to shutdown the system cleanly. > This is nice for things like libvirt where you can now do a=20 >=20 > virsh shutdown <vm> >=20 > and the machine doesn't simply get killed. You need this patch for > libvirt: What about additionally listening on signals? If you run qemu from the console, you can then just press ctrl-c to shut the guest down (instead of killing it that way). The same happens on host shutdown (if the guest is faster than the host's grace period before SIGKILL...). Jan --- qemu/sysemu.h | 2 +- qemu/vl.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) Index: kvm-userspace/qemu/vl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kvm-userspace.orig/qemu/vl.c +++ kvm-userspace/qemu/vl.c @@ -8501,6 +8501,11 @@ void qemu_get_launch_info(int *argc, cha *opt_incoming =3D incoming; } =20 +void qemu_powerdown_sighand(int signal) +{ + qemu_system_powerdown_request(); +} + int main(int argc, char **argv) { #ifdef CONFIG_GDBSTUB @@ -9475,6 +9480,9 @@ int main(int argc, char **argv) } } =20 + signal(SIGINT, qemu_powerdown_sighand); + signal(SIGTERM, qemu_powerdown_sighand); + machine->init(ram_size, vga_ram_size, boot_devices, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_= model); =20 Index: kvm-userspace/qemu/sysemu.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- kvm-userspace.orig/qemu/sysemu.h +++ kvm-userspace/qemu/sysemu.h @@ -35,7 +35,7 @@ int qemu_reset_requested(void); int qemu_powerdown_requested(void); #if !defined(TARGET_SPARC) && !defined(TARGET_I386) // Please implement a power failure function to signal the OS -#define qemu_system_powerdown() do{}while(0) +#define qemu_system_powerdown() exit(0) #else void qemu_system_powerdown(void); #endif |