]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add support for '--validate' option in create nwfilter-binding
authorKristina Hanicova <khanicov@redhat.com>
Thu, 26 Aug 2021 12:32:35 +0000 (14:32 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 6 Sep 2021 15:08:59 +0000 (17:08 +0200)
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>
docs/manpages/virsh.rst
tools/virsh-nwfilter.c

index c699b198fb42625162c9f684413fe886209ec93c..9561b3f59d89fd220e2a812b1af8f3345b34caf0 100644 (file)
@@ -7588,7 +7588,7 @@ nwfilter-binding-create
 
 ::
 
-   nwfilter-binding-create xmlfile
+   nwfilter-binding-create xmlfile [--validate]
 
 Associate a network port with a network filter. The network filter backend
 will immediately attempt to instantiate the filter rules on the port. This
@@ -7599,6 +7599,9 @@ command to define a filter for a network port and then starting the guest
 afterwards may prevent the guest from starting if it attempts to use the
 network port and finds a filter already defined.
 
+Optionally, the format of the input XML file can be validated against an
+internal RNG schema with *--validate*.
+
 
 nwfilter-binding-delete
 -----------------------
index e062aa16491e00c3606402df2988bffbe15591df..77f211d031c3bf751a9fd5bf523b323e01d85054 100644 (file)
@@ -503,6 +503,10 @@ static const vshCmdInfo info_nwfilter_binding_create[] = {
 static const vshCmdOptDef opts_nwfilter_binding_create[] = {
     VIRSH_COMMON_OPT_FILE(N_("file containing an XML network "
                              "filter binding description")),
+    {.name = "validate",
+     .type = VSH_OT_BOOL,
+     .help = N_("validate the XML against the schema")
+    },
     {.name = NULL}
 };
 
@@ -513,15 +517,19 @@ cmdNWFilterBindingCreate(vshControl *ctl, const vshCmd *cmd)
     const char *from = NULL;
     bool ret = true;
     char *buffer;
+    unsigned int flags = 0;
     virshControl *priv = ctl->privData;
 
     if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
         return false;
 
+    if (vshCommandOptBool(cmd, "validate"))
+        flags |= VIR_NWFILTER_BINDING_CREATE_VALIDATE;
+
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    binding = virNWFilterBindingCreateXML(priv->conn, buffer, 0);
+    binding = virNWFilterBindingCreateXML(priv->conn, buffer, flags);
     VIR_FREE(buffer);
 
     if (binding != NULL) {