I am running Ubuntu 18.04 (desktop) in a VM using Debian 9 and KVM as the hypervisor but running virsh shutdown BS-MS01 I get a message saying the domain is shutting down but the VM is actually still sat on the login screen.

I have confirmed acpid is installed and running on the guest:

ms01admin@BS-MS01:~$ sudo service acpid status
● acpid.service - ACPI event daemon
   Loaded: loaded (/lib/systemd/system/acpid.service; disabled; vendor preset: e
   Active: active (running) since Sat 2019-02-16 20:33:52 GMT; 2h 17min ago
 Main PID: 716 (acpid)
    Tasks: 1 (limit: 4614)
   CGroup: /system.slice/acpid.service
           └─716 /usr/sbin/acpid

The VM has been created with </acpi> in the xml too:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <description>Main media server.</description>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>8</vcpu>
    <type arch='x86_64' machine='pc-q35-2.8'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <boot dev='hd'/>
    <bootmenu enable='no'/>
    <vmport state='off'/>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>Haswell-noTSX</model>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/storage/vm/hdd/bsms01.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    <controller type='usb' index='0' model='nec-xhci'>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    <controller type='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='ioh3420'/>
      <target chassis='1' port='0x8'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
    <controller type='pci' index='2' model='dmi-to-pci-bridge'>
      <model name='i82801b11-bridge'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
    <controller type='pci' index='3' model='pci-bridge'>
      <model name='pci-bridge'/>
      <target chassisNr='3'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='ioh3420'/>
      <target chassis='4' port='0x9'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    <controller type='pci' index='5' model='pcie-root-port'>
      <model name='ioh3420'/>
      <target chassis='5' port='0xa'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    <controller type='pci' index='6' model='pcie-root-port'>
      <model name='ioh3420'/>
      <target chassis='6' port='0xb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
    <controller type='pci' index='7' model='pcie-root-port'>
      <model name='ioh3420'/>
      <target chassis='7' port='0xc'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
    <controller type='pci' index='8' model='pcie-root-port'>
      <model name='ioh3420'/>
      <target chassis='8' port='0xd'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
    <controller type='pci' index='9' model='pcie-root-port'>
      <model name='ioh3420'/>
      <target chassis='9' port='0xe'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
    <interface type='bridge'>
      <mac address='52:54:00:40:b9:20'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x01' function='0x0'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    <hostdev mode='subsystem' type='pci' managed='yes'>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='1'/>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='2'/>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
    <qemu:arg value='-cpu'/>
    <qemu:arg value='host,hv_time,kvm=off,hv_vendor_id=null'/>

I've even added acpi=force to grub but have not had any luck getting it to work and I've run out of ideas.

Anyone got any ideas?

  • Also just to clarify I have other guests (Windows and Linux) that are shutting down correctly, so I think you might be right about the HW configuration. – Steve Brown Feb 17 at 1:28
  • Looks like you passed through a couple of PCI devices, at least one of which is a video card? That might have something to do with it. I just installed a fresh Ubuntu 18.04 Desktop VM in virt-manager, and it shuts down properly from virsh shutdown or virt-manager. You might try re-creating the VM. – Michael Hampton Feb 17 at 2:07
  • That's correct, it's the GFX card and it's counterpart sound device. This was happening before I passed these through though :( I've found the solution though which I posted below for future reference :) – Steve Brown Feb 17 at 2:42

Seems like an event for the power button wasn't created automatically, not sure why?

Created a new event handler here:
sudo nano /etc/acpi/events/powerbtn

With these parameters:


Then restarted the service:
sudo service acpid restart

Now I'm able to shutdown the guest!

  • That's a nice workaround. Though by default you can still shutdown the guest even if acpid isn't running - or even not installed! So something else is still wrong. – Michael Hampton Feb 17 at 2:45
  • Something is definitely odd, it's been doing it since day 1 of it being installed and I'm not sure why, I have a tonne of other VM's and all of them worked without any faffing. It was actually while poking around in the acpi directory of another guest I noticed there was a button/power event handler so I just recreated it...oh well everything's working for now. Hopefully no other issues rear their ugly head. :P – Steve Brown Feb 17 at 2:51
  • Old pre-systemd distros needed acpid in order to shutdown properly (and respond to other events). I'm not exactly sure why it's even shipped anymore, but oh well. – Michael Hampton Feb 17 at 2:54

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.