Skip to contentSkip to conversation

monitor.c : fix the monitor_user_noop function for hmp-commands calling user_print conveniently

PATCH In review Zhou Yuan 2 participants 2 messages Oct 30, 2013 – Oct 31, 2013

lore
Share & tools
lore

Zhou Yuan

author
#0 lore raw

PATCH 1/1 monitor.c : fix the monitor_user_noop function for hmp-commands calling user_print conveniently

From: zhouy <[email protected]>
To: [email protected]
Date: Wed, 30 Oct 2013 12:37:51 -0400
Subject: [PATCH] fix the monitor_user_noop function for hmp-commands calling user_print conveniently
If a new hmp command added,just using the function call "monitor_user_noop" to print the result in the monitor model. The function is alreadly existed but not have been fixed.

Cc Luiz Capitulino <[email protected]>
---
 qemu-master/monitor.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
qemu-master/monitor.c +22 -1
index 0aeaf6c..8aa24da 100644
@@ -387,7 +387,28 @@ static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
     return 0;
 }
 
-static void monitor_user_noop(Monitor *mon, const QObject *data) { }
+static void monitor_user_noop(Monitor *mon, const QObject *data)
+{
+    switch ((*data->type).code) {
+    case QTYPE_QSTRING:{
+         const char *result = qstring_get_str(qobject_to_qstring(data));
+         monitor_printf(mon, "%s\n", result);
+         break;
+         }
+    case QTYPE_QINT:{
+         int result = qint_get_int(qobject_to_qint(data));
+         monitor_printf(mon, "%d\n", result);
+         break;
+         }
+    case QTYPE_QFLOAT:{
+         double result = qfloat_get_double(qobject_to_qfloat(data));
+         monitor_printf(mon, "%.3f\n", result);
+         break;
+         }
+    default:
+         break;
+    }
+}
 
 static inline int handler_is_qobject(const mon_cmd_t *cmd)
 {
Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · On Wed, 30 Oct 2013 17:10:29 +0800 "Zhou Yuan" <[email protected]>…

From: zhouy <[email protected]>
To: [email protected]
Date: Wed, 30 Oct 2013 12:37:51 -0400
Subject: [PATCH] fix the monitor_user_noop function for hmp-commands calling user_print conveniently
If a new hmp command added,just using the function call "monitor_user_noop" to print the result in the monitor model. The function is alreadly existed but not have been fixed.

Not sure what you're trying to accomplish here, but monitor_user_noop() is legacy and shouldn't be touched. If you to add a new command, taking a look at docs/writing-qmp-commands.txt may be helpful.

Quoted 41 lines
Cc Luiz Capitulino <[email protected]>
---
 qemu-master/monitor.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
qemu-master/monitor.c +22 -1
index 0aeaf6c..8aa24da 100644
@@ -387,7 +387,28 @@ static int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
     return 0;
 }
 
-static void monitor_user_noop(Monitor *mon, const QObject *data) { }
+static void monitor_user_noop(Monitor *mon, const QObject *data)
+{
+    switch ((*data->type).code) {
+    case QTYPE_QSTRING:{
+         const char *result = qstring_get_str(qobject_to_qstring(data));
+         monitor_printf(mon, "%s\n", result);
+         break;
+         }
+    case QTYPE_QINT:{
+         int result = qint_get_int(qobject_to_qint(data));
+         monitor_printf(mon, "%d\n", result);
+         break;
+         }
+    case QTYPE_QFLOAT:{
+         double result = qfloat_get_double(qobject_to_qfloat(data));
+         monitor_printf(mon, "%.3f\n", result);
+         break;
+         }
+    default:
+         break;
+    }
+}
 
 static inline int handler_is_qobject(const mon_cmd_t *cmd)
 {