Bug 1436502

Summary: [RFE] virsh list - Options to sort guests by name
Product: Red Hat Enterprise Linux 6 Reporter: Jayaraj <jdeenada>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.10CC: eskultet, rbalakri
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-28 06:59:27 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 Jayaraj 2017-03-28 03:30:50 UTC
Description of problem:

This request if from TAM customer.

When you list guests using virsh list it always sorts it by Id. Can we have an option to sort by name instead? It just makes it easier to spot of there is a missing host and/or to locate the guest. Yes I know you can query just the guest itself but that assumes I know which host to query.


How reproducible:
100%

Steps to Reproduce:

Eg: if I list all the KVMs on my host I get this:

[root@kvm2 gluster]# virsh list --all
 Id    Name                           State
----------------------------------------------------
 25    kvm2-guest-237                 running
 26    kvm2-guest-200                 running
 27    kvm2-guest-201                 running
 28    kvm2-guest-202                 running
 29    kvm2-guest-203                 running
 30    kvm2-guest-204                 running
 31    kvm2-guest-205                 running
 32    kvm2-guest-206                 running
 33    kvm2-guest-207                 running
 34    kvm2-guest-208                 running
 35    kvm2-guest-209                 running


As you can see the guest names are random because the list is sorted by Id - it's difficult to identify an individual guest.

Actual results:
Given above.

Expected results:
Customer wants to sort out by guest name with all columns. They are looking for an option like,

# virsh list --all --sort-by-name


Additional info:

Currently they have workaround but that doesn't give all other columns.

[root@kvm2 gluster]# virsh list --all | cut -c8-21 | grep kvm | sort
kvm2-guest-200
kvm2-guest-201
kvm2-guest-202
kvm2-guest-203
kvm2-guest-204
kvm2-guest-205

Please let me know if this can be considered as RFE.

Comment 2 Erik Skultety 2017-03-28 06:59:27 UTC
> Currently they have workaround but that doesn't give all other columns.
> 
> [root@kvm2 gluster]# virsh list --all | cut -c8-21 | grep kvm | sort
> kvm2-guest-200
> kvm2-guest-201
> kvm2-guest-202
> kvm2-guest-203
> kvm2-guest-204
> kvm2-guest-205

Well, they could use the following:
# virsh -q list --all | sort -k2
 -     dummy                          shut off
 4     f24-test                       running
 -     ubuntu-server                  shut off