[PATCH v2 3/4] virsh: add support for '--validate' option in define interface

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

 



Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 docs/manpages/virsh.rst |  5 +++--
 tools/virsh-interface.c | 10 +++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index 20936994ce..2efb15fc1c 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -5531,10 +5531,11 @@ iface-define
 
 ::
 
-   iface-define file
+   iface-define file [--validate]
 
 Define an inactive persistent physical host interface or modify an existing
-persistent one from the XML *file*.
+persistent one from the XML *file*. Optionally, the format of the input XML
+file can be validated against an internal RNG schema with *--validate*.
 
 
 iface-destroy
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 41acae5dcb..f72d40baab 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -525,6 +525,10 @@ static const vshCmdInfo info_interface_define[] = {
 
 static const vshCmdOptDef opts_interface_define[] = {
     VIRSH_COMMON_OPT_FILE(N_("file containing an XML interface description")),
+    {.name = "validate",
+     .type = VSH_OT_BOOL,
+     .help = N_("validate the XML against the schema")
+    },
     {.name = NULL}
 };
 
@@ -535,15 +539,19 @@ cmdInterfaceDefine(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_INTERFACE_DEFINE_VALIDATE;
+
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    iface = virInterfaceDefineXML(priv->conn, buffer, 0);
+    iface = virInterfaceDefineXML(priv->conn, buffer, flags);
     VIR_FREE(buffer);
 
     if (iface != NULL) {
-- 
2.31.1




[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