mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: add support for '--validate' option in define interface
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>
This commit is contained in:
committed by
Ján Tomko
parent
4b4bd278a4
commit
d46a0b0e96
@@ -5523,10 +5523,11 @@ iface-define
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
iface-define file
|
iface-define file [--validate]
|
||||||
|
|
||||||
Define an inactive persistent physical host interface or modify an existing
|
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
|
iface-destroy
|
||||||
|
|||||||
@@ -523,6 +523,10 @@ static const vshCmdInfo info_interface_define[] = {
|
|||||||
|
|
||||||
static const vshCmdOptDef opts_interface_define[] = {
|
static const vshCmdOptDef opts_interface_define[] = {
|
||||||
VIRSH_COMMON_OPT_FILE(N_("file containing an XML interface description")),
|
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}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -533,15 +537,19 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
|
|||||||
const char *from = NULL;
|
const char *from = NULL;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
g_autofree char *buffer = NULL;
|
g_autofree char *buffer = NULL;
|
||||||
|
unsigned int flags = 0;
|
||||||
virshControl *priv = ctl->privData;
|
virshControl *priv = ctl->privData;
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (vshCommandOptBool(cmd, "validate"))
|
||||||
|
flags |= VIR_INTERFACE_DEFINE_VALIDATE;
|
||||||
|
|
||||||
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
|
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
iface = virInterfaceDefineXML(priv->conn, buffer, 0);
|
iface = virInterfaceDefineXML(priv->conn, buffer, flags);
|
||||||
|
|
||||||
if (iface != NULL) {
|
if (iface != NULL) {
|
||||||
vshPrintExtra(ctl, _("Interface %s defined from %s\n"),
|
vshPrintExtra(ctl, _("Interface %s defined from %s\n"),
|
||||||
|
|||||||
Reference in New Issue
Block a user