Bug 742410 - Output need be improved for virsh snapshot-parent
Summary: Output need be improved for virsh snapshot-parent
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.2
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Eric Blake
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 747120
TreeView+ depends on / blocked
 
Reported: 2011-09-30 02:44 UTC by Alex Jia
Modified: 2011-12-06 11:34 UTC (History)
7 users (show)

Fixed In Version: libvirt-0.9.4-15.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-12-06 11:34:47 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1513 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2011-12-06 01:23:30 UTC

Description Alex Jia 2011-09-30 02:44:08 UTC
Description of problem:
when current snapshot is a root, you can't get any error information by virsh snapshot-parent, however, the command will return 1.

Version-Release number of selected component (if applicable):
# uname -r
2.6.32-202.el6.x86_64

# rpm -q libvirt
libvirt-0.9.4-14.el6.x86_64

# rpm -q qemu-kvm
qemu-kvm-0.12.1.2-2.183.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. cat /tmp/snap.xml 
<domainsnapshot>
  <name>hello</name>
  <state>shutoff</state>
</domainsnapshot>

2. virsh snapshot-create vr-rhel5u4-x86_64-kvm snap.xml
3. virsh snapshot-list vr-rhel5u4-x86_64-kvm --parent
4. virsh snapshot-parent vr-rhel5u4-x86_64-kvm hello
5. echo $?
  
Actual results:
without any error information.

Expected results:
error: Domain snapshot not found: snapshot 'hello' does not have a parent

Additional info:

Comment 1 Alex Jia 2011-09-30 02:46:02 UTC
Patch for upstream:

commit 4ee8092dde8b2f017dd862159f8c70fb4092b721
Author: Eric Blake <eblake@redhat.com>
Date:   Sat Sep 24 18:02:24 2011 -0600

    snapshot: implement getparent in qemu
    
    First hypervisor implementation of the new API.
    Allows 'virsh snapshot-list --tree' to be more efficient.
    
    * src/qemu/qemu_driver.c (qemuDomainSnapshotGetParent): New
    function.

Comment 3 Eric Blake 2011-09-30 12:39:45 UTC
I'll handle this.  We cannot backport 4ee8092, since we cannot add new API without a rebase.  But it is still possible to make virsh smarter about snapshots without parents, even without new API.

Comment 4 Eric Blake 2011-09-30 14:36:56 UTC
Also, 'virsh snapshot-current' has existed longer than snapshot-parent.  It currently outputs nothing, but gives status 0, when there is no current snapshot.

Both 'snapshot-current --name' and snapshot-parent are intended for use in scripting situations, so any errors they output must be to stderr.  But I'm not yet decided on whether they should silently exit with status 0 and no output, or noisily exit with status 1 and an error message, when there is no hit (that is, the specific error VIR_ERR_NO_SNAPSHOT_DOMAIN).  Of course, for other errors, such as virDomainSnaphot{Current,GetParent,GetXMLDesc} not supported, or for the domain deleted in the meantime, and so forth, these should error out, leaving the silent status for just the case of no hit, if I decide to go for the silent behavior.

Your report also made me realize that upstream has a bug not present in RHEL 6.2:
# tools/virsh dom testing2
error: unknown procedure: 244

That is, when virDomainSnapshotGetParent is not present, the upstream code is not properly squelching that error message when it falls back to virDomainSnapshotGetXMLDesc.

Comment 5 Eric Blake 2011-09-30 14:40:01 UTC
(In reply to comment #4)
> Your report also made me realize that upstream has a bug not present in RHEL
> 6.2:
> # tools/virsh dom testing2
> error: unknown procedure: 244

Sorry, that should have been:

# tools/virsh snapshot-parent dom testing2

Comment 6 Eric Blake 2011-09-30 21:27:36 UTC
Upstream patch proposed, which will issue an error for both snapshot-current and snapshot-parent when nothing is found:
https://www.redhat.com/archives/libvir-list/2011-September/msg01311.html

Backporting this required some conflict resolution, since the backport must avoid the new API, but I have something in my scratch directory ready to post as soon as I have upstream commit ids to refer back to.

Comment 7 Eric Blake 2011-09-30 23:13:30 UTC
In looking at this backport more, I have a choice:

Omit 'virsh snapshot-list --tree' support, and deal with more conflict resolution but fewer patches

Include 'virsh snapshot-list --tree' support, which results in a lot more patches, but much less conflict resolution

Both approaches only need to touch virsh code, so they are acceptable levels of risk even this late in RHEL 6.2.

I'll probably post both varieties, once my 'virsh snapshot-list --tree' support is completely approved upstream (commit 1cf0e3d is in, but it introduces typos that won't be fixed until the virsh patches from this series are approved: https://www.redhat.com/archives/libvir-list/2011-September/msg01326.html)

Comment 8 Eric Blake 2011-10-04 22:46:00 UTC
In POST:
Option 1: 2 patches, conflict resolution:
https://www.redhat.com/archives/libvir-list/2011-September/msg01326.html

Option 2: 8 patches (4 still need upstream review), 1 RHEL-specific so that remaining 7 are conflict-free:
http://post-office.corp.redhat.com/archives/rhvirt-patches/2011-October/msg00151.html

Comment 10 Eric Blake 2011-10-07 15:17:57 UTC
(In reply to comment #8)
> In POST:
> Option 1: 2 patches, conflict resolution:
> https://www.redhat.com/archives/libvir-list/2011-September/msg01326.html
> 
> Option 2: 8 patches (4 still need upstream review), 1 RHEL-specific so that
> remaining 7 are conflict-free:
> http://post-office.corp.redhat.com/archives/rhvirt-patches/2011-October/msg00151.html

libvirt-0.9.4-15.el6 went with option 1, since option 2 still hadn't received upstream ACK in time.  The typo fixes mentioned in comment 7 are now independently fixed as a followup to bug 735457

Comment 11 Alex Jia 2011-10-08 06:49:38 UTC
This issue has been resolved on rhel6 beta(2.6.32-193.el6.x86_64) with
libvirt-0.9.4-16.el6.x86_64, so move the bug to VERIFIED status.

The following are actual results:

# virsh snapshot-list demo
 Name                 Creation Time             State
------------------------------------------------------------
 hello                2011-10-08 14:44:55 +0800 shutoff

# virsh snapshot-parent demo hello
error: snapshot 'hello' has no parent

Notes, this is a expected result.

# echo $?
1

Comment 12 errata-xmlrpc 2011-12-06 11:34:47 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/RHBA-2011-1513.html


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