On 05/10/2011 02:26 AM, Lai Jiangshan wrote:
+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);
+
+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)
I just noticed that upstream qemu now has QMP 'inject-nmi' (commit
a404666), and that as a result, HMP 'nmi' command no longer takes an
integer option (commit e9b4b43). If libvirt uses QMP, then this is not
an issue, but if libvirt uses HMP while talking to a newer qemu, is this
attempt to do 'nmi 0' going to cause a syntax error? That is, do we
need a patch to libvirt to detect a usage error with 'nmi 0' on hmp that
falls back to trying plain 'nmi' before giving up altogether?
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org