Bug 1507737

Summary: virsh prompt doesn't change after changing the connection to readonly
Product: Red Hat Enterprise Linux 7 Reporter: Lili Zhu <lizhu>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED ERRATA QA Contact: Meina Li <meili>
Severity: low Docs Contact:
Priority: low    
Version: 7.5CC: dyuan, eskultet, fjin, jcfaracco, jdenemar, xuzhang, yafu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-4.3.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 09:50:00 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 Lili Zhu 2017-10-31 03:24:33 UTC
Description of problem:
virsh prompt doesn't change after changing the connection to readonly

Version-Release number of selected component (if applicable):
libvirt-3.8.0-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

Firstly, connect to libvirtd in read-write mode. Then change the connection
to read-only mode:

# virsh 
Welcome to virsh, the virtualization interactive terminal.

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

virsh # list --all
 Id    Name                           State
----------------------------------------------------
 8     rhel7.5                        running

virsh # connect --readonly

virsh # destroy rhel7.5               <========the prompt does NOT change
error: Failed to destroy domain rhel7.5
error: operation forbidden: read only access prevents virDomainDestroy

virsh # 


Actual results:
The prompt doesn't change after changing the connection to readonly

Expected results:
The prompt should change to ">" after changing the connection to readonly

Additional info:

Comment 2 Julio Faracco 2017-11-26 22:52:11 UTC
Another test case that works:

virsh # uri
qemu:///system

virsh # connect qemu:///system --readonly     # simulate a re-connection.

virsh >

Comment 3 Erik Skultety 2017-11-27 09:22:09 UTC
Fixed upstream by:

commit 13d45b0dc25ed99a9da0704d01cf21c8fe99f951 (HEAD -> master, origin/master, origin/HEAD, virsh-connect-readonly)
Author:     Julio Faracco <jcfaracco>
AuthorDate: Sun Nov 26 22:18:11 2017 -0200
Commit:     Erik Skultety <eskultet>
CommitDate: Mon Nov 27 10:12:30 2017 +0100

    virsh: Fix virsh prompt when connection changes to readonly mode.
    
    This commit fixes the virsh prompt when reconnection to the same URI is
    called: `virsh # connect --readonly` (Reconnect). The problem is
    happening because the code is considering URI (name) as a mandatory
    parameter to change the prompt. This commit remove the assignment into
    `priv->readonly` from `if (name)` conditional.
    
    Before:
        virsh # uri
        qemu:///system
    
        virsh # connect --readonly
    
        virsh #
    
    After:
        virsh # uri
        qemu:///system
    
        virsh # connect --readonly
    
        virsh >
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1507737
    
    Signed-off-by: Julio Faracco <jcfaracco>
    Reviewed-by: Erik Skultety <eskultet>

Comment 5 Meina Li 2018-06-22 02:23:48 UTC
Verified on libvirt-4.4.0-2.virtcov.el7.x86_64 and qemu-kvm-rhev-2.12.0-4.el7.x86_64.

Steps:
# virsh 
Welcome to virsh, the virtualization interactive terminal.

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

virsh # list --all
 Id    Name                           State
----------------------------------------------------
 21    ovmf                           running
 -     lmn                            shut off

virsh # uri
qemu:///system

virsh # connect --readonly

virsh > 
virsh > list --all
 Id    Name                           State
----------------------------------------------------
 21    ovmf                           running
 -     lmn                            shut off

virsh > destroy ovmf
error: Failed to destroy domain ovmf
error: operation forbidden: read only access prevents virDomainDestroy

All the results are expected, so change the status to verified.

Comment 7 errata-xmlrpc 2018-10-30 09:50:00 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://access.redhat.com/errata/RHSA-2018:3113