Skip to contentSkip to conversation

log: simple changes

PATCH Applied Denis V. Lunev 3 participants 5 messages Mar 16, 2016 – Mar 21, 2016

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 trace: do not always call exit() in trace_enable_events

The problem is that
virsh qemu-monitor-command --hmp VM log trace:help
forces QEMU to exit even when running VM normally.

---
 trace/control.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
trace/control.c +4 -1
index 20d3370..2d404c3 100644
@@ -19,6 +19,7 @@
 #include "qemu/log.h"
 #endif
 #include "qemu/error-report.h"
+#include "monitor/monitor.h"
 
 int trace_events_enabled_count;
 bool trace_events_dstate[TRACE_EVENT_COUNT];
@@ -131,7 +132,9 @@ void trace_enable_events(const char *line_buf)
 {
     if (is_help_option(line_buf)) {
         trace_list_events();
-        exit(0);
+        if (cur_mon == NULL) {
+            exit(0);
+        }
     } else {
         do_trace_enable_events(line_buf);
     }
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/2 log: move qemu_log_close/qemu_log_flush from header to log.c

In reply to Denis V. Lunev

There is no particular reason to keep these functions in the header. Suggested by Paolo.

CC Stefan Hajnoczi <[email protected]>
CC Paolo Bonzini <[email protected]>
---
 include/qemu/log.h | 22 +++++-----------------
 util/log.c         | 17 +++++++++++++++++
 2 files changed, 22 insertions(+), 17 deletions(-)
include/qemu/log.h +5 -17
index 40c24fd..2c2c220 100644
@@ -73,23 +73,6 @@ void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...);
 
 /* Maintenance: */
 
-/* fflush() the log file */
-static inline void qemu_log_flush(void)
-{
-    fflush(qemu_logfile);
-}
-
-/* Close the log file */
-static inline void qemu_log_close(void)
-{
-    if (qemu_logfile) {
-        if (qemu_logfile != stderr) {
-            fclose(qemu_logfile);
-        }
-        qemu_logfile = NULL;
-    }
-}
-
 /* define log items */
 typedef struct QEMULogItem {
     int mask;
@@ -122,4 +105,9 @@ int qemu_str_to_log_mask(const char *str);
  */
 void qemu_print_log_usage(FILE *f);
 
+/* fflush() the log file */
+void qemu_log_flush(void);
+/* Close the log file */
+void qemu_log_close(void);
+
 #endif
util/log.c +17 -0
index 8b921de..d03b3a8 100644
@@ -105,6 +105,23 @@ void qemu_set_log_filename(const char *filename)
     qemu_set_log(qemu_loglevel);
 }
 
+/* fflush() the log file */
+void qemu_log_flush(void)
+{
+    fflush(qemu_logfile);
+}
+
+/* Close the log file */
+void qemu_log_close(void)
+{
+    if (qemu_logfile) {
+        if (qemu_logfile != stderr) {
+            fclose(qemu_logfile);
+        }
+        qemu_logfile = NULL;
+    }
+}
+
 const QEMULogItem qemu_log_items[] = {
     { CPU_LOG_TB_OUT_ASM, "out_asm",
       "show generated host assembly code for each compiled TB" },
Signature · 1 line
2.1.4