::
- capabilities
+ capabilities [--xpath EXPRESSION] [--wrap]
Print an XML document describing the capabilities of the hypervisor
we are currently connected to. This includes a section on the host
The XML also show the NUMA topology information if available.
+If the **--xpath** argument provides an XPath expression, it will be
+evaluated against the output XML and only those matching nodes will
+be printed. The default behaviour is to print each matching node as
+a standalone document, however, for ease of additional processing,
+the **--wrap** argument will cause the matching node to be wrapped
+in a common root node.
+
domcapabilities
---------------
#include "virstring.h"
#include "virfile.h"
#include "virenum.h"
+#include "virsh-util.h"
/*
* "capabilities" command
{.name = "desc",
.data = N_("Returns capabilities of hypervisor/driver.")
},
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_capabilities[] = {
+ {.name = "xpath",
+ .type = VSH_OT_STRING,
+ .flags = VSH_OFLAG_REQ_OPT,
+ .completer = virshCompleteEmpty,
+ .help = N_("xpath expression to filter the XML document")
+ },
+ {.name = "wrap",
+ .type = VSH_OT_BOOL,
+ .help = N_("wrap xpath results in an common root element"),
+ },
{.name = NULL}
};
static bool
-cmdCapabilities(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
+cmdCapabilities(vshControl *ctl, const vshCmd *cmd)
{
g_autofree char *caps = NULL;
virshControl *priv = ctl->privData;
+ bool wrap = vshCommandOptBool(cmd, "wrap");
+ const char *xpath = NULL;
+
+ if (vshCommandOptStringQuiet(ctl, cmd, "xpath", &xpath) < 0)
+ return false;
if ((caps = virConnectGetCapabilities(priv->conn)) == NULL) {
vshError(ctl, "%s", _("failed to get capabilities"));
return false;
}
- vshPrint(ctl, "%s\n", caps);
- return true;
+ return virshDumpXML(ctl, caps, "capabilities", xpath, wrap);
}
/*
},
{.name = "capabilities",
.handler = cmdCapabilities,
- .opts = NULL,
+ .opts = opts_capabilities,
.info = info_capabilities,
.flags = 0
},