]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: add support for '--validate' option in define storage pool
authorKristina Hanicova <khanicov@redhat.com>
Tue, 24 Aug 2021 14:51:11 +0000 (16:51 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 25 Aug 2021 07:57:58 +0000 (09:57 +0200)
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/manpages/virsh.rst
tools/virsh-pool.c

index 850a862fd9bc768aef4a9956884f9d5f40ea1bd0..2204bed3bb9e638cfb2752eee9862553d0de09ce 100644 (file)
@@ -5958,10 +5958,12 @@ pool-define
 
 ::
 
-   pool-define file
+   pool-define file [--validate]
 
 Define an inactive persistent storage pool or modify an existing persistent one
 from the XML *file*.
+Optionally, the format of the input XML file can be validated against an
+internal RNG schema with *--validate*.
 
 
 pool-define-as
index f0ee95bdf8142ee3c5c8123289e5514567c15aad..1a2ab8cc53c18341b6cbb742ef15f71f6a789509 100644 (file)
@@ -520,7 +520,10 @@ static const vshCmdInfo info_pool_define[] = {
 
 static const vshCmdOptDef opts_pool_define[] = {
     VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description")),
-
+    {.name = "validate",
+     .type = VSH_OT_BOOL,
+     .help = N_("validate the XML against the schema")
+    },
     {.name = NULL}
 };
 
@@ -531,15 +534,19 @@ cmdPoolDefine(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_STORAGE_POOL_DEFINE_VALIDATE;
+
     if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
         return false;
 
-    pool = virStoragePoolDefineXML(priv->conn, buffer, 0);
+    pool = virStoragePoolDefineXML(priv->conn, buffer, flags);
 
     if (pool != NULL) {
         vshPrintExtra(ctl, _("Pool %s defined from %s\n"),