Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
docs/manpages/virsh.rst | 6 +++++-
tools/virsh-domain.c | 18 +++++++++++++++++-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index e28927ed6c..82a759a636 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -7881,7 +7881,8 @@ qemu-monitor-command
::
- qemu-monitor-command domain { [--hmp] | [--pretty] [--return-value] } command...
+ qemu-monitor-command domain { [--hmp] | [--pretty] [--return-value] }
+ [--pass-fds N,M,...] command...
Send an arbitrary monitor command *command* to domain *domain* through the
QEMU monitor. The results of the command will be printed on stdout.
@@ -7914,6 +7915,9 @@ extracted rather than passing through the full reply from QEMU.
If *--hmp* is passed, the command is considered to be a human monitor command
and libvirt will automatically convert it into QMP and convert the result back.
+If *--pass-fds* is specified, the argument is a comma separated list
+of open file descriptors which should be passed on to qemu along with the
+command.
qemu-agent-command
------------------
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0bf4bb8dad..6cd031f8c3 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9703,6 +9703,11 @@ static const vshCmdOptDef opts_qemu_monitor_command[] = {
.type = VSH_OT_BOOL,
.help = N_("extract the value of the 'return' key from the returned
string")
},
+ {.name = "pass-fds",
+ .type = VSH_OT_STRING,
+ .completer = virshCompleteEmpty,
+ .help = N_("pass file descriptors N,M,... along with the command")
+ },
{.name = "cmd",
.type = VSH_OT_ARGV,
.flags = VSH_OFLAG_REQ,
@@ -9801,6 +9806,8 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
bool returnval = vshCommandOptBool(cmd, "return-value");
virJSONValue *formatjson;
g_autofree char *jsonstr = NULL;
+ g_autofree int *fds = NULL;
+ size_t nfds = 0;
VSH_EXCLUSIVE_OPTIONS("hmp", "pretty");
VSH_EXCLUSIVE_OPTIONS("hmp", "return-value");
@@ -9820,9 +9827,18 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
return NULL;
}
- if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, flags) < 0)
+ if (virshFetchPassFdsList(ctl, cmd, &nfds, &fds) < 0)
return false;
+ if (fds) {
+ if (virDomainQemuMonitorCommandWithFiles(dom, monitor_cmd, nfds, fds,
+ &result, flags) < 0)
+ return false;
+ } else {
+ if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, flags) < 0)
+ return false;
+ }
+
if (returnval || pretty) {
resultjson = virJSONValueFromString(result);
--
2.34.1