during shutdown libvirt-guests.sh shouldn't run if libvirtd isn't running
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-
Dec 01 13:52:14 goom-i5 libvirt-
Dec 01 13:52:15 goom-i5 libvirt-
Dec 01 13:52:16 goom-i5 libvirt-
Dec 01 13:52:17 goom-i5 libvirt-
Dec 01 13:52:18 goom-i5 libvirt-
Dec 01 13:52:19 goom-i5 libvirt-
Dec 01 13:52:20 goom-i5 libvirt-
Dec 01 13:52:21 goom-i5 libvirt-
Dec 01 13:52:22 goom-i5 libvirt-
This occurs on my old 16.04 test server and a newly created 20.04 test server.
For example, this seems to work well:
doug@goom- i5:~/config/ usr/lib/ libvirt$ diff libvirt- guests. sh.original libvirt-guests.sh RETRIES} RETRIES}
114,124c114,126
< i=${CONNECT_
< 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_
> 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