Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using virtualisation solely to install OpenBSD onto the bare hardware, and during the installation, the redirection to the serial port didn't get configured, so, I ended up with the system running, but no way to login and do a clean shutdown.

kvm -m 6144 -smp 4 -drive file=/dev/sda,if=ide \
    -drive file=/dev/sdb,if=scsi -drive file=/dev/sdc,if=scsi \
    -cdrom install52.iso -boot d -nographic

How can I send a shutdown event to this session? AFAIK, Ctrl-a x as shown here or a pkill kvm would not do a clean shutdown yet.

Alternatively, how can I switch from the -nographic mode into the -curses mode ?

share|improve this question

libvirt knows how to handle this. If you don't mind installing libvirtd and virsh, then you can use:

virsh list

to show the name(s) of the guest(s). And, to shutdown gracefully the guest with name guest_001, use the command:

virsh shutdown guest_001
share|improve this answer

In principle: Sending "system_powerdown" to the QEMU monitor (see other answers) will signal the guest OS to power off (like if you pushed the power button). You will need to set powerdown=YES in /etc/rc.shutdown to really shut down the machine completely.

Unfortunately in my actual setup here, while this works quite well for real hardware machines, the VM's freeze on receiving a powerdown event. (This is with QEMU-KVM 1.1.2 on Debian Wheezy/amd64 and OpenBSD 5.5 amd64 GENERIC.SP) So what you may do instead is sending a shutdown -h now or halt -p to the (OpenBSD) console.

share|improve this answer

Perhaps Ctrl-a c and system_powerdown ?

Supposed to work, although it didn't seem to work in my case; perhaps OpenBSD and QEMU ACPI don't interact well enough.

share|improve this answer

qemu sends an acpi shutdown event to the VM, if it cannot interpret this call, it will not shutdown. In Linux this means you need acpid running, as for BSD, I suppose something similar must exist

share|improve this answer
Are there no options to send non-ACPI shutdown events to the guest OS? – cnst Dec 8 '12 at 6:44
define "non acpi shutdown event" – dyasny Dec 8 '12 at 7:16
Ctrl-Alt-Del, APM etc. – cnst Dec 8 '12 at 7:59
none of these is a shutdown. system stop with no poweroff and a reboot are not shutdown. Maybe Alt+SysRQ+o will work (it's APM, so I doubt the VM with terminate after stopping everything, but...) the key combination can be sent via the qemu-monitor sendkey routine – dyasny Dec 8 '12 at 8:26
How do I send any of these in a snap? I don't care what the VM does; it only matters that the guest gets one of these, and does a sync with proper umount and stuff. – cnst Dec 10 '12 at 20:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.