Bug 869100

Summary: poor error message for virsh snapshot-list --roots --current
Product: Red Hat Enterprise Linux 6 Reporter: weizhang <weizhan>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: medium    
Version: 6.4CC: acathrow, dallan, dyasny, dyuan, eblake, mzhan, whuang, zhpeng
Target Milestone: rcKeywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.10.2-6.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 07:10:53 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 weizhang 2012-10-23 03:06:46 UTC
Description of problem:
If I create a snapshot with --no-metadata, then snapshot-list will not list this snapshot with --no-metadata
And with --roots --current, snapshot-list can not list expect result but error
error: --roots and --from are mutually exclusive


Version-Release number of selected component (if applicable):
libvirt-0.10.2-4.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.329.el6.x86_64
kernel-2.6.32-329.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Prepare a guest with qcow2 disk
2. Create snapshot with --no-metadata
# virsh snapshot-create guest --nometadata
Domain snapshot 1350900552 created

3. List snapshots
# virsh snapshot-list guest --no-metadata
 Name                 Creation Time             State
------------------------------------------------------------

4. # virsh snapshot-list guest --roots --current
error: --roots and --from are mutually exclusive
  
Actual results:
1. Can not list no metadata snapshot with --no-metadata
2. list with --roots --current report error

Expected results:
1. Can list no metadata snapshot with --no-metadata
2. list with --roots --current works well


Additional info:

Comment 1 Eric Blake 2012-10-23 03:14:36 UTC
(In reply to comment #0)
> Description of problem:
> If I create a snapshot with --no-metadata, then snapshot-list will not list
> this snapshot with --no-metadata
> And with --roots --current, snapshot-list can not list expect result but
> error
> error: --roots and --from are mutually exclusive
> 
> 
> Version-Release number of selected component (if applicable):
> libvirt-0.10.2-4.el6.x86_64
> qemu-kvm-rhev-0.12.1.2-2.329.el6.x86_64
> kernel-2.6.32-329.el6.x86_64
> 
> How reproducible:
> 100%
> 
> Steps to Reproduce:
> 1. Prepare a guest with qcow2 disk
> 2. Create snapshot with --no-metadata
> # virsh snapshot-create guest --nometadata
> Domain snapshot 1350900552 created
> 

This creates a snapshot, _and then immediately deletes the metadata_.  That is, it is useful for creating snapshot files _without tracking an actual snapshot_.

> 3. List snapshots
> # virsh snapshot-list guest --no-metadata
>  Name                 Creation Time             State
> ------------------------------------------------------------

This is expected.

> 
> 4. # virsh snapshot-list guest --roots --current
> error: --roots and --from are mutually exclusive

This is expected.

>   
> Actual results:
> 1. Can not list no metadata snapshot with --no-metadata

There is no way to list qemu snapshots that lack metadata, yet.  Upstream will eventually add a way to list internal snapshots that do not have libvirt data, but where qemu can use 'loadvm' to revert to that snapshot; but you cannot create this situation from libvirt alone, and it is not yet an upstream feature.

> 2. list with --roots --current report error

That is correct, because once you limit a tree (such as by using --current), then using --roots no longer makes sense (--roots only works when used on the global list of snapshots for a domain).

Hence, I'm closing this as NOTABUG.

Comment 2 weizhang 2012-10-23 03:42:46 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > Description of problem:
> > If I create a snapshot with --no-metadata, then snapshot-list will not list
> > this snapshot with --no-metadata
> > And with --roots --current, snapshot-list can not list expect result but
> > error
> > error: --roots and --from are mutually exclusive
> > 
> > 
> > Version-Release number of selected component (if applicable):
> > libvirt-0.10.2-4.el6.x86_64
> > qemu-kvm-rhev-0.12.1.2-2.329.el6.x86_64
> > kernel-2.6.32-329.el6.x86_64
> > 
> > How reproducible:
> > 100%
> > 
> > Steps to Reproduce:
> > 1. Prepare a guest with qcow2 disk
> > 2. Create snapshot with --no-metadata
> > # virsh snapshot-create guest --nometadata
> > Domain snapshot 1350900552 created
> > 
> 
> This creates a snapshot, _and then immediately deletes the metadata_.  That
> is, it is useful for creating snapshot files _without tracking an actual
> snapshot_.
> 
> > 3. List snapshots
> > # virsh snapshot-list guest --no-metadata
> >  Name                 Creation Time             State
> > ------------------------------------------------------------
> 
> This is expected.
> 
> > 
> > 4. # virsh snapshot-list guest --roots --current
> > error: --roots and --from are mutually exclusive
> 
> This is expected.
> 

Can it means that the root of current children? Because I can get the result with perl-Sys-Virt
$snapshot->list_all_children(Sys::Virt::DomainSnapshot::LIST_ROOTS);

else , it also should report "--roots and --current are mutually exclusive"

> >   
> > Actual results:
> > 1. Can not list no metadata snapshot with --no-metadata
> 
> There is no way to list qemu snapshots that lack metadata, yet.  Upstream
> will eventually add a way to list internal snapshots that do not have
> libvirt data, but where qemu can use 'loadvm' to revert to that snapshot;
> but you cannot create this situation from libvirt alone, and it is not yet
> an upstream feature.
> 
> > 2. list with --roots --current report error
> 
> That is correct, because once you limit a tree (such as by using --current),
> then using --roots no longer makes sense (--roots only works when used on
> the global list of snapshots for a domain).
> 
> Hence, I'm closing this as NOTABUG.

Comment 3 Eric Blake 2012-10-23 12:35:59 UTC
(In reply to comment #2)

> > > 4. # virsh snapshot-list guest --roots --current
> > > error: --roots and --from are mutually exclusive
> > 
> > This is expected.
> > 
> 
> Can it means that the root of current children? Because I can get the result
> with perl-Sys-Virt
> $snapshot->list_all_children(Sys::Virt::DomainSnapshot::LIST_ROOTS);

This is a bug in your script.  The value of Sys::Virt::DomainSnapshot::LIST_ROOTS and Sys::Virt::DomainSnapshot::LIST_DESCENDANTS are identical; LIST_ROOTS is for listing snapshots of a domain, while LIST_DESCENDANTS is for listing children of a snapshot.  You are passing the wrong name but the right value for the LIST_DESCENDANTS behavior.

> 
> else , it also should report "--roots and --current are mutually exclusive"

--roots says to filter to snapshots with no parents.  But the moment you limit the tree to a subset, as in using --current, then everything in that subset has a parent, and thus none of them are roots.  Hence, --roots and --current are mutually exclusive.

However, there is an upstream thread about poor error message quality:
https://www.redhat.com/archives/libvir-list/2012-October/msg01183.html

So I will reopen and retitle this bug, as a request to backport the improved error message.

Comment 4 Eric Blake 2012-10-25 21:21:33 UTC
Here's another attempt upstream at improving the situation:
https://www.redhat.com/archives/libvir-list/2012-October/msg01526.html

Comment 7 Huang Wenlong 2012-10-31 03:15:14 UTC
Verify this bug with:
libvirt-0.10.2-6.el6.x86_64

# virsh snapshot-create-as q1 ds1 --disk-only 
Domain snapshot ds1 created

# virsh snapshot-create-as q1 ds2 --disk-only 
Domain snapshot ds2 created


# virsh snapshot-list q1 --roots --current 
error: --roots and --current are mutually exclusive

Comment 8 errata-xmlrpc 2013-02-21 07:10:53 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.

http://rhn.redhat.com/errata/RHSA-2013-0276.html