[libvirt] [PATCH 2/2] qemu: fallback to HMP drive_add/drive_del

Eric Blake eblake at redhat.com
Thu Mar 17 19:44:09 UTC 2011


On 03/17/2011 09:00 AM, Jiri Denemark wrote:
> From: Hu Tao <hutao at cn.fujitsu.com>
> 
> fallback to HMP drive_add/drive_del commands if not found in QMP
> ---
>  src/qemu/qemu_monitor_json.c |   38 ++++++++++++++++++++++++--------------
>  1 files changed, 24 insertions(+), 14 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 43245a6..235985e 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -2288,11 +2288,18 @@ int qemuMonitorJSONAddDrive(qemuMonitorPtr mon,
>      if (!cmd)
>          return -1;
>  
> -    ret = qemuMonitorJSONCommand(mon, cmd, &reply);
> +    if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply) < 0))
> +        goto cleanup;
>  
> -    if (ret == 0)
> -        ret = qemuMonitorJSONCheckError(cmd, reply);
> +    if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
> +        VIR_DEBUG0("drive_add command not found, trying HMP");
> +        ret = qemuMonitorTextAddDrive(mon, drivestr);

Here, we always try the hmp variant...

> -        /* See if drive_del isn't supported */
> -        if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
> +    if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
> +        if (qemuMonitorCheckHMP(mon)) {
> +            VIR_DEBUG0("drive_del command not found, trying HMP");
> +            ret = qemuMonitorTextDriveDel(mon, drivestr);

...but here, we only try hmp if it is present.

I guess that makes sense if the error message for add when hmp is
missing is reasonable (the whole point of skipping on delete is that hmp
not present is not fatal, so we don't want the error message).  So:

ACK

-- 
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/20110317/a41fc524/attachment-0001.sig>


More information about the libvir-list mailing list