return qemudDomainSetMemoryFlags(dom, memory, VIR_DOMAIN_MEM_MAXIMUM);
}
+static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags)
+{
+ struct qemud_driver *driver = domain->conn->privateData;
+ virDomainObjPtr vm = NULL;
+ int ret = -1;
+ qemuDomainObjPrivatePtr priv;
+
+ virCheckFlags(0, -1);
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, domain->uuid);
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(domain->uuid, uuidstr);
+ qemuReportError(VIR_ERR_NO_DOMAIN,
+ _("no domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
+ priv = vm->privateData;
+
+ if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
+ goto cleanup;
+ qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ ret = qemuMonitorInjectNMI(priv->mon);
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ if (qemuDomainObjEndJob(vm) == 0) {
+ vm = NULL;
+ goto cleanup;
+ }
+
+cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ qemuDriverUnlock(driver);
+ return ret;
+}
+
static int qemudDomainGetInfo(virDomainPtr dom,
virDomainInfoPtr info)
{
qemuDomainSnapshotDelete, /* domainSnapshotDelete */
qemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
qemuDomainOpenConsole, /* domainOpenConsole */
- NULL, /* domainInjectNMI */
+ qemuDomainInjectNMI, /* domainInjectNMI */
};
return ret;
}
+
+int qemuMonitorJSONInjectNMI(qemuMonitorPtr mon)
+{
+ int ret;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+
+ cmd = qemuMonitorJSONMakeCommand("inject-nmi", NULL);
+ if (!cmd)
+ return -1;
+
+ if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
+ goto cleanup;
+
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound") &&
+ qemuMonitorCheckHMP(mon, "inject-nmi")) {
+ VIR_DEBUG0("inject-nmi command not found, trying HMP");
+ ret = qemuMonitorTextInjectNMI(mon);
+ } else {
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+ }
+
+cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
return ret;
}
+
+int qemuMonitorTextInjectNMI(qemuMonitorPtr mon)
+{
+ const char *cmd = "inject-nmi";
+ char *reply = NULL;
+
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
+ goto fail;
+
+ if (strstr(reply, "unknown command") != NULL) {
+ VIR_FREE(reply);
+
+ /* fallback to 'nmi' if qemu has not supported "inject-nmi" yet. */
+ cmd = "nmi 0";
+ reply = NULL;
+ if (qemuMonitorHMPCommand(mon, cmd, &reply) < 0)
+ goto fail;
+ }
+
+ VIR_FREE(reply);
+ return 0;
+
+fail:
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("failed to inject NMI using command '%s'"),
+ cmd);
+ return -1;
+}