15

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 ?

  • As for “clean”, I think that if it's a fresh install that doesn't have much running on it yet, as long as you wait like 20 minutes the filesystem should have all its changes synced and wouldn't experience any particularly nasty problems from a hard-shutdown – JamesTheAwesomeDude Apr 8 at 12:20
6

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.

| improve this answer | |
  • note that if you've started qemu with -monitor stdio, you can just type system_powerdown right at the (qemu) prompt – JamesTheAwesomeDude Apr 8 at 11:51
6

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
| improve this answer | |
5

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.

| improve this answer | |
0

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

| improve this answer | |
  • Are there no options to send non-ACPI shutdown events to the guest OS? – cnst Dec 8 '12 at 6:44
  • 1
    define "non acpi shutdown event" – dyasny Dec 8 '12 at 7:16
  • 1
    Ctrl-Alt-Del, APM etc. – cnst Dec 8 '12 at 7:59
  • 2
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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