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).
---

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.

Thanks for the reviewing, pushed the whole series with the small nits fixed,
([PATCH v4 5/6] is pushed as is).
Regards
Osier