virsh list hangs because of qemu-system-i386 defunct so libvirtd has to be restarted
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libvirt (Ubuntu) |
Fix Released
|
Medium
|
Unassigned |
Bug Description
1) The release of Ubuntu you are using, via 'lsb_release -rd' or System -> About Ubuntu
choix:~$ lsb_release -rd
Description: Ubuntu 20.04 LTS
Release: 20.04
2) The version of the package you are using, via 'apt-cache policy pkgname'
choix:~$ dpkg-query -S /lib/systemd/
libvirt-
choix:~$ dpkg -l libvirt-
Desired=
| Status=
|/ Err?=(none)
||/ Name Version Architecture Description
+++-===
ii libvirt-
3) What you expected to happen
Have a manageable and usable libvirtd service after every boot of Ubuntu.
4) What happened instead
After the installation of libvirt in Ubuntu, and following the reboot of Ubuntu. Every virsh command or virt-install or virt-manager were hanged.
5) Diagnostic
It is necessary to restart libvirtd so the programs like virsh can interact again with the service.
Checking the process list, I found that qemu-system is defunct 'qemu-system-i386 defunct'.
If I restart libvirtd, then it becomes responsive but if I reboot the machine, then libvirtd hangs again.
I enabled the debug flag for libvirtd in /etc/libvirt/
log_level = 1
log_filters=
log_outputs=
And found that qemu was not finding the kvm device when invoked by libvirtd during the startup of the service.
qemu-system-x86_64: failed to initialize KVM: No such file or directory.
I could not replicate this on a laptop but happens every single time in my PC with a Ryzen 3700X, X570 chipset, an NVMe and 32 GB of RAM.
6) Resolution.
There is a race condition happening between qemu-kvm.service and libvirtd.service. Becase the debug flag of libvirtd pointed that qemu was not findinf the kvm device, and it is created by qemu-kvm.service.
Therefore the solution was to create a drop-in for the libvirtd.service to add an After key as follows:
```ini
$ sudo systemctl edit libvirtd
[Unit]
After=qemu-
```
This will make the `libvirtd` to wait for `qemu-kvm` to complete before starting.
Related branches
- Miriam España Acebal (community): Needs Information
- Canonical Server Reporter: Pending requested
- git-ubuntu import: Pending requested
-
Diff: 10088 lines (+9197/-44)36 files modifieddebian/changelog (+7963/-4)
debian/control (+6/-5)
debian/libvirt-clients.install (+1/-0)
debian/libvirt-clients.lintian-overrides (+1/-0)
debian/libvirt-daemon-system.dirs (+2/-0)
debian/libvirt-daemon-system.install (+1/-0)
debian/libvirt-daemon-system.libvirt-guests.default (+2/-2)
debian/libvirt-daemon-system.postinst (+136/-0)
debian/libvirt-daemon-system.postrm (+24/-1)
debian/libvirt-daemon.README.Debian (+82/-22)
debian/libvirt-daemon.apport (+22/-0)
debian/libvirt-daemon.dnsmasq (+2/-0)
debian/libvirt-daemon.install (+1/-0)
debian/libvirt-uri.sh (+27/-0)
debian/patches/series (+19/-0)
debian/patches/ubuntu-aa/0020-virt-aa-helper-ubuntu-storage-paths.patch (+37/-0)
debian/patches/ubuntu-aa/0029-appmor-libvirt-qemu-Add-9p-support.patch (+34/-0)
debian/patches/ubuntu-aa/0031-virt-aa-helper-Ask-for-no-deny-rule-for-readonly-dis.patch (+43/-0)
debian/patches/ubuntu-aa/0032-apparmor-libvirt-qemu-Allow-reading-charm-specific-c.patch (+34/-0)
debian/patches/ubuntu-aa/0033-UBUNTU-only-apparmor-for-kvm.powerpc-LP-1680384.patch (+41/-0)
debian/patches/ubuntu-aa/0034-apparmor-virt-aa-helper-access-for-snapped-nova.patch (+33/-0)
debian/patches/ubuntu-aa/lp-1815910-allow-vhost-hotplug.patch (+57/-0)
debian/patches/ubuntu/Allow-libvirt-group-to-access-the-socket.patch (+50/-0)
debian/patches/ubuntu/daemon-augeas-fix-expected.patch (+21/-0)
debian/patches/ubuntu/dnsmasq-as-priv-user (+300/-0)
debian/patches/ubuntu/lp-1861125-ubuntu-models.patch (+21/-0)
debian/patches/ubuntu/ovmf_paths.patch (+60/-0)
debian/patches/ubuntu/set-default-machine-to-ubuntu.patch (+45/-0)
debian/patches/ubuntu/swtpm-by-swtpm-user.patch (+40/-0)
debian/patches/ubuntu/ubuntu_machine_type.patch (+14/-0)
debian/patches/ubuntu/wait-for-qemu-kvm.patch (+23/-0)
debian/rules (+15/-2)
debian/tests/control (+3/-2)
debian/tests/smoke-lxc (+30/-4)
debian/tests/smoke-qemu-session (+5/-0)
debian/tests/smoke-qemu-session.xml (+2/-2)
- Rafael David Tinoco (community): Approve
- Canonical Server: Pending requested
- Christian Ehrhardt : Pending requested
-
Diff: 10108 lines (+9168/-74)46 files modifieddebian/changelog (+7070/-25)
debian/control (+16/-16)
debian/libvirt-clients.install (+1/-0)
debian/libvirt-clients.lintian-overrides (+1/-0)
debian/libvirt-daemon-system.dirs (+2/-0)
debian/libvirt-daemon-system.install (+1/-1)
debian/libvirt-daemon-system.postinst (+128/-0)
debian/libvirt-daemon-system.postrm (+26/-1)
debian/libvirt-daemon.README.Debian (+82/-22)
debian/libvirt-daemon.apport (+22/-0)
debian/libvirt-daemon.dnsmasq (+2/-0)
debian/libvirt-daemon.install (+1/-0)
debian/libvirt-uri.sh (+27/-0)
debian/patches/series (+30/-0)
debian/patches/ubuntu-aa/0003-apparmor-libvirt-qemu-Allow-read-access-to-overcommi.patch (+30/-0)
debian/patches/ubuntu-aa/0007-apparmor-libvirt-qemu-Allow-owner-read-access-to-PRO.patch (+28/-0)
debian/patches/ubuntu-aa/0020-virt-aa-helper-ubuntu-storage-paths.patch (+37/-0)
debian/patches/ubuntu-aa/0029-appmor-libvirt-qemu-Add-9p-support.patch (+34/-0)
debian/patches/ubuntu-aa/0030-virt-aa-helper-Complete-9p-support.patch (+36/-0)
debian/patches/ubuntu-aa/0031-virt-aa-helper-Ask-for-no-deny-rule-for-readonly-dis.patch (+43/-0)
debian/patches/ubuntu-aa/0032-apparmor-libvirt-qemu-Allow-reading-charm-specific-c.patch (+34/-0)
debian/patches/ubuntu-aa/0033-UBUNTU-only-apparmor-for-kvm.powerpc-LP-1680384.patch (+41/-0)
debian/patches/ubuntu-aa/0034-apparmor-virt-aa-helper-access-for-snapped-nova.patch (+33/-0)
debian/patches/ubuntu-aa/0050-local-include-for-libvirt-qemu.patch (+19/-0)
debian/patches/ubuntu-aa/apparmor-allow-unmounting-.dev-entries.patch (+41/-0)
debian/patches/ubuntu-aa/apparmor-profiles-are-meant-to-allow-adding-permanen.patch (+65/-0)
debian/patches/ubuntu-aa/lp-1815910-allow-vhost-hotplug.patch (+57/-0)
debian/patches/ubuntu-aa/lp-1847361-load-versioned-module.patch (+44/-0)
debian/patches/ubuntu/Allow-libvirt-group-to-access-the-socket.patch (+49/-0)
debian/patches/ubuntu/daemon-augeas-fix-expected.patch (+20/-0)
debian/patches/ubuntu/dnsmasq-as-priv-user (+290/-0)
debian/patches/ubuntu/lp-1861125-ubuntu-models.patch (+21/-0)
debian/patches/ubuntu/ovmf_paths.patch (+60/-0)
debian/patches/ubuntu/parallel-shutdown.patch (+25/-0)
debian/patches/ubuntu/set-default-machine-to-ubuntu.patch (+45/-0)
debian/patches/ubuntu/tools-fix-libvirt-guests.sh-text-assignments.patch (+405/-0)
debian/patches/ubuntu/ubuntu_machine_type.patch (+14/-0)
debian/patches/ubuntu/wait-for-qemu-kvm.patch (+23/-0)
debian/patches/virdevmapper-Don-t-cache-device-mapper-major.patch (+88/-0)
debian/patches/virdevmapper-Handle-kernel-without-device-mapper-support.patch (+76/-0)
debian/patches/virdevmapper-Ignore-all-errors-when-opening-dev-mapper-co.patch (+76/-0)
debian/rules (+14/-4)
debian/tests/control (+2/-1)
debian/tests/smoke-lxc (+2/-2)
debian/tests/smoke-qemu-session (+5/-0)
debian/tests/smoke-qemu-session.xml (+2/-2)
CVE References
Changed in libvirt (Ubuntu): | |
status: | Triaged → In Progress |
Sounds reasonable, thanks for the detailed pre-work.
I'll take a look at putting this into Ubuntu once I'm back from PTO.
I was recently helping someone on askubuntu that faced the same or at least similar - are you by any chance - that someone?