[PATCH] qemu: add support for error messages greater than 1024 characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In libvirt, the default error message length is 1024 bytes. This is not
enough for qemu to print long error messages such as the list of
supported ARM machine models (more than 1700 chars). This is
raised when the machine entry in the XML file is wrong, but there may
be now or in future other verbose error messages.
The above patch enables libvirt to print error messages >1024 for qemu.

Signed-off-by: Michele Paolino <m.paolino@xxxxxxxxxxxxxxxxxxxxxx>
---
 src/qemu/qemu_process.c |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index bd9546e..c2e2136 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1904,10 +1904,25 @@ cleanup:
          * a possible read of the fd in the monitor code doesn't influence this
          * error delivery option */
         ignore_value(lseek(logfd, pos, SEEK_SET));
-        qemuProcessReadLog(logfd, buf + len, buf_size - len - 1, 0, true);
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("process exited while connecting to monitor: %s"),
-                       buf);
+        len = qemuProcessReadLog(logfd, buf + len, buf_size - len - 1, 0, true);
+
+        /* virReportError error buffer is limited to 1024 byte*/
+        if (len < 1024){
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("process exited while connecting to monitor: %s"),
+                            buf);
+        } else {
+             if (STRPREFIX(buf, "Supported machines are:"))
+                 virReportError(VIR_ERR_INTERNAL_ERROR,
+                     _("process exited while connecting to monitor:"
+                       "please check machine model"));
+             else
+                 virReportError(VIR_ERR_INTERNAL_ERROR,
+                     _("process exited while connecting to monitor"));
+
+             VIR_ERROR("%s", buf);
+        }
+
         ret = -1;
     }
 
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]