}
-static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
- char **result, unsigned int flags)
+static int
+qemuDomainQemuMonitorCommandWithFiles(virDomainPtr domain,
+ const char *cmd,
+ unsigned int ninfds,
+ int *infds,
+ unsigned int *noutfds,
+ int **outfds,
+ char **result,
+ unsigned int flags)
{
virQEMUDriver *driver = domain->conn->privateData;
virDomainObj *vm = NULL;
int ret = -1;
qemuDomainObjPrivate *priv;
bool hmp;
+ int fd = -1;
virCheckFlags(VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP, -1);
+ /* currently we don't pass back any fds */
+ if (outfds)
+ *outfds = NULL;
+ if (noutfds)
+ *noutfds = 0;
+
+ if (ninfds > 1) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("at most 1 fd can be passed to qemu along with a command"));
+ return -1;
+ }
+
+ if (ninfds == 1)
+ fd = infds[0];
+
if (!(vm = qemuDomainObjFromDomain(domain)))
goto cleanup;
- if (virDomainQemuMonitorCommandEnsureACL(domain->conn, vm->def) < 0)
+ if (virDomainQemuMonitorCommandWithFilesEnsureACL(domain->conn, vm->def) < 0)
goto cleanup;
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
hmp = !!(flags & VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP);
qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result, hmp);
+ ret = qemuMonitorArbitraryCommand(priv->mon, cmd, fd, result, hmp);
qemuDomainObjExitMonitor(driver, vm);
endjob:
}
+static int
+qemuDomainQemuMonitorCommand(virDomainPtr domain,
+ const char *cmd,
+ char **result,
+ unsigned int flags)
+{
+ return qemuDomainQemuMonitorCommandWithFiles(domain, cmd, 0, NULL, NULL, NULL, result, flags);
+}
+
+
static int
qemuDomainOpenConsole(virDomainPtr dom,
const char *dev_name,
.domainRevertToSnapshot = qemuDomainRevertToSnapshot, /* 0.8.0 */
.domainSnapshotDelete = qemuDomainSnapshotDelete, /* 0.8.0 */
.domainQemuMonitorCommand = qemuDomainQemuMonitorCommand, /* 0.8.3 */
+ .domainQemuMonitorCommandWithFiles = qemuDomainQemuMonitorCommandWithFiles, /* 8.2.0 */
.domainQemuAttach = NULL, /* 0.9.4 - 5.5.0 */
.domainQemuAgentCommand = qemuDomainQemuAgentCommand, /* 0.10.0 */
.connectDomainQemuMonitorEventRegister = qemuConnectDomainQemuMonitorEventRegister, /* 1.2.3 */
int
qemuMonitorArbitraryCommand(qemuMonitor *mon,
const char *cmd,
+ int fd,
char **reply,
bool hmp)
{
- VIR_DEBUG("cmd=%s, reply=%p, hmp=%d", cmd, reply, hmp);
+ VIR_DEBUG("cmd=%s, fd=%d, reply=%p, hmp=%d", cmd, fd, reply, hmp);
QEMU_CHECK_MONITOR(mon);
if (hmp)
- return qemuMonitorJSONHumanCommand(mon, cmd, reply);
+ return qemuMonitorJSONHumanCommand(mon, cmd, fd, reply);
else
- return qemuMonitorJSONArbitraryCommand(mon, cmd, reply);
+ return qemuMonitorJSONArbitraryCommand(mon, cmd, fd, reply);
}
int qemuMonitorArbitraryCommand(qemuMonitor *mon,
const char *cmd,
+ int fd,
char **reply,
bool hmp);
int
qemuMonitorJSONHumanCommand(qemuMonitor *mon,
const char *cmd_str,
+ int fd,
char **reply_str)
{
g_autoptr(virJSONValue) cmd = NULL;
"s:command-line", cmd_str,
NULL);
- if (!cmd || qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ if (!cmd || qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0)
return -1;
if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
int qemuMonitorJSONArbitraryCommand(qemuMonitor *mon,
const char *cmd_str,
+ int fd,
char **reply_str)
{
g_autoptr(virJSONValue) cmd = NULL;
if (!(cmd = virJSONValueFromString(cmd_str)))
return -1;
- if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ if (qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0)
return -1;
if (!(*reply_str = virJSONValueToString(reply, false)))
int
qemuMonitorJSONHumanCommand(qemuMonitor *mon,
const char *cmd,
+ int fd,
char **reply);
int
int
qemuMonitorJSONArbitraryCommand(qemuMonitor *mon,
const char *cmd_str,
+ int fd,
char **reply_str);
int
* address required when attaching drives to a controller */
cmd = g_strdup_printf("drive_add dummy %s", drivestr);
- if (qemuMonitorJSONHumanCommand(mon, cmd, &reply) < 0)
+ if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply) < 0)
return -1;
if (strstr(reply, "unknown command:")) {
cmd = g_strdup_printf("drive_del %s", drivestr);
- if (qemuMonitorJSONHumanCommand(mon, cmd, &reply) < 0)
+ if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply) < 0)
return -1;
if (strstr(reply, "unknown command:")) {
cmd = g_strdup_printf("savevm \"%s\"", name);
- if (qemuMonitorJSONHumanCommand(mon, cmd, &reply))
+ if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply))
return -1;
if (strstr(reply, "Error while creating snapshot") ||
g_autofree char *reply = NULL;
cmd = g_strdup_printf("delvm \"%s\"", name);
- if (qemuMonitorJSONHumanCommand(mon, cmd, &reply))
+ if (qemuMonitorJSONHumanCommand(mon, cmd, -1, &reply))
return -1;
if (strstr(reply, "No block device supports snapshots")) {