Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-host.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 734f1a8..2f926d6 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -69,6 +69,84 @@ cmdCapabilities(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
/*
+ * "domcapabilities" command
+ */
+static const vshCmdInfo info_domcapabilities[] = {
+ {.name = "help",
+ .data = N_("domain capabilities")
+ },
+ {.name = "desc",
+ .data = N_("Returns capabilities of emulator with respect to host and
libvirt.")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_domcapabilities[] = {
+ {.name = "emulatorbin",
+ .type = VSH_OT_STRING,
+ .help = N_("path to emulator binary"),
+ },
+ {.name = "virttype",
+ .type = VSH_OT_STRING,
+ .help = N_("virtualization type (/domain/@type)"),
+ },
+ {.name = "machine",
+ .type = VSH_OT_STRING,
+ .help = N_("machine type (/domain/os/type/@machine)"),
+ },
+ {.name = "arch",
+ .type = VSH_OT_STRING,
+ .help = N_("domain architecture (/domain/os/type/@arch)"),
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
+{
+ bool ret = false;
+ char *caps;
+ const char *emulatorbin = NULL;
+ const char *machine = NULL;
+ const char *virttype = NULL;
+ const char *arch = NULL;
+ const unsigned int flags = 0; /* No flags so far */
+
+ if (vshCommandOptString(cmd, "emulatorbin", &emulatorbin) < 0) {
+ vshError(ctl, "%s", _("ble"));
+ goto cleanup;
+ }
+
+ if (vshCommandOptString(cmd, "virttype", &virttype) < 0) {
+ vshError(ctl, "%s", _("ble"));
+ goto cleanup;
+ }
+
+ if (vshCommandOptString(cmd, "machine", &machine) < 0) {
+ vshError(ctl, "%s", _("ble"));
+ goto cleanup;
+ }
+
+ if (vshCommandOptString(cmd, "arch", &arch) < 0) {
+ vshError(ctl, "%s", _("ble"));
+ goto cleanup;
+ }
+
+ caps = virConnectGetDomainCapabilities(ctl->conn, emulatorbin,
+ arch, machine, virttype, flags);
+ if (!caps) {
+ vshError(ctl, "%s", _("failed to get emulator
capabilities"));
+ goto cleanup;
+ }
+
+ vshPrint(ctl, "%s\n", caps);
+ ret = true;
+ cleanup:
+ VIR_FREE(caps);
+ return ret;
+}
+
+/*
* "freecell" command
*/
static const vshCmdInfo info_freecell[] = {
@@ -1131,6 +1209,12 @@ const vshCmdDef hostAndHypervisorCmds[] = {
.info = info_cpu_models,
.flags = 0
},
+ {.name = "domcapabilities",
+ .handler = cmdDomCapabilities,
+ .opts = opts_domcapabilities,
+ .info = info_domcapabilities,
+ .flags = 0
+ },
{.name = "freecell",
.handler = cmdFreecell,
.opts = opts_freecell,
--
1.8.5.5