Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 1357363

Summary: Some environment variables don't take effect for virt-admin
Product: Red Hat Enterprise Linux 7 Reporter: Fangge Jin <fjin>
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, eskultet, mzhan, rbalakri, yafu, yanqzhan, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-2.0.0-4.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:50:19 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:

Description Fangge Jin 2016-07-18 05:08:25 UTC
Description of problem:
Set environment variables  VIRT_ADMIN_DEBUG and  VIRT_ADMIN_LOG_FILE, then execute virt-admin commands, no debug log produced and no log file created.

Set environment variable VIRT_ADMIN_HISTSIZE, then execute virt-admin command in interactive mode, it also doesn't take effect.

Version-Release number of selected component:
libvirt-2.0.0-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Open a terminal and set environment variables:
# export VIRT_ADMIN_DEBUG=0
# export VIRT_ADMIN_LOG_FILE="/tmp/virt-admin.log"
# export VIRT_ADMIN_HISTSIZE=2

2.In the same terminal:
# virt-admin uri
libvirtd:///system

3.Check file /tmp/virt-admin.log
# cat /tmp/virt-admin.log
cat: /tmp/virt-admin.log: No such file or directory

4.Enter interactive mode:
# virt-admin
Welcome to virt-admin, the administrating virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virt-admin #


5. Execute three different commands:
virt-admin # pwd
/root/libvirt

virt-admin # cd /

virt-admin # srv-list
 Id    Name           
---------------
 0     libvirtd       
 1     admin          


6. Press "UP" key continually for three times and press enter:
virt-admin # pwd
/


Actual results:
As step 2&3&6

Expected results:
Step2:
# virt-admin uri
commands: "uri"  ===> outputs debug log
libvirtd:///system

Step3:
And the debug log is written into log file:
# cat /tmp/virt-admin.log
[2016.07.15 23:19:11 virt-admin 17544] INFO commands: "uri"

Step6:
The oldest history command should be "cd /" instead of "pwd"

Comment 2 Erik Skultety 2016-07-28 12:06:15 UTC
Fixed in upstream by:

commit d02ef33451a0d84692f32fe0877d621bfe243f50
Author:     Erik Skultety <eskultet@redhat.com>
AuthorDate: Thu Jul 28 12:54:16 2016 +0200
Commit:     Erik Skultety <eskultet@redhat.com>
CommitDate: Thu Jul 28 13:54:06 2016 +0200

    tools: Make use of the correct environment variables
    
    Since commit 834c5720 which extracted the generic functionality out of virsh
    and made it available for other clients like virt-admin to make use of it, it
    also introduced a bug when it renamed the original VIRSH_ environment variables
    to VSH_ variables. Virt-admin of course suffers from the same bug, so this
    patch modifies the generic module vsh.c to construct the correct name for
    environment variables of each client from information it has.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1357363
    
    Signed-off-by: Erik Skultety <eskultet@redhat.com>

v2.1.0-rc1-9-gd02ef33

Comment 6 yanqzhan@redhat.com 2016-08-09 09:36:36 UTC
Reproduce this bug on libvirt-2.0.0-2.el7.x86_64.

Steps to reproduce:
(A)For virt-admin: the steps and results are same as comment 0.

(B)For virsh client:
1.Open a terminal and set environment variables:
# export VIRSH_DEBUG=0
# export VIRSH_LOG_FILE="/tmp/virsh.log"
# export HISTSIZE=3

2.In the same terminal:
# virsh uri
qemu:///system

3.Check file /tmp/virsh.log
# cat /tmp/virsh.log
cat: /tmp/virsh.log: No such file or directory

4.4.Enter interactive mode and execute 4 different commands:
# virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # pwd
/root

virsh # list
 Id    Name                           State
----------------------------------------------------

virsh # cd /

virsh # hostname
hostB

5. Press "UP" key continually for 4 times and press enter:
virsh # pwd
/


Verify this bug on libvirt-2.0.0-4.el7.x86_64.

Steps to Verify:
(A)For virt-admin: 
1.Open a terminal and set environment variables:
# export VIRT_ADMIN_DEBUG=0
# export VIRT_ADMIN_LOG_FILE="/tmp/virt-admin.log"
# export VIRT_ADMIN_HISTSIZE=3

2.In the same terminal:
# virt-admin uri
commands: "uri"
libvirtd:///system

3.Check file /tmp/virt-admin.log
# cat /tmp/virt-admin.log
[2016.08.09 13:57:48 virt-admin 7760] INFO commands: "uri"

4.Enter interactive mode, and execute 4 different commands:
# virt-admin
Welcome to virt-admin, the administrating virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virt-admin # pwd
/root

virt-admin # version
Compiled against library: libvirt 2.0.0
Using library: libvirt 2.0.0
Running against daemon: 2.0.0

virt-admin # cd /
cd: dir(optdata): /

virt-admin # srv-list
 Id    Name           
---------------
 0     admin          
 1     libvirtd 
     

5. Press "UP" key continually for 4 times and press enter:
virt-admin # version
Compiled against library: libvirt 2.0.0
Using library: libvirt 2.0.0
Running against daemon: 2.0.0

(B)For virsh client:
1.Open a terminal and set environment variables:
#  export VIRSH_DEBUG=0
# export VIRSH_LOG_FILE="/tmp/virsh.log"
# export VIRSH_HISTSIZE=3

2.In the same terminal:
# virsh uri
commands: "uri"
qemu:///system

3.Check file /tmp/virsh.log
# cat /tmp/virsh.log
[2016.08.09 14:47:53 virsh 8158] INFO commands: "uri"

4.Enter interactive mode, and execute 4 different commands:
# virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # pwd
/root

virsh # list
 Id    Name                           State
----------------------------------------------------
 124   test1                          paused
 149   vmnode2                        running

virsh # cd /
cd: dir(optdata): /

virsh # hostname
hostA

5. Press "UP" key continually for 4 times and press enter:
virsh # list
 Id    Name                           State
----------------------------------------------------
 124   test1                          paused
 149   vmnode2                        running

Since the result is as expected, mark this bug as verified.

Comment 8 errata-xmlrpc 2016-11-03 18:50:19 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/RHSA-2016-2577.html