[libvirt] [PATCH 1/3] Fix check for errors in device_add command in QEMU text monitor
Eric Blake
eblake at redhat.com
Fri May 28 12:57:46 UTC 2010
On 05/28/2010 05:52 AM, Daniel P. Berrange wrote:
> Any output at all from device_add indicates an error in the
> command execution. Thus it needs to check for reply != ""
>
> * src/qemu/qemu_monitor_text.c: Fix reply check for errors
> to treat any output as an error
> ---
> src/qemu/qemu_monitor_text.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
> index 4b1e2ec..005db25 100644
> --- a/src/qemu/qemu_monitor_text.c
> +++ b/src/qemu/qemu_monitor_text.c
> @@ -2319,11 +2319,11 @@ int qemuMonitorTextAddDevice(qemuMonitorPtr mon,
> goto cleanup;
> }
>
> - /* If the command failed qemu prints:
> - * Could not add ... */
> - if (strstr(reply, "Could not add ")) {
> + /* If the command succeeds, not output is sent. So
s/not/no/
> + * any non-empty string shows an error */
> + if (STRNEQ(reply, "")) {
Does it look any better to use:
if (!*reply) {
At any rate, the compiler can probably optimize both variants into the
same code.
> qemuReportError(VIR_ERR_OPERATION_FAILED,
> - _("adding %s device failed"), devicestr);
> + _("adding %s device failed: %s"), devicestr, reply);
> goto cleanup;
> }
>
ACK with the spelling fix.
--
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/20100528/12f22ed6/attachment-0001.sig>
More information about the libvir-list
mailing list