Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at
Bug 1089715 - script should execute only when libvirtd is stopped
Summary: script should execute only when libvirtd is stopped
Alias: None
Product: Spacewalk
Classification: Community
Component: Clients
Version: 2.2
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Stephen Herr
QA Contact: Red Hat Satellite QA List
Depends On: 888871
Blocks: space22
TreeView+ depends on / blocked
Reported: 2014-04-21 18:36 UTC by Stephen Herr
Modified: 2016-04-26 13:22 UTC (History)
5 users (show)

Fixed In Version: rhn-virtualization-5.4.53-1
Doc Type: Bug Fix
Doc Text:
Clone Of: 888871
Last Closed: 2014-07-17 08:40:46 UTC

Attachments (Terms of Use)

Description Stephen Herr 2014-04-21 18:36:31 UTC
+++ This bug was initially created as a clone of Bug #888871 +++

[3] What is the nature and description of the request?

/usr/share/rhn/virtualization/ (run as a cron job) provided by package="rhn-virtualization-host"
generates tracebacks (like below) without checking the status of libvirtd.


libvir: RPC error : Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory
Warning: Could not retrieve virtualization information!
        libvirtd service needs to be running.
libvir: RPC error : Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory
Traceback (most recent call last):
  File "<stdin>", line 301, in <module>
  File "/usr/share/rhn/virtualization/", line 70, in __init__
    self.conn = libvirt.openReadOnly(None)
  File "/usr/lib64/python2.6/site-packages/", line 247, in openReadOnly
    if ret is None:raise libvirtError('virConnectOpenReadOnly() failed')
libvirt.libvirtError: Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory

Which is annoying.

[4] Why does the customer need this? (List the business requirements here)

Customer does not want unwanted tracebacks to be sent as mails - even when libvirtd is running.
The following is *un-acceptable* to the customer.

In /etc/cron.d/rhn-virtualization.cron :

0-59/2 * * * * root python < /usr/share/rhn/virtualization/ &> /dev/null

This was not be acceptable to them as only the traces are directed to /dev/null
There exists no easy way for their support-team to get notified if libvirtd crashes/is stopped or 
something else (since depends upon libvirtd)

but they require the libvirtd crashes *also* be reported to them via mails
This is easier for their SUPPORT team to read and get notified about.

[5] How would the customer like to achieve this? (List the functional requirements here)

- The should check the status of the libvirtd and only execute when it finds 
  that libvirtd is stopped.
- The cron-job "/etc/cron.d/rhn-virtualization.cron" should be modified to execute in such a way that
  the comes into action only when libvirtd is detected as stopped.

[8] List any affected packages or components: rhn-virtualization-host

[10] Additional Note:

The following solution was *acceptable* to the customer.

Modify /etc/cron.d/rhn-virtualization.cron as below in the next release version of "rhn-virtualization-host"
like below

0-59/2 * * * * root [ -S /var/run/libvirt/libvirt-sock-ro ] && python < /usr/share/rhn/virtualization/

- Addition of "[ -S /var/run/libvirt/libvirt-sock-ro ] &&" will check libvirtd service is running or not.
- If running will execute, otherwise skip it from running. 

The advantage of this check is that, it will prevent from executing 
(if libvirtd service is stopped) and hence prevents 
the tracebacks generated due to libvirtd not running. 
At the same time will capture the error message generated by the 
script when libvirtd is running.

Comment 1 Stephen Herr 2014-04-21 18:40:35 UTC
The description above is a bit confusing, however the root problem is that if the server has both libvirt and rhn-virtualization-host installed and libvirtd is not running, the root user is spammed with email every two minutes from rhn-virtualization-host's cron job telling him that libvirtd is not running.

It is not rhn-virtualization-host's job to tell root that libvirtd is not running; the cron job should just exit silently in that case.

Comment 2 Stephen Herr 2014-04-21 18:44:56 UTC
Committing to Spacewalk master:

Comment 3 Stephen Herr 2014-04-22 17:58:38 UTC
And commit:

Comment 4 Stephen Herr 2014-04-23 12:40:55 UTC
And commit:

Comment 5 Milan Zázrivec 2014-07-17 08:40:46 UTC
Spacewalk 2.2 has been released:

Note You need to log in before you can comment on or make changes to this bug.