Bug 697742
| Summary: | libvirt: remove managedsave data when a domain is undefined | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | zhe peng <zpeng> |
| Component: | libvirt | Assignee: | Osier Yang <jyang> |
| Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 6.1 | CC: | dallan, dyasny, dyuan, eblake, mzhan, yupzhang |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| 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.
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2011-12-06 11:05: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: | |||
|
Description
zhe peng
2011-04-19 05:28:47 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. Sounds like a libvirt bug. Libvirt should be removing the managedsave data when a domain is undefined. patch posted upstream: https://www.redhat.com/archives/libvir-list/2011-April/msg00957.html 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. 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. *** Bug 719284 has been marked as a duplicate of this bug. *** (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. 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.
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.
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.
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 |