Patchwork [RFC,36/48] error: New error_printf_unless_qmp()

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

Comments

Markus Armbruster - Feb. 24, 2010, 5:55 p.m.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qemu-error.c |   11 +++++++++++
 qemu-error.h |    2 ++
 2 files changed, 13 insertions(+), 0 deletions(-)

Patch

diff --git a/qemu-error.c b/qemu-error.c
index a726d32..95e87c8 100644
--- a/qemu-error.c
+++ b/qemu-error.c
@@ -41,6 +41,17 @@  void error_printf(const char *fmt, ...)
     va_end(ap);
 }
 
+void error_printf_unless_qmp(const char *fmt, ...)
+{
+    va_list ap;
+
+    if (!in_qmp_mon()) {
+        va_start(ap, fmt);
+        error_vprintf(fmt, ap);
+        va_end(ap);
+    }
+}
+
 static Location std_loc = {
     .kind = LOC_NONE
 };
diff --git a/qemu-error.h b/qemu-error.h
index 75bc4bf..3ea3ba5 100644
--- a/qemu-error.h
+++ b/qemu-error.h
@@ -32,6 +32,8 @@  void loc_set_file(const char *fname, int lno);
 
 void error_vprintf(const char *fmt, va_list ap);
 void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
+void error_printf_unless_qmp(const char *fmt, ...)
+    __attribute__ ((format(printf, 1, 2)));
 void error_print_loc(void);
 void error_set_progname(const char *argv0);
 void qemu_error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));