Bug 1507737 - virsh prompt doesn't change after changing the connection to readonly
Summary: virsh prompt doesn't change after changing the connection to readonly
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.5
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Libvirt Maintainers
QA Contact: Meina Li
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-31 03:24 UTC by Lili Zhu
Modified: 2018-10-30 09:51 UTC (History)
7 users (show)

Fixed In Version: libvirt-4.3.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-10-30 09:50:00 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:3113 None None None 2018-10-30 09:51:23 UTC

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@gmail.com>
AuthorDate: Sun Nov 26 22:18:11 2017 -0200
Commit:     Erik Skultety <eskultet@redhat.com>
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@gmail.com>
    Reviewed-by: Erik Skultety <eskultet@redhat.com>

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


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