Re: [PATCH 1/3] snapshot: fix logic bug in qemu undefine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 21, 2011 at 01:08:50PM -0600, Eric Blake wrote:
> Commit 19f8c98 introduced VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA,
> with the intent that omitting the flag makes undefine fail, and
> including the flag deletes metadata.  But it used the wrong logic.
> Also, hoist the transient domain sooner, so that we don't
> accidentally remove metadata of a transient domain.
> 
> * src/qemu/qemu_driver.c (qemuDomainUndefineFlags): Check correct
> flag value.
> ---
>  src/qemu/qemu_driver.c |   16 ++++++++--------
>  1 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 67c43ab..4a24019 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -5095,7 +5095,7 @@ cleanup:
> 
>  static int
>  qemuDomainUndefineFlags(virDomainPtr dom,
> -                         unsigned int flags)
> +                        unsigned int flags)
>  {
>      struct qemud_driver *driver = dom->conn->privateData;
>      virDomainObjPtr vm;
> @@ -5118,11 +5118,17 @@ qemuDomainUndefineFlags(virDomainPtr dom,
>          goto cleanup;
>      }
> 
> +    if (!vm->persistent) {
> +        qemuReportError(VIR_ERR_OPERATION_INVALID,
> +                        "%s", _("cannot undefine transient domain"));
> +        goto cleanup;
> +    }
> +
>      if (!virDomainObjIsActive(vm) &&
>          (nsnapshots = virDomainSnapshotObjListNum(&vm->snapshots, 0))) {
>          struct snap_remove rem;
> 
> -        if (flags & VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA) {
> +        if (!(flags & VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA)) {
>              qemuReportError(VIR_ERR_OPERATION_INVALID,
>                              _("cannot delete inactive domain with %d "
>                                "snapshots"),
> @@ -5139,12 +5145,6 @@ qemuDomainUndefineFlags(virDomainPtr dom,
>              goto cleanup;
>      }
> 
> -    if (!vm->persistent) {
> -        qemuReportError(VIR_ERR_OPERATION_INVALID,
> -                        "%s", _("cannot undefine transient domain"));
> -        goto cleanup;
> -    }
> -
>      name = qemuDomainManagedSavePath(driver, vm);
>      if (name == NULL)
>          goto cleanup;

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]