VMmanager Knowledge Base

How to check and restore QEMU Guest Agent?

QEMU Guest Agent is a daemon program that is installed on a VM. QEMU Guest Agent provides execution of commands on VMs and information exchange between VMs and the cluster node.

VMmanager uses QEMU Guest Agent to change network settings without rebooting. If the QEMU Guest Agent is unavailable for the platform for five minutes, VMmanager will reboot the VM to apply the settings.

To manage VM with CentOS OS, guest-exec function should be enabled in QEMU Guest Agent.

To avoid an unplanned reboot of the VM, you can check the status of the QEMU Guest Agent before changing the settings. This can be done on a VM or the cluster node.

Diagnostics on the VM

  1. Connect to the VM via SSH.
  2. Define the status of the QEMU Guest Agent:

    systemctl status qemu-guest-agent

     Examples of responses:

    QEMU Guest Agent is running
    ● qemu-guest-agent.service - QEMU Guest Agent
       Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; enabled; vendor preset: enabled)
       Active: active (running) since Вт 2021-08-10 05:25:54 UTC; 1 weeks 3 days ago
    QEMU Guest Agent is stopped
    ● qemu-guest-agent.service - QEMU Guest Agent
       Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; enabled; vendor preset: enabled)
       Active: inactive (dead) since Пт 2021-08-20 06:27:16 UTC; 2s ag
    QEMU Guest Agent is not installed
    Unit qemu-guest-agent.service could not be found.

Diagnostics on the cluster node

  1. Connect to the cluster node via SSH.
  2. Define the status of the QEMU Guest Agent:

    virsh qemu-agent-command <vm_id>_<vm_name> '{"execute": "guest-info", "arguments": {}}'
    Comments to the command

    If QEMU Guest Agent is running, you will get a response as shown below:

    Fragment of response in JSON
    {"return":{"version":"2.12.0","supported_commands":[{"enabled":true,"name":"guest-get-osinfo","success-response":true}

     If QEMU Guest Agent is not running or is stopped, you will get a response as shown below:

    error: Guest agent is not responding: QEMU guest agent is not connected
  3. For VMs with CentOS OS, define the status of the guest-exec function: 

    virsh qemu-agent-command <vm_id>_<vm_name> '{"execute":"guest-info"}' --pretty | grep -B1 "guest-exec"
    Comments to the command
    Fragment of the response, if the function is enabled
    "enabled": true,
    "name": "guest-exec",
    Fragment of the response, if the function is disabled
    "enabled": false,
    "name": "guest-exec",

Diagnostics on the platform

To find the problem with QEMU Guest Agent, you can:

  • when creating a VM and reinstalling the OS, monitor the log of VM operations: 
    docker exec vm_box tail -f /var/log/host.log
  • when attempting to install or restore QEMU Guest Agent on a VM, monitor the log of QEMU Guest Agent operations: 
    docker exec vm_box tail -f /var/log/host_guest_agent.log

Restoring work

If QEMU Guest Agent is not installed

  1. Connect to the VM via SSH.
  2. Install QEMU Guest Agent:

    CentOS
    yum install qemu-guest-agent
    Debian, Ubuntu
    apt install qemu-guest-agent
  3. Add QEMU Guest Agent to the autostart:

    systemctl enable --now qemu-guest-agent
  4. Check the status of QEMU Guest Agent:

    systemctl status qemu-guest-agent
  5. Check the status of the SELinux service:

    sestatus

    If the status is different from disable:

    1. Disable SELinux. Replace the below line in the /etc/selinux/config file

      SELINUX=enforcing

      with

      SELINUX=disabled
    2. Reboot the VM.
  6. The file /etc/sysconfig/qemu-ga contains a line the below format

    BLACKLIST_RPC=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush,guest-exec,guest-exec-status


    1. Mark this line as comment or delete it.
    2. Restart QEMU Guest Agent:

      systemctl restart qemu-guest-agent

If QEMU Guest Agent is stopped

  1. Connect to the VM via SSH.
  2. Start QEMU Guest Agent:

    systemctl start qemu-guest-agent

If guest-exec function is disabled

  1. Connect to the VM via SSH.
  2. Run the command: 

    sed -i '/BLACKLIST_RPC=/cBLACKLIST_RPC=' /etc/sysconfig/qemu-ga
  3. Restart QEMU Guest Agent:

    systemctl restart qemu-guest-agent

Running QEMU Guest Agent on Windows

Installation

  1. To prepare the VM for Virtio driver installation, create a 1 GB disk with Virtio connection type and connect it to the VM: Virtual machines section → select VM → Parameters button → Virtual diskConnect one more diskCreate and connect a disk → select Size 1 GB and virtio Connection typeConnect the disk button.
  2. Download and install the Virtio drivers
  3. Download and install QEMU Guest Agent.

Diagnostics

Run the services.msc service manager and check that QEMU Guest Agent is in the list of running services. If the service is stopped, start it. If the service is not listed, install the QEMU Guest Agent software.

Example of QEMU Guest Agent status display in the manager