Re: [PATCH 5/5] conf: replace validation with variables passed to virXMLParse()

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

 



On a %A in %Y, Kristina Hanicova wrote:
> virXMLParse() now allows to validate xml against schema directly,

s/allows to validate/allows validating/

> eliminating the need to do it individually in each function.
> 
> Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
> ---
>  src/conf/backup_conf.c     | 13 ++-----------
>  src/conf/checkpoint_conf.c | 12 ++----------
>  src/conf/snapshot_conf.c   | 15 ++-------------
>  3 files changed, 6 insertions(+), 34 deletions(-)
> 
> diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c
> index 9307357d84..8e378a5d26 100644
> --- a/src/conf/backup_conf.c
> +++ b/src/conf/backup_conf.c
> @@ -281,7 +281,8 @@ virDomainBackupDefParseString(const char *xmlStr,
>      g_autoptr(xmlDoc) xml = NULL;
>      int keepBlanksDefault = xmlKeepBlanksDefault(0);
>  
> -    if ((xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"), NULL, false))) {
> +    if ((xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"), "domainbackup.rng",
> +                           !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL)))) {
>          xmlKeepBlanksDefault(keepBlanksDefault);
>          ret = virDomainBackupDefParseNode(xml, xmlDocGetRootElement(xml),
>                                            xmlopt, flags);
> @@ -306,16 +307,6 @@ virDomainBackupDefParseNode(xmlDocPtr xml,
>          return NULL;
>      }
>  
> -    if (!(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL)) {
> -        if (!(schema = virFileFindResource("domainbackup.rng",
> -                                           abs_top_srcdir "/docs/schemas",
> -                                           PKGDATADIR "/schemas")))
> -            return NULL;
> -
> -        if (virXMLValidateAgainstSchema(schema, xml) < 0)
> -            return NULL;
> -    }
> -
>      if (!(ctxt = virXMLXPathContextNew(xml)))
>          return NULL;
>  

The declaration of 'schema' also needs to go, otherwise clang complains:
../src/conf/backup_conf.c:303:22: error: unused variable 'schema'
[-Werror,-Wunused-variable]
    g_autofree char *schema = NULL;
                     ^
1 error generated.

> diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
> index dd0e6035fa..ccb01b87f9 100644
> --- a/src/conf/checkpoint_conf.c
> +++ b/src/conf/checkpoint_conf.c
> @@ -200,15 +200,6 @@ virDomainCheckpointDefParseNode(xmlDocPtr xml,
>          return NULL;
>      }
>  
> -    /* This is a new enough API to make schema validation unconditional */
> -    schema = virFileFindResource("domaincheckpoint.rng",
> -                                 abs_top_srcdir "/docs/schemas",
> -                                 PKGDATADIR "/schemas");
> -    if (!schema)
> -        return NULL;
> -    if (virXMLValidateAgainstSchema(schema, xml) < 0)
> -        return NULL;
> -

same here.

>      if (!(ctxt = virXMLXPathContextNew(xml)))
>          return NULL;
>  

For the whole series:
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano




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

  Powered by Linux