mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
virsh: add support for '--validate' option in create nwfilter-binding
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:
parent
39f835621a
commit
8f8eeb3750
@ -7588,7 +7588,7 @@ nwfilter-binding-create
|
||||
|
||||
::
|
||||
|
||||
nwfilter-binding-create xmlfile
|
||||
nwfilter-binding-create xmlfile [--validate]
|
||||
|
||||
Associate a network port with a network filter. The network filter backend
|
||||
will immediately attempt to instantiate the filter rules on the port. This
|
||||
@ -7599,6 +7599,9 @@ command to define a filter for a network port and then starting the guest
|
||||
afterwards may prevent the guest from starting if it attempts to use the
|
||||
network port and finds a filter already defined.
|
||||
|
||||
Optionally, the format of the input XML file can be validated against an
|
||||
internal RNG schema with *--validate*.
|
||||
|
||||
|
||||
nwfilter-binding-delete
|
||||
-----------------------
|
||||
|
@ -503,6 +503,10 @@ static const vshCmdInfo info_nwfilter_binding_create[] = {
|
||||
static const vshCmdOptDef opts_nwfilter_binding_create[] = {
|
||||
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network "
|
||||
"filter binding description")),
|
||||
{.name = "validate",
|
||||
.type = VSH_OT_BOOL,
|
||||
.help = N_("validate the XML against the schema")
|
||||
},
|
||||
{.name = NULL}
|
||||
};
|
||||
|
||||
@ -513,15 +517,19 @@ cmdNWFilterBindingCreate(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_NWFILTER_BINDING_CREATE_VALIDATE;
|
||||
|
||||
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
|
||||
return false;
|
||||
|
||||
binding = virNWFilterBindingCreateXML(priv->conn, buffer, 0);
|
||||
binding = virNWFilterBindingCreateXML(priv->conn, buffer, flags);
|
||||
VIR_FREE(buffer);
|
||||
|
||||
if (binding != NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user