Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
docs/manpages/virsh.rst | 4 +++-
tools/virsh-network.c | 13 ++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index ce98283ae3..48d6ab54df 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -5189,13 +5189,15 @@ net-create
::
- net-create file
+ net-create file [--validate]
Create a transient (temporary) virtual network from an
XML *file* and instantiate (start) the network.
See the documentation at `https://libvirt.org/formatnetwork.html
<
https://libvirt.org/formatnetwork.html>`__
to get a description of the XML network format used by libvirt.
+Optionally, the format of the input XML file can be validated against an
+internal RNG schema with *--validate*.
net-define
----------
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index a8f7f46905..37c19b663b 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -197,6 +197,10 @@ static const vshCmdInfo info_network_create[] = {
static const vshCmdOptDef opts_network_create[] = {
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network description")),
+ {.name = "validate",
+ .type = VSH_OT_BOOL,
+ .help = N_("validate the XML against the schema")
+ },
{.name = NULL}
};
@@ -207,15 +211,22 @@ cmdNetworkCreate(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_NETWORK_CREATE_VALIDATE;
+
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
return false;
- network = virNetworkCreateXML(priv->conn, buffer);
+ if (flags)
+ network = virNetworkCreateXMLFlags(priv->conn, buffer, flags);
+ else
+ network = virNetworkCreateXML(priv->conn, buffer);
if (network != NULL) {
vshPrintExtra(ctl, _("Network %s created from %s\n"),
--
2.31.1