RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 697742 - libvirt: remove managedsave data when a domain is undefined
Summary: libvirt: remove managedsave data when a domain is undefined
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.1
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: rc
: ---
Assignee: Osier Yang
QA Contact: Virtualization Bugs
URL:
Whiteboard:
: 719284 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-04-19 05:28 UTC by zhe peng
Modified: 2018-11-14 11:49 UTC (History)
6 users (show)

Fixed In Version: libvirt-0.9.4-rc1-1.el6
Doc Type: Bug Fix
Doc Text:
Cause libvirt doesn't provide an option of domain undefine for user to remove the managed state file, and thus if the user undefine a domain which has an managed state file left, and defines a new domain with the same name later, it will fail when starting, as it sees the domain managed file with same name as domain exists, and it will try to restore from the managed state file. This is complete wrong. Consequence Domain starting will fail if there is a managed state file which was of a previous domain with the same domain name. Fix New API virDomainUndefineFlags was introduced with flags support, the user can specify the flag (e.g. virsh undefine --managed-save), the managed state file will be removed when undefine. If the managed state file exists, but no flag specified to tell libvirt to remove it, libvirt will refuse undefining the domain with sensiable error. Result There is option provided for user to choose to avoid the problem. Also if managed state file exists, but no option specified to tell libvirt to remove it, there will be an sensiable error, which will be enough to let the user known what he needs to do.
Clone Of:
Environment:
Last Closed: 2011-12-06 11:05:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


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

Description zhe peng 2011-04-19 05:28:47 UTC
Description of problem:
can't start new guest when have a managed save with same name

Version-Release number of selected component (if applicable):
python-virtinst-0.500.5-3.el6.noarch

How reproducible:
always

Steps to Reproduce:

1.install a guest with virt-install.
#virt-install -n test -r 1024 -f /dev/sdb -l http://download.englab.nay.redhat.com/pub/rhel/rel-eng/RHEL6.1-20110413.1/6.1/Server/x86_64/os/ --debug
after install success,run command line:
#virsh mananedsave test
2.destroy and undefine guest
#virsh destroy test
#virsh undefine test
#virsh list --all
 Id Name                 State
----------------------------------
 
3.install a new guest:
#virt-install -n test -r 1024 -f /dev/sdb -l http://download.englab.nay.redhat.com/pub/rhel/rel-eng/RHEL6.1-20110413.1/6.1/Server/x86_64/os/ --debug
  after install complete,click reboot button in guest.

Actual results:
the guest can't reboot,Exception:
error: Failed to start domain test
error: operation failed: cannot restore domain 'test' uuid af06f47d-9dc8-0bfd-a219-37c264e7d33c from a file which belongs to domain 'test' uuid 8f820670-f44d-3163-81e6-bbd39741b53b


Expected results:
the guest can start without error or have warning message to user.

Additional info:

Comment 2 RHEL Program Management 2011-04-19 06:00:12 UTC
Since RHEL 6.1 External Beta has begun, and this bug remains
unresolved, it has been rejected as it is not proposed as
exception or blocker.

Red Hat invites you to ask your support representative to
propose this request, if appropriate and relevant, in the
next release of Red Hat Enterprise Linux.

Comment 3 Cole Robinson 2011-04-19 14:31:34 UTC
Sounds like a libvirt bug. Libvirt should be removing the managedsave data when a domain is undefined.

Comment 4 Osier Yang 2011-04-20 07:31:29 UTC
patch posted upstream:

https://www.redhat.com/archives/libvir-list/2011-April/msg00957.html

Comment 5 Eric Blake 2011-04-20 13:40:31 UTC
Upstream the point was also made that we should probably also delete snapshot data when a domain is undefined:
https://www.redhat.com/archives/libvir-list/2011-April/msg00554.html

I'm wondering if any of that work should be folded in to this bug.

Comment 6 Osier Yang 2011-04-25 09:26:51 UTC
IMO, we'd better add flag to state whether to discard snapshot files as part of undefining a domain, sliently removing the snapshots will make some user scream I guess, which means we need to introduce new API to do the work. Personally I'd create another bug instead.

Comment 7 Dave Allan 2011-07-07 18:51:40 UTC
*** Bug 719284 has been marked as a duplicate of this bug. ***

