** Description changed:

  [ Impact ]
  
   * The qemu-guest-agent daemon is not started in the VMs after 
qemu-guest-agent
     package installation.
   * QEMU guest agent services are not available until reboot.
  
  [ Test Plan ]
  
  On Ubuntu host:
  
  $ wget 
https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img
+ $ sudo apt install guestfs-tools
  $ sudo virt-customize -a ubuntu-24.04-server-cloudimg-amd64.img 
--root-password password:root
  $ qemu-system-x86_64 -enable-kvm -cpu host -m 2048 -nographic -netdev 
user,id=net0,hostfwd=tcp::2222-:22 -device virtio-net-pci,netdev=ne\
  t0 -drive if=virtio,file=ubuntu-24.04-server-cloudimg-amd64.img,format=qcow2  
-device virtio-serial -chardev socket,path=/tmp/qga.sock,server=\
  on,wait=off,id=qga0 -device 
virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
  
  In the VM:
  
  $ sudo apt install qemu-guest-agent
  
  $ systemctl status qemu-guest-agent
  ○ qemu-guest-agent.service - QEMU Guest Agent
       Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; static)
       Active: inactive (dead)
  
  We can see that the guest agent service is not started
  
  [ Where problems could occur ]
  
  This SRU starts the guest agent daemon at installation, currently this
  service is already started at next VM boot so I do not expect this SRU
  to introduce regressions.
  
  [ Other Info ]
  
  -- Original bug report --
  
  I noticed that qemu-guest-agent does not start automatically in VMs
  using image ubuntu-24.04-server-cloudimg-amd64.img (see exact versions
  at the end) in a libvirt/qemu/kvm VM. I would expect it to start
  automatically after each boot.
  
  This is what I first noticed from the Debian hypervisor host:
  
  [edit: simplified this command]
  $ virsh domifaddr --source agent test0
  error: Failed to query for interfaces addresses
  error: Guest agent is not responding: QEMU guest agent is not connected
  
  Then inside the Ubuntu VM I found qemu-guest-agent not running:
  
  $ ssh test0
  $ sudo -s
  # systemctl status qemu-guest-agent
  ○ qemu-guest-agent.service - QEMU Guest Agent
       Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; static)
       Active: inactive (dead)
  # ps aux | egrep qemu-ga | grep -v grep
  [nothing]
  
  I could start it manually:
  
  # systemctl start qemu-guest-agent
  # ps aux | egrep qemu-ga | grep -v grep
  root       12841  0.0  0.1  80712  4096 ?        Ssl  09:32   0:00 
/usr/sbin/qemu-ga
  
  However I guess it was not autostarted because the systemd service could
  not be enabled:
  
  # systemctl enable qemu-guest-agent
  Synchronizing state of qemu-guest-agent.service with SysV service script with 
/usr/lib/systemd/systemd-sysv-install.
  Executing: /usr/lib/systemd/systemd-sysv-install enable qemu-guest-agent
  The unit files have no installation config (WantedBy=, RequiredBy=, UpheldBy=,
  Also=, or Alias= settings in the [Install] section, and DefaultInstance= for
  template units). This means they are not meant to be enabled or disabled 
using systemctl.
  ·
  Possible reasons for having these kinds of units are:
  • A unit may be statically enabled by being symlinked from another unit's
    .wants/, .requires/, or .upholds/ directory.
  • A unit's purpose may be to act as a helper for some other unit which has
    a requirement dependency on it.
  • A unit may be started when needed via activation (socket, path, timer,
    D-Bus, udev, scripted systemctl call, ...).
  • In case of template units, the unit is meant to be enabled with some
    instance name specified.
  
  If I added a WantedBy, then I could enable it and it got autostarted
  after a reboot:
  
  # vim /usr/lib/systemd/system/qemu-guest-agent.service
  ...
  [Install]
  WantedBy=multi-user.target
  
  # systemctl enable qemu-guest-agent
  Synchronizing state of qemu-guest-agent.service with SysV service script with 
/usr/lib/systemd/systemd-sysv-install.
  Executing: /usr/lib/systemd/systemd-sysv-install enable qemu-guest-agent
  Created symlink 
/etc/systemd/system/multi-user.target.wants/qemu-guest-agent.service → 
/usr/lib/systemd/system/qemu-guest-agent.service.
  # systemctl reboot
  [wait, ssh again, become root]
  # systemctl status qemu-guest-agent
  ● qemu-guest-agent.service - QEMU Guest Agent
       Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; 
enabled; preset: enabled)
       Active: active (running) since Wed 2025-03-12 09:36:43 UTC; 3min 13s ago
     Main PID: 878 (qemu-ga)
        Tasks: 2 (limit: 4654)
       Memory: 1.3M (peak: 1.6M)
          CPU: 10ms
       CGroup: /system.slice/qemu-guest-agent.service
               └─878 /usr/sbin/qemu-ga
  
  márc 12 09:36:43 test0 systemd[1]: Started qemu-guest-agent.service -
  QEMU Guest Agent.
  
  I reproduced this with the newest ubuntu 24.04 cloud image release:
  
  # cat /etc/lsb-release
  DISTRIB_ID=Ubuntu
  DISTRIB_RELEASE=24.04
  DISTRIB_CODENAME=noble
  DISTRIB_DESCRIPTION="Ubuntu 24.04.2 LTS"
  
  Which I downloaded from:
  
  https://cloud-
  images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-
  amd64.img
  
  At download time this pointed to:
  
  https://cloud-images.ubuntu.com/releases/noble/release-20250228/
  
  The qemu-guest-agent package was autoinstalled from could-init user-
  data, its version was:
  
  # dpkg -l qemu-guest-agent
  Desired=Unknown/Install/Remove/Purge/Hold
  | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
  |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
  ||/ Name             Version               Architecture Description
  
+++-================-=====================-============-=================================
  ii  qemu-guest-agent 1:8.2.2+ds-0ubuntu1.6 amd64        Guest-side 
qemu-system agent

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2102093

Title:
  qemu-guest-agent does not start automatically

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/2102093/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to