[libvirt] [PATCHv2 14/26] snapshot: prevent stranding snapshot data on domain destruction

Eric Blake eblake at redhat.com
Fri Aug 19 14:05:09 UTC 2011


On 08/15/2011 05:33 PM, Eric Blake wrote:
> Just as leaving managed save metadata behind can cause problems
> when creating a new domain that happens to collide with the name
> of the just-deleted domain, the same is true of leaving any
> snapshot metadata behind.  For safety sake, extend the semantic
> change of commit b26a9fa9 to also cover snapshot metadata as a
> reason to reject losing the last reference to a domain (undefine
> on an inactive, or shutdown/destroy on a transient).  The caller
> must first take care of snapshots, possible via the existing
> virDomainSnapshotDelete.
>
> @@ -4726,10 +4745,17 @@ qemuDomainUndefineFlags(virDomainPtr dom,
>           goto cleanup;
>       }
>
> +    /* XXX We should allow undefine to convert running persistent into
> +     * transient domain, rather than reject things here.  */
>       if (virDomainObjIsActive(vm)) {
>           qemuReportError(VIR_ERR_OPERATION_INVALID,
>                           "%s", _("cannot delete active domain"));
>           goto cleanup;
> +    } else if ((nsnapshots = virDomainSnapshotObjListNum(&vm->snapshots))) {
> +        qemuReportError(VIR_ERR_OPERATION_INVALID,
> +                        _("cannot delete inactive domain with %d snapshots"),
> +                        nsnapshots);
> +        goto cleanup;
>       }

Another rebase conflict, thanks to Osier's recent series:

diff --cc src/qemu/qemu_driver.c
index 98380fd,ca07352..0000000
--- i/src/qemu/qemu_driver.c
+++ w/src/qemu/qemu_driver.c
@@@ -4726,6 -4745,19 +4745,14 @@@ qemuDomainUndefineFlags(virDomainPtr do
           goto cleanup;
       }

  -    /* XXX We should allow undefine to convert running persistent into
  -     * transient domain, rather than reject things here.  */
  -    if (virDomainObjIsActive(vm)) {
  -        qemuReportError(VIR_ERR_OPERATION_INVALID,
  -                        "%s", _("cannot delete active domain"));
  -        goto cleanup;
  -    } else if ((nsnapshots = 
virDomainSnapshotObjListNum(&vm->snapshots, 0))) {
++    if (!virDomainObjIsActive(vm) &&
++        (nsnapshots = virDomainSnapshotObjListNum(&vm->snapshots, 0))) {
+         qemuReportError(VIR_ERR_OPERATION_INVALID,
+                         _("cannot delete inactive domain with %d 
snapshots"),
+                         nsnapshots);
+         goto cleanup;
+     }
+
       if (!vm->persistent) {
           qemuReportError(VIR_ERR_OPERATION_INVALID,
                           "%s", _("cannot undefine transient domain"));

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




More information about the libvir-list mailing list