Bug 735498

Summary: libvirt undefine on running guest should allow transition from persistent to transient
Product: Red Hat Enterprise Linux 6 Reporter: Eric Blake <eblake>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2CC: dyuan, mzhan, nzhang, rwu, veillard, whuang, yupzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.4-9.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 11:28:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 735495    
Bug Blocks: 638510    

Description Eric Blake 2011-09-02 20:05:50 UTC
Description of problem:
Libvirt can convert a transient guest to persistent (by defining the xml for a running domain), and the public API for virDomainUndefine claimed that the converse of converting a persistent back to transient was possible (by undefining a running domain).  However, the qemu driver was rejecting this.

Version-Release number of selected component (if applicable):
libvirt-0.9.4-7.el6

How reproducible:
100%

Steps to Reproduce:
1. create and start a persistent guest
2. use virDomainUndefine to convert it to persistent
3.
  
Actual results:
step 2 is rejected by the qemu driver (also, note that bug 735495 also documents that it is rejected by 'virsh undefine'; you'd have to use python, perl, or C bindings to test this to make sure virsh is not in the way)

Expected results:
after step 2, the domain should still be running, but show up as transient

Additional info:

Comment 1 Eric Blake 2011-09-02 20:12:03 UTC
Getting this fixed will help in testing bug 638510 support for live snapshots via the snapshot_blkdev qemu monitor command, since one of the snapshot transitions that must be properly handled is creating an offline snapshot of a persistent guest, starting the guest, converting the guest to transient, then stopping the guest, and seeing if the metadata is properly cleaned up.  It also brings the code into compliance with the API documentation.

See these upstream commits (the second even includes the test described in the original comment)

commit aaa93ab6faa178406d9a472f6002a6985e5ebc72
Author: Osier Yang <jyang>
Date:   Fri Aug 19 21:49:37 2011 +0800

    qemu: Allow to undefine a running domain

commit 5f98c437077e2ee7f7cf8c8d8427966d60c7e539
Author: Eric Blake <eblake>
Date:   Fri Aug 19 08:57:22 2011 -0600

    test: rewrite test to match change in behavior
    
    Test failure exposed in commit 7d3390f.
    
    * tests/undefine: Fix to match updated test driver semantics.

Comment 5 yuping zhang 2011-09-07 08:10:58 UTC
Reproduce this issue libvirt-0.9.4-7.el6.x86_64:
# virsh list --all
 Id Name                 State
----------------------------------
  2 rhel6             running
# virsh undefine rhel6
error: Failed to undefine domain rhel6
error: Requested operation is not valid: cannot delete active domain

Verified this issue with:

libvirt-0.9.4-9.el6.x86_64
qemu-kvm-0.12.1.2-2.185.el6.x86_64

# virsh list --all
 Id Name                 State
----------------------------------
  2 rhel6             running


# virsh undefine 2
Domain 2 has been undefined

# virsh shutdown 2
Domain 2 is being shutdown

# virsh list 
 Id Name                 State
----------------------------------

So change the status to VERIFIED.

Comment 6 errata-xmlrpc 2011-12-06 11:28:18 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