[libvirt] RFC: Post-install behavior of libvirt(-client)

Martin Kletzander mkletzan at redhat.com
Tue Feb 14 08:37:29 UTC 2012

Hello everyone,

I have a small bug #786770 [1] assigned and I discussed this with few
people from our team but I'm still not sure what should be the proper
fix for this bug.
To sumarize the bug, the problem described and discussed there [1] is
that when there's a fresh installation of RHEL system with
libvirt-client, there are some error messages displayed. These messages
are generated by the part of %post client script where we are running this:

if [ $1 -ge 1 ]; then
    level=$(/sbin/runlevel | /bin/cut -d ' ' -f 2)
    if /sbin/chkconfig --levels $level libvirt-guests; then
        # this doesn't do anything but allowing for libvirt-guests to be
        # stopped on the first shutdown
        /sbin/service libvirt-guests start > /dev/null 2>&1 || true

The messages are generated because "/sbin/runlevel" returns "unknown" in
chrooted installation environment. But there's more to that. While
looking at this part of code, I wonder what we are trying to do here :)

There are some problems, let me revise:
 - 1st parameter of this script is 1 for install and 2 for upgrade, thus
"[ $1 -ge 1 ]" is always true
 - we are trying to get the current runlevel and then check if
libvirt-guests is enabled in this runlevel.

As mentioned before, the latter doesn't work because we are using
command "/sbin/runlevel" there. There is another option, but
unfortunately, running "/sbin/chkconfig libvirt-guests" fails as well.
Both of these are trying to get current runlevel from "/var/run/utmp"
which is empty in the chrooted env during installation.

Thinking about this a little more, I see two more "unconsistencies"
let's say:
 - we are starting libvirt-guests if it is enabled (rpm post script
should not start services)
 - we don't check if libvirtd is running, so during shutdown we can get
even more error messages that the script is not able to connect to
libvirt etc.

So I'm wondering if I can just remove the starting part (because if
someone wants to use it after first install, he has to start libvirtd
anyway and then should know to start libvirt-guests as well) or if I
have to come up with some totally different solution how to do this.
Maybe I'm missing something here or I don't understand it correctly, any
correction is appreciated.
Thanks in advance for all suggestions.

Have a nice day

[1] https://bugzilla.redhat.com/show_bug.cgi?id=786770

More information about the libvir-list mailing list