if (!cmd || qemuMonitorJSONCommandWithFd(mon, cmd, scm_fd, &reply) < 0)
goto cleanup;
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+ _("Human monitor command is not available to run %s"),
+ cmd_str);
+ goto cleanup;
+ }
+
if (qemuMonitorJSONCheckError(cmd, reply))
goto cleanup;
*/
int
qemuMonitorJSONCheckCommands(qemuMonitorPtr mon,
- qemuCapsPtr caps,
- int *json_hmp)
+ qemuCapsPtr caps)
{
int ret = -1;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-commands", NULL);
!(name = virJSONValueObjectGetString(entry, "name")))
goto cleanup;
- if (STREQ(name, "human-monitor-command"))
- *json_hmp = 1;
- else if (STREQ(name, "system_wakeup"))
+ if (STREQ(name, "system_wakeup"))
qemuCapsSet(caps, QEMU_CAPS_WAKEUP);
else if (STREQ(name, "transaction"))
qemuCapsSet(caps, QEMU_CAPS_TRANSACTION);
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
- qemuMonitorCheckHMP(mon, "cpu_set")) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
VIR_DEBUG("cpu_set command not found, trying HMP");
ret = qemuMonitorTextSetCPU(mon, cpu, online);
goto cleanup;
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply) < 0))
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
- qemuMonitorCheckHMP(mon, "drive_add")) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
VIR_DEBUG("drive_add command not found, trying HMP");
ret = qemuMonitorTextAddDrive(mon, drivestr);
goto cleanup;
goto cleanup;
if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
- if (qemuMonitorCheckHMP(mon, "drive_del")) {
- VIR_DEBUG("drive_del command not found, trying HMP");
- ret = qemuMonitorTextDriveDel(mon, drivestr);
- } else {
- VIR_ERROR(_("deleting disk is not supported. "
- "This may leak data if disk is reassigned"));
- ret = 1;
+ VIR_DEBUG("drive_del command not found, trying HMP");
+ if ((ret = qemuMonitorTextDriveDel(mon, drivestr)) < 0) {
+ virErrorPtr err = virGetLastError();
+ if (err && err->code == VIR_ERR_OPERATION_UNSUPPORTED) {
+ VIR_ERROR("%s",
+ _("deleting disk is not supported. "
+ "This may leak data if disk is reassigned"));
+ ret = 1;
+ virResetLastError();;
+ }
}
} else if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
/* NB: device not found errors mean the drive was
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
- qemuMonitorCheckHMP(mon, "savevm")) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
VIR_DEBUG("savevm command not found, trying HMP");
ret = qemuMonitorTextCreateSnapshot(mon, name);
goto cleanup;
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
- qemuMonitorCheckHMP(mon, "loadvm")) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
VIR_DEBUG("loadvm command not found, trying HMP");
ret = qemuMonitorTextLoadSnapshot(mon, name);
goto cleanup;
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
- qemuMonitorCheckHMP(mon, "delvm")) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
VIR_DEBUG("delvm command not found, trying HMP");
ret = qemuMonitorTextDeleteSnapshot(mon, name);
goto cleanup;
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
- qemuMonitorCheckHMP(mon, "snapshot_blkdev")) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
VIR_DEBUG("blockdev-snapshot-sync command not found, trying HMP");
ret = qemuMonitorTextDiskSnapshot(mon, device, file);
goto cleanup;
int ret = -1;
if (hmp) {
- if (!qemuMonitorCheckHMP(mon, NULL)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("HMP passthrough is not supported by qemu"
- " process; only QMP commands can be used"));
- return -1;
- }
return qemuMonitorJSONHumanCommandWithFd(mon, cmd_str, -1, reply_str);
} else {
if (!(cmd = virJSONValueFromString(cmd_str)))
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
- qemuMonitorCheckHMP(mon, "inject-nmi")) {
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
VIR_DEBUG("inject-nmi command not found, trying HMP");
ret = qemuMonitorTextInjectNMI(mon);
} else {
* FIXME: qmp sendkey has not been implemented yet,
* and qmp API of it cannot be anticipated, so we use hmp temporary.
*/
- if (qemuMonitorCheckHMP(mon, "sendkey")) {
- return qemuMonitorTextSendKey(mon, holdtime, keycodes, nkeycodes);
- } else
- return -1;
+ return qemuMonitorTextSendKey(mon, holdtime, keycodes, nkeycodes);
}
int qemuMonitorJSONScreendump(qemuMonitorPtr mon,