[PATCH] qemu: monitor: Improve error message when QEMU reply is too large

Peter Krempa posted 1 patch 4 years, 3 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/675360ee4a6a17781f253c7ec2897a6e8fc60ade.1579533109.git.pkrempa@redhat.com
src/qemu/qemu_monitor.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] qemu: monitor: Improve error message when QEMU reply is too large
Posted by Peter Krempa 4 years, 3 months ago
Don't use ERANGE as it doesn't make much sense in the error message.
Also point out that the reply from qemu was too large which is not
obvious from the original error:

 error: No complete monitor response found in 10485760 bytes: Numerical result out of range

The new message will read:

 error: internal error: QEMU monitor reply exceeds buffer size (10485760 bytes)

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_monitor.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index ccd20b3740..e3bd000ccb 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -484,9 +484,9 @@ qemuMonitorIORead(qemuMonitorPtr mon)

     if (avail < 1024) {
         if (mon->bufferLength >= QEMU_MONITOR_MAX_RESPONSE) {
-            virReportSystemError(ERANGE,
-                                 _("No complete monitor response found in %d bytes"),
-                                 QEMU_MONITOR_MAX_RESPONSE);
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("QEMU monitor reply exceeds buffer size (%d bytes)"),
+                           QEMU_MONITOR_MAX_RESPONSE);
             return -1;
         }
         if (VIR_REALLOC_N(mon->buffer,
-- 
2.24.1

Re: [PATCH] qemu: monitor: Improve error message when QEMU reply is too large
Posted by Jiri Denemark 4 years, 3 months ago
On Mon, Jan 20, 2020 at 16:11:49 +0100, Peter Krempa wrote:
> Don't use ERANGE as it doesn't make much sense in the error message.
> Also point out that the reply from qemu was too large which is not
> obvious from the original error:
> 
>  error: No complete monitor response found in 10485760 bytes: Numerical result out of range
> 
> The new message will read:
> 
>  error: internal error: QEMU monitor reply exceeds buffer size (10485760 bytes)
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_monitor.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>