during shutdown libvirt-guests.sh shouldn't run if libvirtd isn't running

Bug #1854653 reported by Doug Smythies
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libvirt (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

The libvirtd service being started during boot doesn't mean it is still running during shutdown.
libvirt-guests.sh waits around for 10 seconds trying to communicate with it, re-trying once per second.
The desire is that it either doesn't run at all or it checks if libvirtd is even running before wasting the 10 seconds.

As a use case example:
I often disable extraneous services so as to get my test server to be very "idle", much more idle than a typical user, particularly with a desktop type GUI, can achieve. I can easily re-boot 50 times in a day, and get hit by this 10 seconds every time.

Example:

Dec 01 13:52:13 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 10
Dec 01 13:52:14 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 9
Dec 01 13:52:15 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 8
Dec 01 13:52:16 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 7
Dec 01 13:52:17 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 6
Dec 01 13:52:18 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 5
Dec 01 13:52:19 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 4
Dec 01 13:52:20 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 3
Dec 01 13:52:21 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 2
Dec 01 13:52:22 goom-i5 libvirt-guests.sh[3717]: Unable to connect to libvirt currently. Retrying .. 1Can't connect to default. Skipping.

This occurs on my old 16.04 test server and a newly created 20.04 test server.

Revision history for this message
Doug Smythies (dsmythies) wrote :

For example, this seems to work well:

doug@goom-i5:~/config/usr/lib/libvirt$ diff libvirt-guests.sh.original libvirt-guests.sh
114,124c114,126
< i=${CONNECT_RETRIES}
< while [ $i -gt 0 ]; do
< run_virsh "$uri" connect 2>/dev/null
< if [ $? -eq 0 ]; then
< return 0;
< fi
< sleep ${RETRIES_SLEEP}
< eval_gettext "Unable to connect to libvirt currently. Retrying .. \$i"
< i=$(($i-1))
< done
< eval_gettext "Can't connect to \$uri. Skipping."
---
> if `pidof libvirtd 1>/dev/null`; then
> i=${CONNECT_RETRIES}
> while [ $i -gt 0 ]; do
> run_virsh "$uri" connect 2>/dev/null
> if [ $? -eq 0 ]; then
> return 0;
> fi
> sleep ${RETRIES_SLEEP}
> eval_gettext "Unable to connect to libvirt currently. Retrying .. \$i"
> i=$(($i-1))
> done
> eval_gettext "Can't connect to \$uri. Skipping."
> fi

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Hi Doug,
thanks for the report - and yes I agree it shouldn't waste time on that, but it isn't that easy IMHO.

Users can configure in /etc/default/libvirt-guests for any URI including remote ones.
Therefore there can be no local check to the service that will make a clear decision if we can skip trying to connect.

But I'd expect that 99,9..% of the users have still "defult" in the URI and then we could do the suggested.

I've submitted a patch for this [1], lets see what others think.

[1]: https://www.redhat.com/archives/libvir-list/2019-December/msg00079.html

Changed in libvirt (Ubuntu):
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

New revision of the fix was accepted upstream.
This will be merged with the libvirt that gets into 20.04

tags: added: libvirt-20.04
Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (13.2 KiB)

This bug was fixed in the package libvirt - 6.0.0-0ubuntu1

---------------
libvirt (6.0.0-0ubuntu1) focal; urgency=medium

  * Merged with Debian 5.6.0-4 from experimental and v6.0.0 from upstream
    Among many other new features and fixes this includes fixes for:
    - LP: #1859253 - rbd driver fails to create a new volume
    - LP: #1858341 - rbd driver does not list all volumes in pool
    - LP: #1845506 - Libvirt snapshot doesn't update apparmor profile
    - LP: #1854653 - slow libvirt-guests.sh during shutdown if service is off
    - LP: #1848229 - enable ppc64el to use ccf-assist feature
    - LP: #1853315 - Enable CPU Model Comparison and Baselining on s390x
    - LP: #1853317 - CCW IPL support to boot from ECKD DASDs
    - LP: #1859506 - security: AppArmor profile fixes for swtpm
    Remaining changes:
    - Disable libssh2 support (universe dependency)
    - Disable firewalld support (universe dependency)
    - Set qemu-group to kvm (for compat with older ubuntu)
    - Additional apport package-hook
    - Autostart default bridged network (As upstream does, but not Debian).
      In addition to just enabling it our solution provides:
      + do not autostart if subnet is already taken (e.g. in guests).
      + iterate some alternative subnets before giving up
    - d/p/ubuntu/Allow-libvirt-group-to-access-the-socket.patch: This is
      the group based access to libvirt functions as it was used in Ubuntu
      for quite long.
      + d/p/ubuntu/daemon-augeas-fix-expected.patch fix some related tests
        due to the group access change.
      + d/libvirt-daemon-system.postinst: add users in sudo to the libvirt
        group.
    - ubuntu/parallel-shutdown.patch: set parallel shutdown by default.
    - Update Vcs-Git and Vcs-Browser fields to point to launchpad
    - Update README.Debian with Ubuntu changes
    - Enable some additional features on ppc64el and s390x (for arch parity)
      + systemtap, zfs, numa and numad on s390x.
      + systemtap on ppc64el.
    - d/p/ubuntu/ubuntu_machine_type.patch: accept ubuntu types as pci440fx
    - Further upstreamed apparmor Delta, especially any new one
      Our former delta is split into logical pieces and is either Ubuntu only
      or is part of a continuous upstreaming effort.
      Listing related remaining changes in debian/patches/ubuntu-aa/:
    - fix autopkgtests
      + d/t/control, d/t/smoke-qemu-session: fixup smoke-qemu-session by making
        vmlinuz available and accessible (Debian bug 848314)
      + d/t/control: fix smoke-qemu-session by ensuring the service will run
        installing libvirt-daemon-system
      + d/t/smoke-lxc: fix smoke-lxc by ignoring potential issues on destroy as
        long as the following undefine succeeds
      + d/t/smoke-lxc: use systemd instead of sysV to restart the service
    - dnsmasq related enhancements
      + run dnsmasq as libvirt-dnsmasq (LP: 1743718)
      + d/libvirt-daemon-system.postinst: add libvirt-dnsmasq user and group
      + d/libvirt-daemon-system.postrm: remove libvirt-dnsmasq user and group
        on purge
      + d/p/ubuntu/dnsmasq-as-priv-user: write dnsmasq config with user
        libvirt-dnsmasq and adapt t...

Changed in libvirt (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.