Patchwork [RFC,01/48] monitor: Factor monitor_set_error() out of qemu_error_internal()

login
register
mail settings
Submitter Markus Armbruster
Date Feb. 24, 2010, 5:55 p.m.
Message ID <1267034160-3517-2-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/46151/
State New
Headers show

Comments

Markus Armbruster - Feb. 24, 2010, 5:55 p.m.
This separates the monitor part from the QError part.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c |   21 +++++++++++++--------
 monitor.h |    3 +++
 2 files changed, 16 insertions(+), 8 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index b1a6edc..fcd8718 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3856,6 +3856,18 @@  fail:
     return NULL;
 }
 
+void monitor_set_error(Monitor *mon, QError *qerror)
+{
+    /* report only the first error */
+    if (!mon->error) {
+        mon->error = qerror;
+    } else {
+        MON_DEBUG("Additional error report at %s:%d\n",
+                  qerror->file, qerror->linenr);
+        QDECREF(qerror);
+    }
+}
+
 static void monitor_print_error(Monitor *mon)
 {
     qerror_print(mon->error);
@@ -4757,14 +4769,7 @@  void qemu_error_internal(const char *file, int linenr, const char *func,
         QDECREF(qerror);
         break;
     case ERR_SINK_MONITOR:
-        /* report only the first error */
-        if (!qemu_error_sink->mon->error) {
-            qemu_error_sink->mon->error = qerror;
-        } else {
-            MON_DEBUG("Additional error report at %s:%d\n", qerror->file,
-                      qerror->linenr);
-            QDECREF(qerror);
-        }
+        monitor_set_error(qemu_error_sink->mon, qerror);
         break;
     }
 }
diff --git a/monitor.h b/monitor.h
index fc09505..1c72615 100644
--- a/monitor.h
+++ b/monitor.h
@@ -3,6 +3,7 @@ 
 
 #include "qemu-common.h"
 #include "qemu-char.h"
+#include "qerror.h"
 #include "qdict.h"
 #include "block.h"
 
@@ -47,4 +48,6 @@  void monitor_flush(Monitor *mon);
 
 typedef void (MonitorCompletion)(void *opaque, QObject *ret_data);
 
+void monitor_set_error(Monitor *mon, QError *qerror);
+
 #endif /* !MONITOR_H */