[libvirt] [PATCH 4/5] libxl: Check for libxl_ctx_alloc failure

Osier Yang jyang at redhat.com
Wed Jan 16 04:54:49 UTC 2013


On 2013年01月16日 07:15, Jim Fehlig wrote:
> ---
>   src/libxl/libxl_driver.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
> index 61ceae1..baa05e8 100644
> --- a/src/libxl/libxl_driver.c
> +++ b/src/libxl/libxl_driver.c
> @@ -269,7 +269,12 @@ libxlDomainObjPrivateAlloc(void)
>       if (VIR_ALLOC(priv)<  0)
>           return NULL;
>
> -    libxl_ctx_alloc(&priv->ctx, LIBXL_VERSION, 0, libxl_driver->logger);
> +    if (libxl_ctx_alloc(&priv->ctx, LIBXL_VERSION, 0, libxl_driver->logger)) {
> +        VIR_ERROR(_("Failed libxl context initialization"));
> +        VIR_FREE(priv);
> +        return NULL;
> +    }

Checked the codes of libxl_ctx_alloc, which returns greater than 0
on failure. So ACK.

> +
>       libxl_osevent_register_hooks(priv->ctx,&libxl_event_callbacks, priv);
>
>       return priv;




More information about the libvir-list mailing list