[libvirt] [PATCH v3 2/3] Add support for schema validation when passing in XML

Jiri Denemark jdenemar at redhat.com
Thu Jan 15 09:33:26 UTC 2015


On Tue, Jan 13, 2015 at 17:00:15 +0000, Daniel Berrange wrote:
> The virDomainDefineXMLFlags and virDomainCreateXML APIs both
> gain new flags allowing them to be told to validate XML.
> This updates all the drivers to turn on validation in the
> XML parser when the flags are set
...
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b316b4b..420f94b 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
...
> @@ -12647,6 +12648,16 @@ virDomainDefParseXML(xmlDocPtr xml,
>      bool usb_master = false;
>      bool primaryVideo = false;
>  
> +    if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE) {
> +        char *schema = virFileFindResource("domain.rng",
> +                                           "docs/schemas",
> +                                           PKGDATADIR "/schemas");
> +        if (!schema)
> +            return NULL;
> +        if (virXMLValidateAgainstSchema(schema, xml) < 0)
> +            return NULL;

This will leak schema.

> +    }
> +
>      if (VIR_ALLOC(def) < 0)
>          return NULL;
>  
...

ACK with the memory leak fixed.

Jirka




More information about the libvir-list mailing list