::
- net-port-create network file
+ net-port-create network file [--validate]
Allocate a new network port reserving resources based on the
port description.
+Optionally, the format of the input XML file can be validated against an
+internal RNG schema with *--validate*.
net-port-dumpxml
static const vshCmdOptDef opts_network_port_create[] = {
VIRSH_COMMON_OPT_NETWORK_FULL(VIR_CONNECT_LIST_NETWORKS_ACTIVE),
VIRSH_COMMON_OPT_FILE(N_("file containing an XML network port description")),
+ {.name = "validate",
+ .type = VSH_OT_BOOL,
+ .help = N_("validate the XML against the schema")
+ },
{.name = NULL}
};
bool ret = false;
char *buffer = NULL;
virNetworkPtr network = NULL;
+ unsigned int flags = 0;
network = virshCommandOptNetwork(ctl, cmd, NULL);
if (network == NULL)
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
goto cleanup;
+ if (vshCommandOptBool(cmd, "validate"))
+ flags |= VIR_NETWORK_PORT_CREATE_VALIDATE;
+
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
vshSaveLibvirtError();
goto cleanup;
}
- port = virNetworkPortCreateXML(network, buffer, 0);
+ port = virNetworkPortCreateXML(network, buffer, flags);
if (port != NULL) {
char uuidstr[VIR_UUID_STRING_BUFLEN];