[libvirt] [PATCH 6/6 V4] qemu, inject-nmi: Implement the driver methods

Eric Blake eblake at redhat.com
Wed Jun 22 17:52:09 UTC 2011


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110622/6d4005c3/attachment-0001.sig>


More information about the libvir-list mailing list