]> git.proxmox.com Git - qemu.git/commitdiff
QError: Don't abort on multiple faults
authorLuiz Capitulino <lcapitulino@redhat.com>
Mon, 8 Feb 2010 19:01:29 +0000 (17:01 -0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Wed, 10 Feb 2010 19:46:17 +0000 (13:46 -0600)
Ideally, Monitor code should report an error only once and
return the error information up the call chain.

To assure that this happens as expected and that no error is
lost, we have an assert() in qemu_error_internal().

However, we still have not fully converted handlers using
monitor_printf() to report errors. As there can be multiple
monitor_printf() calls on an error, the assertion is easily
triggered when debugging is enabled; and we will get a memory
leak if it's not.

The solution to this problem is to allow multiple faults by only
reporting the first one, and to release the additional error objects.

A better mechanism to report multiple errors to programmers is
underway.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
monitor.c

index eccb61d1831ae052d80dbf73b9c043df6e1f5bbb..23c0661aa8b2dfc1f64bdb3c3bacf34bf121481b 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -4628,8 +4628,13 @@ void qemu_error_internal(const char *file, int linenr, const char *func,
         QDECREF(qerror);
         break;
     case ERR_SINK_MONITOR:
-        assert(qemu_error_sink->mon->error == NULL);
-        qemu_error_sink->mon->error = qerror;
+        /* report only the first error */
+        if (!qemu_error_sink->mon->error) {
+            qemu_error_sink->mon->error = qerror;
+        } else {
+            /* XXX: warn the programmer */
+            QDECREF(qerror);
+        }
         break;
     }
 }