Comment 8 Dave Allan 2011-07-13 00:44:55 UTC
(In reply to comment #6)
> IMO, we'd better add flag to state whether to discard snapshot files as part of
> undefining a domain, sliently removing the snapshots will make some user scream
> I guess, which means we need to introduce new API to do the work. Personally
> I'd create another bug instead.

I agree that we need an UndefineFlags API, but I think it can be done under this BZ.

Comment 9 Osier Yang 2011-07-21 02:47:44 UTC
commit 39babffb7348c794909be1ac50c7d84946507a63
Author: Osier Yang <jyang>

    undefine: Extend virsh undefine to support the new flag
    
    If the domain has managed save image, and --managed-save is
    not specified, then it fails with an error telling the user
    that a managed save image still exists.
    
    If the domain has managed save image, and --managed-save is
    specified, it invokes virDomainUndefineFlags. If
    virDomainUndefineFlags fails, then it tries to remove the managed
    save image using virDomainManagedSaveRemove first, with
    invoking virDomainUndefine following. (For compatibility between
    new virsh with this patch and older libvirt without this patch).
    
    Similarly if the domain has no managed save image. See the codes for
    detail.
    
    NOTE: Have not removing the codes checking if the domain is running
    in function "cmdUndefine", it will go along with qemu driver's fix
    (allow to undefine a running domain).

commit 39babffb7348c794909be1ac50c7d84946507a63
Author: Osier Yang <jyang>
Date:   Wed Jul 20 11:08:21 2011 +0800

    undefine: Implement undefineFlags for all other drivers

commit 67d33735eca33d5e50967e0dfaecee9746a7aca9
Author: Osier Yang <jyang>
Date:   Wed Jul 20 11:05:20 2011 +0800

    undefine: Implement internal API for libxl driver
    
    * src/libxl/libxl_driver.c: New callback for libxl_driver,
    new function libxlDomainUndefineFlags, and changes libxlDomainUndefine
    as a wrapper of libxlDomainUndefineFlags.

commit ae8e08aa28c2441cecd3077ee4251eee16d95cbb
Author: Osier Yang <jyang>
Date:   Wed Jul 20 11:04:15 2011 +0800

    undefine: Implement internal API for qemu driver
    
    * src/qemu/qemu_driver.c: New call back for qemu_driver,
    New function qemudDomainUndefineFlags, and changes on
    qemudDomainUndefine.

commit 0f8552a2fb93b816b11cee1b326c4ddd3c57fbe9
Author: Osier Yang <jyang>
Date:   Wed Jul 20 11:01:45 2011 +0800

    undefine: Wire up the remote protocol

commit b26a9fa9c226447e5f1153fb59eea4b92b848178
Author: Osier Yang <jyang>
Date:   Wed Jul 20 10:59:54 2011 +0800

    undefine: Define the new API
    
    This introduces a new API virDomainUndefineFlags to control the
    domain undefine process, as the existing API virDomainUndefine
    doesn't support flags.
    
    Currently only flag VIR_DOMAIN_UNDEFINE_MANAGED_SAVE is supported.
    If the domain has a managed save image, including
    VIR_DOMAIN_UNDEFINE_MANAGED_SAVE in @flags will also remove that
    file, and omitting the flag will cause undefine process to fail.
    
    This patch also changes the behavior of virDomainUndefine, if the
    domain has a managed save image, the undefine will be refused.

Patches are in upstream, move to POST.

Comment 11 yuping zhang 2011-08-02 08:04:42 UTC
Reproduce this issue with libvirt-0.9.3-8.el6  and no --managed-save option for undefine
# virsh start test
error: Failed to start domain test
error: operation failed: cannot restore domain 'test' uuid a4d37d98-ee58-7189-2816-750a4026f634 from a file which belongs to domain 'test' uuid 6170fecf-2b17-ba0b-837a-efb5d595f549

Verified this issue with :
kernel-2.6.32-172.el6.x86_64
qemu-kvm-0.12.1.2-2.172.el6.x86_64
libvirt-0.9.4-0rc1.2.el6.x86_64

Added --managed-save option for undefine.
Steps:
1.Create a guest
#virt-install -n test -r 1024 -f /dev/sdb -l
http://download.englab.nay.redhat.com/pub/rhel/rel-eng/RHEL6.1-20110413.1/6.1/Server/x86_64/os/
--debug
2.#virsh mananedsave test
3.# virsh undefine test
error: Refusing to undefine while domain managed save image exists
4.# virsh undefine test --managed-save
Domain test has been undefined
5.
#virt-install -n test -r 1024 -f /dev/sdb -l
http://download.englab.nay.redhat.com/pub/rhel/rel-eng/RHEL6.1-20110413.1/6.1/Server/x86_64/os/
--debug
  after install complete,click reboot button in guest.
6.The guest reboot successfully 

So change the status to VERIFIED.

Comment 12 Osier Yang 2011-11-14 08:40:32 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause
    libvirt doesn't provide an option of domain undefine for user to remove the managed state file, and thus if the user undefine a domain which has an managed state file left, and defines a new domain with the same name later,  it will fail when starting, as it sees the domain managed file with same name as domain exists, and it will try to restore from the managed state file. This is complete wrong.

Consequence
   Domain starting will fail if there is a managed state file which was of a previous domain with the same domain name.

Fix
   New API virDomainUndefineFlags was introduced with flags
support, the user can specify the flag (e.g. virsh undefine --managed-save), the managed state file will be removed when undefine. If the managed state file exists, but no flag specified to tell libvirt to remove it, libvirt will refuse undefining the domain with sensiable error.
    
Result
    There is option provided for user to choose to avoid the problem. Also if managed state file exists, but no option specified to tell libvirt to remove it, there will be an sensiable error, which will be enough to let the user known what he needs to do.

Comment 13 errata-xmlrpc 2011-12-06 11:05: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


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