Re: [PATCH 2/4] qemu: Refactor managed save functions to use domain lookup helpers

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

 



On 12/11/2012 11:48 AM, Peter Krempa wrote:
> ---
>  src/qemu/qemu_driver.c | 54 +++++++++++---------------------------------------
>  1 file changed, 12 insertions(+), 42 deletions(-)

Nice reduction in size. However, you need a v2...

> @@ -3323,50 +3316,28 @@ cleanup:
>  static int
>  qemuDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
>  {
> -    virQEMUDriverPtr driver = dom->conn->privateData;
>      virDomainObjPtr vm = NULL;
> -    int ret = -1;
> 
>      virCheckFlags(0, -1);
> 
> -    qemuDriverLock(driver);
> -    vm = virDomainFindByUUID(&driver->domains, dom->uuid);
> -    if (!vm) {
> -        char uuidstr[VIR_UUID_STRING_BUFLEN];
> -        virUUIDFormat(dom->uuid, uuidstr);
> -        virReportError(VIR_ERR_NO_DOMAIN,
> -                       _("no domain with matching uuid '%s'"), uuidstr);
> -        goto cleanup;
> -    }
> -
> -    ret = vm->hasManagedSave;
> +    if (!(vm = qemuDomObjFromDomain(dom)))
> +        return -1;
> 
> -cleanup:
> -    if (vm)
> -        virDomainObjUnlock(vm);
> -    qemuDriverUnlock(driver);
> -    return ret;
> +    return vm->hasManagedSave;
>  }

Ouch.  This leaves vm locked on exit.  It needs to look more like:

if !(vm = qemuDomObjFromDomain(dom)))
    return -1;
ret = vm->hasManagedSave;
virDomainObjUnlock(vm);
retun ret;

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]