[libvirt] [PATCH 3/4] conf: Convert virDomainChrSourceDefNew to return object

Marc Hartmayer mhartmay at linux.vnet.ibm.com
Mon Apr 9 14:51:23 UTC 2018


On Fri, Apr 06, 2018 at 06:53 PM +0200, John Ferlan <jferlan at redhat.com> wrote:
> Let's use object referencing to handle the ChrSourceDef. A subsequent
> patch then can allow the monConfig to take an extra reference before
> dropping the domain lock to then ensure nothing free's the memory that
> needs to be used.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/conf/domain_conf.c | 33 ++++++++++++++++++++++++++++++---
>  1 file changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index fd57364cd4..b4c5de8b33 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2260,8 +2260,10 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
>      return 0;
>  }
>

[…snip…]

> +
> +VIR_ONCE_GLOBAL_INIT(virDomainChrSourceDef);
> +
>  virDomainChrSourceDefPtr
>  virDomainChrSourceDefNew(virDomainXMLOptionPtr xmlopt)
>  {
>      virDomainChrSourceDefPtr def = NULL;
>
> -    if (VIR_ALLOC(def) < 0)
> +    if (virDomainChrSourceDefInitialize() < 0)
> +        return NULL;
> +
> +    if (!(def = virObjectNew(virDomainChrSourceDefClass)))
>          return NULL;
>
>      if (xmlopt && xmlopt->privateData.chrSourceNew &&
           !(def->privateData = xmlopt->privateData.chrSourceNew()))
           VIR_FREE(def);
           ^^^^^^^^^^^^^^
           Replace it with virDomainChrSourceDefFree(def) or virObjectUnref(def).

> --
> 2.13.6
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>

Otherwise, Reviewed-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>

--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294





More information about the libvir-list mailing list