[libvirt] [PATCH] fix the check of the output of monitor command 'device_add'

Hotpluging host usb device by text mode will fail, because the monitor command 'device_add' outputs 'husb: using...' if it succeeds, but we think the command should not output anything. Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> --- src/qemu/qemu_monitor_text.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 91ecc8b..75b2995 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -2283,7 +2283,15 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon, goto cleanup; } - /* If the command succeeds, no output is sent. So + /* If the host device is hotpluged first time, qemu will output + * husb: using %s file-system with %s if the command succeeds. + */ + if (STRPREFIX(reply, "husb: using")) { + ret = 0; + goto cleanup; + } + + /* Otherwise, if the command succeeds, no output is sent. So * any non-empty string shows an error */ if (STRNEQ(reply, "")) { qemuReportError(VIR_ERR_OPERATION_FAILED, -- 1.7.1

On 03/24/2011 02:56 AM, Wen Congyang wrote:
Hotpluging host usb device by text mode will fail, because the monitor command 'device_add' outputs 'husb: using...' if it succeeds, but we think the command should not output anything.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
--- src/qemu/qemu_monitor_text.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 91ecc8b..75b2995 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -2283,7 +2283,15 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon, goto cleanup; }
- /* If the command succeeds, no output is sent. So + /* If the host device is hotpluged first time, qemu will output + * husb: using %s file-system with %s if the command succeeds.
ACK. I was a bit surprised that qemu had a leading h, but git grep on qemu.git confirmed this is correct. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

At 03/24/2011 11:25 PM, Eric Blake Write:
On 03/24/2011 02:56 AM, Wen Congyang wrote:
Hotpluging host usb device by text mode will fail, because the monitor command 'device_add' outputs 'husb: using...' if it succeeds, but we think the command should not output anything.
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
--- src/qemu/qemu_monitor_text.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 91ecc8b..75b2995 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -2283,7 +2283,15 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon, goto cleanup; }
- /* If the command succeeds, no output is sent. So + /* If the host device is hotpluged first time, qemu will output + * husb: using %s file-system with %s if the command succeeds.
ACK. I was a bit surprised that qemu had a leading h, but git grep on qemu.git confirmed this is correct.
Thanks. Pushed.
participants (2)
-
Eric Blake
-
Wen Congyang