On 07/19/2011 09:57 AM, Osier Yang wrote:
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).
---
tools/virsh.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
tools/virsh.pod | 14 ++++++++++--
2 files changed, 71 insertions(+), 4 deletions(-)
+ } else {
+ rc = virDomainUndefineFlags(dom, flags);
+
+ /* It might fail for virDomainUndefineFlags is not
s/for/when/
+ * supported on older libvirt, try to undefine the
+ * domain with combo virDomainManagedSaveRemove and
+ * virDomainUndefine.
+ */
+ if (rc< 0) {
+ if (last_error->code != VIR_ERR_NO_SUPPORT) {
+ virshReportError(ctl);
+ goto end;
+ } else {
+ virFreeError(last_error);
+ last_error = NULL;
+ }
+
+ if (has_managed_save&&
s/has_managed_save/has_managed_save == 1/
Your earlier changes mean that you can now get here even while
has_managed_save == -1 because the hypervisors lacks managed save
support altogether, in which case, the virDomainManagedSaveRemove will
also fail for unsupported, but the plain undefine is safe in that case.
ACK with those changes.
--
Eric Blake eblake@xxxxxxxxxx +1-801-349-2682
Libvirt virtualization library http://libvirt.org
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list