On 03/17/2011 09:00 AM, Jiri Denemark wrote:
From: Hu Tao <hutao(a)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(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org