Bug 1363943

Summary: virt-who can be started in xen mode if no "env"/"owner" option in /etc/virt-who.d/xxx
Product: Red Hat Enterprise Linux 7 Reporter: Liushihui <shihliu>
Component: virt-whoAssignee: Radek Novacek <rnovacek>
Status: CLOSED ERRATA QA Contact: Eko <hsun>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.3CC: ldai, ovasik, sgao
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: virt-who-0.17-8.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 05:10:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Liushihui 2016-08-04 05:35:10 UTC
Description of problem:
When virt-who run at xen mode, disable "env"/"owner" or set "env"/"owner" to null in /etc/virt-who.d/xxxx, virt-who still can be started.

If I disable VIRTWHO_XEN_ENV/VIRTWHO_XEN_OWNER in /etc/sysconfig/virt-who, virt-who started failed and feedback with error info "virt-who can't be started: Option --xen-env (or VIRTWHO_XEN_ENV environment variable) needs to be set"

If I run virt-who CLI without "--xen-env/--xen-owner" option,  virt-who started failed and feedback with error info as before.

Version-Release number of selected component (if applicable):
virt-who-0.17-7.el7.noarch
subscription-manager-1.17.9-1.el7.x86_64
python-rhsm-1.17.5-1.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. create the config fie in /etc/virt-who.d, make sure without env/owner option
[root@hp-z220-08 ~]# cat /etc/virt-who.d/xen
[xen]
type=xen
server=10.73.5.210
username=root
password=Welcome1
owner=ACME_Corporation

2. restart virt-who service and check virt-who's log
[root@hp-z220-08 ~]# service virt-who restart
Redirecting to /bin/systemctl restart  virt-who.service
[root@hp-z220-08 ~]# service virt-who status
Redirecting to /bin/systemctl status  virt-who.service
[root@hp-z220-08 ~]# tail -f /var/log/rhsm/rhsm.log
● virt-who.service - Daemon for reporting virtual guest IDs to subscription-manager
   Loaded: loaded (/usr/lib/systemd/system/virt-who.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2016-08-04 01:25:01 EDT; 14s ago
 Main PID: 14059 (virt-who)
   CGroup: /system.slice/virt-who.service
           ├─14059 /usr/bin/python2 /usr/bin/virt-who
           └─14066 /usr/bin/python2 /usr/bin/virt-who
2016-08-04 01:24:56,717 [virtwho.main DEBUG] MainProcess(14039):MainThread @executor.py:terminate:303 - virt-who is shutting down
2016-08-04 01:25:01,904 [virtwho.init DEBUG] MainProcess(14059):MainThread @executor.py:__init__:65 - Using config named 'xen'
2016-08-04 01:25:01,904 [virtwho.init INFO] MainProcess(14059):MainThread @main.py:main:160 - Using configuration "xen" ("xen" mode)
2016-08-04 01:25:01,905 [virtwho.init INFO] MainProcess(14059):MainThread @main.py:main:162 - Using reporter_id='hp-z220-08.qe.lab.eng.nay.redhat.com-63e1ccb2df0242c98fa91794572d568b'
2016-08-04 01:25:01,906 [virtwho.main DEBUG] MainProcess(14059):MainThread @executor.py:run:171 - Starting infinite loop with 60 seconds interval
2016-08-04 01:25:01,935 [virtwho.xen DEBUG] Xen-1(14066):MainThread @virt.py:run:364 - Virt backend 'xen' started
2016-08-04 01:25:01,935 [virtwho.xen DEBUG] Xen-1(14066):MainThread @xen.py:_prepare:42 - Logging into XEN pools https://10.73.5.210
2016-08-04 01:25:02,016 [virtwho.xen DEBUG] Xen-1(14066):MainThread @xen.py:login:52 - XEN pool login successful with user root
2016-08-04 01:25:02,496 [virtwho.xen DEBUG] Xen-1(14066):MainThread @xen.py:getHostGuestMapping:80 - Control Domain 0e57a500-1ff6-464e-b863-fd8ee93f2738 is ignored
2016-08-04 01:25:02,496 [virtwho.xen DEBUG] Xen-1(14066):MainThread @virt.py:enqueue:357 - Report for config "xen" gathered, putting to queue for sending
2016-08-04 01:25:02,507 [virtwho.main DEBUG] MainProcess(14059):MainThread @subscriptionmanager.py:_connect:123 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2016-08-04 01:25:02,539 [virtwho.main DEBUG] MainProcess(14059):MainThread @subscriptionmanager.py:hypervisorCheckIn:171 - Checking if server has capability 'hypervisor_async'
2016-08-04 01:25:02,573 [virtwho.main DEBUG] MainProcess(14059):MainThread @subscriptionmanager.py:hypervisorCheckIn:183 - Server does not have 'hypervisors_async' capability
2016-08-04 01:25:02,573 [virtwho.main INFO] MainProcess(14059):MainThread @subscriptionmanager.py:hypervisorCheckIn:194 - Sending update in hosts-to-guests mapping for config "xen": 1 hypervisors and 0 guests found
2016-08-04 01:25:02,573 [virtwho.main DEBUG] MainProcess(14059):MainThread @subscriptionmanager.py:hypervisorCheckIn:195 - Host-to-guest mapping: {
    "b27310f3-77ec-46ed-be4e-5609e85e280c": []
}
2016-08-04 01:25:02,618 [virtwho.main ERROR] MainProcess(14059):MainThread @executor.py:send:143 - Unable to send data: Communication with subscription manager failed with code 404: Couldn't find environment 'None'

Actual results:
Although virt-who will show error in log, virt-who can start normally.

Expected results:
Virt-who shouldn't be started when it with null env/owner. And the error info should the same as the following:
[root@hp-z220-08 ~]# service virt-who restart
Redirecting to /bin/systemctl restart  virt-who.service
Job for virt-who.service failed because the control process exited with error code. See "systemctl status virt-who.service" and "journalctl -xe" for details.
[root@hp-z220-08 ~]# systemctl status virt-who.service
● virt-who.service - Daemon for reporting virtual guest IDs to subscription-manager
   Loaded: loaded (/usr/lib/systemd/system/virt-who.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2016-08-04 01:14:42 EDT; 18s ago
  Process: 13904 ExecStart=/usr/bin/virt-who (code=exited, status=1/FAILURE)
 Main PID: 13904 (code=exited, status=1/FAILURE)
   Status: "virt-who can't be started: Option `env` needs to be set in config `xen`"


Additional info:
When virt-who run at rhevm, esx and hyperv mode ,it hasn't this problem.

Comment 1 Radek Novacek 2016-08-11 14:00:53 UTC
Fix is applied upstream:

https://github.com/virt-who/virt-who/commit/aa28a1be35fad31de21ecdb073c8cba4637d338a

Comment 2 Radek Novacek 2016-08-11 14:30:02 UTC
Fixed in virt-who-0.17-8.el7.

Comment 3 Liushihui 2016-08-18 02:34:48 UTC
*** Bug 1367957 has been marked as a duplicate of this bug. ***

Comment 5 Liushihui 2016-08-29 03:57:36 UTC
Verified it on virt-who-0.17-10.el7.noarch since virt-who has been checked none env and owner and report error info . Therefore, verify it.

Comment 7 errata-xmlrpc 2016-11-04 05:10:26 UTC
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.

https://rhn.redhat.com/errata/RHBA-2016-2387.html