[PATCH] qemu: fix a segfault in qemuProcessWaitForMonitor

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

 



Commit b3f2b4ca5cfe98b08ffdb96f0455e3e333e5ace6 left buf unallocated in
the case of QMP capability probing being used, leading to a segfault in
strlen in the cleanup path.

This patch opens the log and allocates the buffer if QMP probing was
used, so we can display the helpful error message.
---
 src/qemu/qemu_process.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 358757b..2d63cf2 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1709,6 +1709,15 @@ cleanup:
     if (pos != -1 && kill(vm->pid, 0) == -1 && errno == ESRCH) {
         /* VM is dead, any other error raised in the interim is probably
          * not as important as the qemu cmdline output */
+        if (qemuCapsUsedQMP(caps)) {
+            if ((logfd = qemuDomainOpenLog(driver, vm, pos)) < 0)
+                return -1;
+
+            if (VIR_ALLOC_N(buf, buf_size) < 0) {
+                virReportOOMError();
+                goto closelog;
+            }
+        }
         qemuProcessReadLogFD(logfd, buf, buf_size, strlen(buf));
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("process exited while connecting to monitor: %s"),
-- 
1.7.8.6

--
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]