::
- nodedev-create FILE
+ nodedev-create FILE [--validate]
Create a device on the host node that can then be assigned to virtual
machines. Normally, libvirt is able to automatically determine which
host hardware that libvirt did not automatically detect. *file*
contains xml for a top-level <device> description of a node device.
+If *--validate* is specified, validates the format of the XML document against
+an internal RNG schema.
+
nodedev-destroy
---------------
::
- nodedev-define FILE
+ nodedev-define FILE [--validate]
Define an inactive persistent device or modify an existing persistent one from
the XML *FILE*.
+If *--validate* is specified, validates the format of the XML document against
+an internal RNG schema.
+
nodedev-undefine
----------------
int virNodeDeviceReAttach (virNodeDevicePtr dev);
int virNodeDeviceReset (virNodeDevicePtr dev);
+/**
+ * virNodeDeviceCreateXMLFlags:
+ *
+ * Since: 8.10.0
+ */
+typedef enum {
+ VIR_NODE_DEVICE_CREATE_XML_VALIDATE = 1 << 0, /* Validate the XML document against schema (Since: 8.10.0) */
+} virNodeDeviceCreateXMLFlags;
+
virNodeDevicePtr virNodeDeviceCreateXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
int virNodeDeviceDestroy (virNodeDevicePtr dev);
+
+/**
+ * virNodeDeviceDefineXMLFlags:
+ *
+ * Since: 8.10.0
+ */
+typedef enum {
+ VIR_NODE_DEVICE_DEFINE_XML_VALIDATE = 1 << 0, /* Validate the XML document against schema (Since: 8.10.0) */
+} virNodeDeviceDefineXMLFlags;
+
virNodeDevicePtr virNodeDeviceDefineXML(virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
* virNodeDeviceCreateXML:
* @conn: pointer to the hypervisor connection
* @xmlDesc: string containing an XML description of the device to be created
- * @flags: extra flags; not used yet, so callers should always pass 0
+ * @flags: bitwise-OR of supported virNodeDeviceCreateXMLFlags
*
* Create a new device on the VM host machine, for example, virtual
* HBAs created using vport_create.
* virNodeDeviceDefineXML:
* @conn: pointer to the hypervisor connection
* @xmlDesc: string containing an XML description of the device to be defined
- * @flags: extra flags; not used yet, so callers should always pass 0
+ * @flags: bitwise-OR of supported virNodeDeviceDefineXMLFlags
*
* Define a new device on the VM host machine, for example, a mediated device
*
static const vshCmdOptDef opts_node_device_create[] = {
VIRSH_COMMON_OPT_FILE(N_("file containing an XML description "
"of the device")),
+ {.name = "validate",
+ .type = VSH_OT_BOOL,
+ .help = N_("validate the XML against the schema")
+ },
{.name = NULL}
};
const char *from = NULL;
g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
+ unsigned int flags = 0;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
return false;
- if (!(dev = virNodeDeviceCreateXML(priv->conn, buffer, 0))) {
+ if (vshCommandOptBool(cmd, "validate"))
+ flags |= VIR_NODE_DEVICE_CREATE_XML_VALIDATE;
+
+ if (!(dev = virNodeDeviceCreateXML(priv->conn, buffer, flags))) {
vshError(ctl, _("Failed to create node device from %s"), from);
return false;
}
static const vshCmdOptDef opts_node_device_define[] = {
VIRSH_COMMON_OPT_FILE(N_("file containing an XML description "
"of the device")),
+ {.name = "validate",
+ .type = VSH_OT_BOOL,
+ .help = N_("validate the XML against the schema")
+ },
{.name = NULL}
};
const char *from = NULL;
g_autofree char *buffer = NULL;
virshControl *priv = ctl->privData;
+ unsigned int flags = 0;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
return false;
- if (!(dev = virNodeDeviceDefineXML(priv->conn, buffer, 0))) {
+ if (vshCommandOptBool(cmd, "validate"))
+ flags |= VIR_NODE_DEVICE_DEFINE_XML_VALIDATE;
+
+ if (!(dev = virNodeDeviceDefineXML(priv->conn, buffer, flags))) {
vshError(ctl, _("Failed to define node device from '%s'"), from);
return false;
}