summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2023-04-14 16:06:02 +0200
committerMichal Privoznik <mprivozn@redhat.com>2023-04-18 09:06:08 +0200
commit98d5b07f6d467675cd40d2805b640937f122970f (patch)
tree18a36a2b798d4ba18733c56864836f5b1c8793a1 /tools
parent332385aa7ed81ed5c6cc42e41071bca06f607a2a (diff)
downloadlibvirt-98d5b07f6d467675cd40d2805b640937f122970f.tar.gz
virsh: Introduce --xpath and --wrap to domcapabilities
Similarly to dumpxml, let's have --xpath and --wrap to the 'domcapabilities' command since users might be interested only in a subset of domcapabilities XML. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/virsh-host.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 1504eab0f1..0bda327cae 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -112,6 +112,16 @@ static const vshCmdOptDef opts_domcapabilities[] = {
.type = VSH_OT_STRING,
.help = N_("machine type (/domain/os/type/@machine)"),
},
+ {.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}
};
@@ -123,13 +133,16 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
const char *emulatorbin = NULL;
const char *arch = NULL;
const char *machine = NULL;
+ const char *xpath = NULL;
const unsigned int flags = 0; /* No flags so far */
+ bool wrap = vshCommandOptBool(cmd, "wrap");
virshControl *priv = ctl->privData;
if (vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 ||
vshCommandOptStringReq(ctl, cmd, "emulatorbin", &emulatorbin) < 0 ||
vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0)
+ vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0 ||
+ vshCommandOptStringQuiet(ctl, cmd, "xpath", &xpath) < 0)
return false;
caps = virConnectGetDomainCapabilities(priv->conn, emulatorbin,
@@ -139,9 +152,7 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
return false;
}
- vshPrint(ctl, "%s\n", caps);
-
- return true;
+ return virshDumpXML(ctl, caps, "domcapabilities", xpath, wrap);
}
/*