Bug 1300512 - oneshot mode doesn't work when starting as service
oneshot mode doesn't work when starting as service
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: virt-who (Show other bugs)
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Radek Novacek
: 1294760 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2016-01-20 22:30 EST by Liushihui
Modified: 2016-11-30 19:34 EST (History)
6 users (show)

See Also:
Fixed In Version: virt-who-0.16-2.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2016-05-10 19:57:18 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Liushihui 2016-01-20 22:30:52 EST
Description of problem:
When configure VIRTWHO_ONE_SHOT=1, virt-who will start at background mode rather than one-shot mode.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.Register system to satellite
2.Configure virt-who run at kvm one-shot mode:
[root@hp-dl120gen9-01 ~]# cat /etc/sysconfig/virt-who  | grep -v ^# | grep -v ^$
3.Restart virt-who service, then check virt-who's log
[root@hp-dl120gen9-01 ~]# service virt-who restart
[root@hp-dl120gen9-01 ~]# tail -f /var/log/rhsm/rhsm.log

Actual results:
It will show error info in the log
2016-01-20 22:07:14,760 [virtwho.init ERROR] MainProcess(6533):MainThread @virtwho.py:parseOptions:710 - Background and oneshot can't be used together, using background mode

Expected results:
As virt-who not support background mode, the related function should remove.
When configure one-shot mode in config file, virt-who can work at one-shot mode rather than background mode.

Additional info:
Check virt-who's source code. background related code should be removed.
# vim virt-who.py
    env = os.getenv("VIRTWHO_BACKGROUND", "0").strip().lower()
    if env in ["1", "true"]:
        options.background = True
line 709-711:
    if options.background and options.oneshot:
        logger.error("Background and oneshot can't be used together, using background mode")
        options.oneshot = False
Comment 1 Radek Novacek 2016-01-28 05:19:39 EST
The background mode is still needed internally on RHEL-6. When a service is started using `service virt-who start` it should do a double-fork to detach from the terminal. This is original purpose of background mode. There is (and will be) environment variable VIRTWHO_BACKGROUND that is set up by the initscript that will do the double-fork in virt-who. On RHEL-7 the double-fork is not needed as systemd can handle it directly.

Nevertheless the conflict between oneshot and background mode is no longer valid, so I'll remove it.
Comment 2 Radek Novacek 2016-01-28 05:23:18 EST
*** Bug 1294760 has been marked as a duplicate of this bug. ***
Comment 3 Radek Novacek 2016-01-28 08:04:13 EST
Fixed in virt-who-0.16-2.el6.
Comment 5 Liushihui 2016-02-04 02:21:46 EST
Verified it on virt-who-0.16-3.el6.noarch since virt-who can send h/g mapping when VIRTWHO_DEBUG=1 and VIRTWHO_ONE_SHOT=1 in /etc/sysconfig/virt-who. The log file as the following:

2016-02-04 02:19:27,915 [virtwho.init INFO] MainProcess(13530):MainThread @virtwho.py:parseOptions:630 - Using reporter_id='intel-canoepass-10.lab.bos.redhat.com'
2016-02-04 02:19:27,917 [virtwho.init INFO] MainProcess(13530):MainThread @virtwho.py:main:714 - No configurations found, using libvirt as backend
2016-02-04 02:19:27,917 [virtwho.init INFO] MainProcess(13530):MainThread @virtwho.py:main:721 - Using configuration "env/cmdline" ("libvirt" mode)
2016-02-04 02:19:28,078 [virtwho.env_cmdline DEBUG] Libvirtd-1(13539):MainThread @virt.py:run:358 - Virt backend 'env/cmdline' started
2016-02-04 02:19:28,081 [virtwho.env_cmdline INFO] Libvirtd-1(13539):MainThread @libvirtd.py:_connect:156 - Using libvirt url: ""
2016-02-04 02:19:28,109 [virtwho.env_cmdline DEBUG] Libvirtd-1(13539):MainThread @libvirtd.py:_listDomains:236 - Libvirt domains found: 9ebbeb2c-e391-b586-1d29-5e579c190a31
2016-02-04 02:19:28,110 [virtwho.env_cmdline DEBUG] Libvirtd-1(13539):MainThread @virt.py:enqueue:351 - Report gathered, putting to queue for sending
2016-02-04 02:19:28,126 [virtwho.main DEBUG] MainProcess(13533):MainThread @subscriptionmanager.py:_connect:121 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2016-02-04 02:19:28,324 [virtwho.main INFO] MainProcess(13533):MainThread @subscriptionmanager.py:sendVirtGuests:147 - Sending update in guests lists for config "env/cmdline": 1 guests found
2016-02-04 02:19:28,324 [virtwho.main DEBUG] MainProcess(13533):MainThread @subscriptionmanager.py:sendVirtGuests:148 - Domain info: [
        "guestId": "9ebbeb2c-e391-b586-1d29-5e579c190a31", 
        "state": 5, 
        "attributes": {
            "active": 0, 
            "hypervisorVersion": "0.12.1", 
            "virtWhoType": "libvirt", 
            "hypervisorType": "QEMU"
2016-02-04 02:19:29,113 [virtwho.env_cmdline DEBUG] Libvirtd-1(13539):MainThread @virt.py:run:377 - Virt backend 'env/cmdline' stopped after sending one report
2016-02-04 02:19:30,772 [virtwho.main DEBUG] MainProcess(13533):MainThread @virtwho.py:send_current_report:159 - Report for config "env/cmdline" sent
2016-02-04 02:19:30,774 [virtwho.main DEBUG] MainProcess(13533):MainThread @virtwho.py:<module>:805 - virt-who terminated
2016-02-04 02:19:30,774 [virtwho.main DEBUG] MainProcess(13533):MainThread @virtwho.py:terminate:352 - virt-who is shutting down
Comment 7 errata-xmlrpc 2016-05-10 19:57:18 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


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