conf: virnwfilterbindingdef: add validation against schema in create

We need to validate the XML against schema if option '--validate'
was passed to the virsh command. This patch also includes
propagation of flags into the virNWFilterBindingDefParse().

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Kristina Hanicova 2021-08-26 14:32:33 +02:00 committed by Ján Tomko
parent e21448e830
commit eabb73eba2
3 changed files with 12 additions and 7 deletions

View File

@ -178,12 +178,15 @@ virNWFilterBindingDefParseNode(xmlDocPtr xml,
static virNWFilterBindingDef *
virNWFilterBindingDefParse(const char *xmlStr,
const char *filename)
const char *filename,
unsigned int flags)
{
virNWFilterBindingDef *def = NULL;
g_autoptr(xmlDoc) xml = NULL;
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_definition)"), NULL, false))) {
if ((xml = virXMLParse(filename, xmlStr, _("(nwfilterbinding_definition)"),
"nwfilterbinding.rng",
flags & VIR_NWFILTER_BINDING_CREATE_VALIDATE))) {
def = virNWFilterBindingDefParseNode(xml, xmlDocGetRootElement(xml));
}
@ -192,16 +195,17 @@ virNWFilterBindingDefParse(const char *xmlStr,
virNWFilterBindingDef *
virNWFilterBindingDefParseString(const char *xmlStr)
virNWFilterBindingDefParseString(const char *xmlStr,
unsigned int flags)
{
return virNWFilterBindingDefParse(xmlStr, NULL);
return virNWFilterBindingDefParse(xmlStr, NULL, flags);
}
virNWFilterBindingDef *
virNWFilterBindingDefParseFile(const char *filename)
{
return virNWFilterBindingDefParse(NULL, filename);
return virNWFilterBindingDefParse(NULL, filename, 0);
}

View File

@ -51,7 +51,8 @@ virNWFilterBindingDefParseNode(xmlDocPtr xml,
xmlNodePtr root);
virNWFilterBindingDef *
virNWFilterBindingDefParseString(const char *xml);
virNWFilterBindingDefParseString(const char *xml,
unsigned int flags);
virNWFilterBindingDef *
virNWFilterBindingDefParseFile(const char *filename);

View File

@ -745,7 +745,7 @@ nwfilterBindingCreateXML(virConnectPtr conn,
return NULL;
}
def = virNWFilterBindingDefParseString(xml);
def = virNWFilterBindingDefParseString(xml, 0);
if (!def)
return NULL;