KVM guest halt to make the host kvm exit

haltkvm-virtualization

I'm running Linux inside kvm. When I issue the halt command as root in the guest, eventually the guest halts with the kernel log message System halted.. However, the kvm host process keeps running. Is it possible to make it exit upon halt?

This looks like a relevant discussion: http://comments.gmane.org/gmane.comp.emulators.kvm.devel/107972

A related discussion, but it's about halting the guest from the host, but not from within: http://ubuntuforums.org/showthread.php?t=1066940

A similar bugreport, with no meaningful response: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/967049

My kernel didn't have ACPI compiled in, so I've added support, but it still won't halt. This is what I get at boot time:

[    0.311211] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
[    0.312637] virtio-pci 0000:00:03.0: PCI INT A -> Link[LNKC] -> GSI 11 (level, high) -> IRQ 11
[    0.315049] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 10
[    0.316472] virtio-pci 0000:00:04.0: PCI INT A -> Link[LNKD] -> GSI 10 (level, high) -> IRQ 10
[    0.318858] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10
[    0.320254] virtio-pci 0000:00:05.0: PCI INT A -> Link[LNKA] -> GSI 10 (level, high) -> IRQ 10

ACPI kernel config:

CONFIG_ACPI=y
# CONFIG_ACPI_PROCFS is not set
# CONFIG_ACPI_PROCFS_POWER is not set
# CONFIG_ACPI_EC_DEBUGFS is not set
# CONFIG_ACPI_PROC_EVENT is not set
# CONFIG_ACPI_AC is not set
# CONFIG_ACPI_BATTERY is not set
CONFIG_ACPI_BUTTON=y
# CONFIG_ACPI_FAN is not set
# CONFIG_ACPI_DOCK is not set
# CONFIG_ACPI_PROCESSOR is not set
CONFIG_ACPI_CUSTOM_DSDT_FILE=""
# CONFIG_ACPI_CUSTOM_DSDT is not set
CONFIG_ACPI_BLACKLIST_YEAR=0
# CONFIG_ACPI_DEBUG is not set
# CONFIG_ACPI_PCI_SLOT is not set
# CONFIG_ACPI_CONTAINER is not set
# CONFIG_ACPI_SBS is not set
# CONFIG_ACPI_HED is not set
# CONFIG_ACPI_CUSTOM_METHOD is not set
# CONFIG_ACPI_APEI is not set
CONFIG_PNPACPI=y
# CONFIG_THINKPAD_ACPI is not set
# CONFIG_ACPI_WMI is not set
# CONFIG_ACPI_ASUS is not set
# CONFIG_ACPI_CMPC is not set

Update: poweroff works with an ACPI-enabled kernel (e.g. with the kernel config above). halt still doesn't work.

Best Answer

Try running halt -p

-p tells the host to power off after the shutdown.

Specifically, the man page for halt states:

-p, --poweroff
       Instructs the halt command to instead behave as poweroff.
Related Topic