Re: [libvirt] [PATCH 2/2] Fix leak in PCI hostdev hot-unplug

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

 



On Thu, Sep 17, 2009 at 04:03:00PM +0100, Mark McLoughlin wrote:
> * src/qemu_driver.c: sync the hostdev hot-unplug code with the disk/net
>   code.
> ---
>  src/qemu_driver.c |   20 +++++++++++++-------
>  1 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu_driver.c b/src/qemu_driver.c
> index de31581..2ddcdc0 100644
> --- a/src/qemu_driver.c
> +++ b/src/qemu_driver.c
> @@ -6206,14 +6206,20 @@ static int
> qemudDomainDetachHostPciDevice(virConnectPtr conn,
>          pciFreeDevice(conn, pci);
>      }
>  
> -    if (i != --vm->def->nhostdevs)
> -        memmove(&vm->def->hostdevs[i],
> -                &vm->def->hostdevs[i+1],
> -                sizeof(*vm->def->hostdevs) * (vm->def->nhostdevs-i));
> -    if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
> -        virReportOOMError(conn);
> -        ret = -1;
> +    if (vm->def->nhostdevs > 1) {
> +        memmove(vm->def->hostdevs + i,
> +                vm->def->hostdevs + i + 1,
> +                sizeof(*vm->def->hostdevs) *
> +                (vm->def->nhostdevs - (i + 1)));
> +        vm->def->nhostdevs--;
> +        if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
> +            /* ignore, harmless */
> +        }
> +    } else {
> +        VIR_FREE(vm->def->hostdevs);
> +        vm->def->nhostdevs = 0;
>      }
> +    virDomainHostdevDefFree(detach);
>  
>      return ret;
>  }
> -- 

ACK


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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