]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add support for '--validate' option in define interface
authorKristina Hanicova <khanicov@redhat.com>
Fri, 20 Aug 2021 11:28:52 +0000 (13:28 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 20 Aug 2021 13:41:22 +0000 (15:41 +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-interface.c

index 0326a7d015a4a4ef1c8be20aa611eea360f9d2ce..bbdf8312f5b4893859bf6c2a0ca206c392a0cc30 100644 (file)
@@ -5523,10 +5523,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
index 07d5f50be33cadb2e8b09f793afa014cfd0faa00..46af45c97be999295f0850c72c8a1ada947b6eac 100644 (file)
@@ -523,6 +523,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}
 };
 
@@ -533,15 +537,19 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
     const char *from = NULL;
     bool ret = true;
     g_autofree char *buffer = NULL;
+    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);
 
     if (iface != NULL) {
         vshPrintExtra(ctl, _("Interface %s defined from %s\n"),