Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

A.15. Guest Virtual Machine Fails to Shutdown

Traditionally, executing a virsh shutdown command causes a power button ACPI event to be sent, thus copying the same action as when someone presses a power button on a physical machine. Within every physical machine, it is up to the OS to handle this event. In the past operating systems would just silently shutdown. Today, the most usual action is to show a dialog asking what should be done. Some operating systems even ignore this event completely, especially when no users are logged in. When such operating systems are installed on a guest virtual machine, running virsh shutdown just does not work (it is either ignored or a dialog is shown on a virtual display). However, if a qemu-guest-agent channel is added to a guest virtual machine and this agent is running inside the guest virtual machine's OS, the virsh shutdown command will ask the agent to shut down the guest OS instead of sending the ACPI event. The agent will call for a shutdown from inside the guest virtual machine OS and everything works as expected.

Procedure A.7. Configuring the guest agent channel in a guest virtual machine

  1. Stop the guest virtual machine.
  2. Open the Domain XML for the guest virtual machine and add the following snippet:
    <channel type='unix'>
        <source mode='bind'/>
        <target type='virtio' name='org.qemu.guest_agent.0'/>

    Figure A.2. Configuring the guest agent channel

  3. Start the guest virtual machine, by running virsh start [domain].
  4. Install qemu-guest-agent on the guest virtual machine (yum install qemu-guest-agent) and make it run automatically at every boot as a service (qemu-guest-agent.service).