[libvirt] [[PATCH v2] 1/4] util: remove 1k limit for error messages

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Mon Sep 12 14:34:40 UTC 2016


This limit is the issue for example when we want to return in the
error message the log of the abnormally exited qemu process of
the destination side in the process of migration.

virVasprintf is already used in the process of logging in
the callers down the stack.
---
 src/util/virerror.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/util/virerror.c b/src/util/virerror.c
index 2958308..ca74c14 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -1427,22 +1427,21 @@ void virReportErrorHelper(int domcode,
 {
     int save_errno = errno;
     va_list args;
-    char errorMessage[1024];
+    char *errorMessage = NULL;
     const char *virerr;
 
     if (fmt) {
         va_start(args, fmt);
-        vsnprintf(errorMessage, sizeof(errorMessage)-1, fmt, args);
+        ignore_value(virVasprintfQuiet(&errorMessage, fmt, args));
         va_end(args);
-    } else {
-        errorMessage[0] = '\0';
     }
 
-    virerr = virErrorMsg(errorcode, (errorMessage[0] ? errorMessage : NULL));
+    virerr = virErrorMsg(errorcode, errorMessage);
     virRaiseErrorFull(filename, funcname, linenr,
                       domcode, errorcode, VIR_ERR_ERROR,
                       virerr, errorMessage, NULL,
                       -1, -1, virerr, errorMessage);
+    VIR_FREE(errorMessage);
     errno = save_errno;
 }
 
-- 
1.8.3.1




More information about the libvir-list mailing list