qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@nodalink.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com,
	"Benoît Canet" <benoit.canet@nodalink.com>,
	stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 08/26] monitor: Extract qmp_human_monitor_command into monitor-system.c
Date: Fri, 15 Aug 2014 15:35:40 +0200	[thread overview]
Message-ID: <1408109759-1100-9-git-send-email-benoit.canet@nodalink.com> (raw)
In-Reply-To: <1408109759-1100-1-git-send-email-benoit.canet@nodalink.com>

Signed-off-by: Benoît Canet <benoit.canet@nodalink.com>
---
 monitor-system.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 monitor.c        | 44 --------------------------------------------
 2 files changed, 43 insertions(+), 44 deletions(-)

diff --git a/monitor-system.c b/monitor-system.c
index 51ca21f..90758db 100644
--- a/monitor-system.c
+++ b/monitor-system.c
@@ -67,3 +67,46 @@ int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
     return 0;
 }
 
+static void monitor_data_destroy(Monitor *mon)
+{
+    QDECREF(mon->outbuf);
+    qemu_mutex_destroy(&mon->out_lock);
+}
+
+char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
+                                int64_t cpu_index, Error **errp)
+{
+    char *output = NULL;
+    Monitor *old_mon, hmp;
+
+    monitor_data_init(&hmp);
+    hmp.skip_flush = true;
+
+    old_mon = cur_mon;
+    cur_mon = &hmp;
+
+    if (has_cpu_index) {
+        int ret = monitor_set_cpu(cpu_index);
+        if (ret < 0) {
+            cur_mon = old_mon;
+            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+                      "a CPU number");
+            goto out;
+        }
+    }
+
+    handle_user_command(&hmp, command_line);
+    cur_mon = old_mon;
+
+    qemu_mutex_lock(&hmp.out_lock);
+    if (qstring_get_length(hmp.outbuf) > 0) {
+        output = g_strdup(qstring_get_str(hmp.outbuf));
+    } else {
+        output = g_strdup("");
+    }
+    qemu_mutex_unlock(&hmp.out_lock);
+
+out:
+    monitor_data_destroy(&hmp);
+    return output;
+}
diff --git a/monitor.c b/monitor.c
index 24f4a53..106efb5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -552,50 +552,6 @@ void monitor_data_init(Monitor *mon)
     mon->cmd_table = mon_cmds;
 }
 
-static void monitor_data_destroy(Monitor *mon)
-{
-    QDECREF(mon->outbuf);
-    qemu_mutex_destroy(&mon->out_lock);
-}
-
-char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
-                                int64_t cpu_index, Error **errp)
-{
-    char *output = NULL;
-    Monitor *old_mon, hmp;
-
-    monitor_data_init(&hmp);
-    hmp.skip_flush = true;
-
-    old_mon = cur_mon;
-    cur_mon = &hmp;
-
-    if (has_cpu_index) {
-        int ret = monitor_set_cpu(cpu_index);
-        if (ret < 0) {
-            cur_mon = old_mon;
-            error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
-                      "a CPU number");
-            goto out;
-        }
-    }
-
-    handle_user_command(&hmp, command_line);
-    cur_mon = old_mon;
-
-    qemu_mutex_lock(&hmp.out_lock);
-    if (qstring_get_length(hmp.outbuf) > 0) {
-        output = g_strdup(qstring_get_str(hmp.outbuf));
-    } else {
-        output = g_strdup("");
-    }
-    qemu_mutex_unlock(&hmp.out_lock);
-
-out:
-    monitor_data_destroy(&hmp);
-    return output;
-}
-
 int compare_cmd(const char *name, const char *list)
 {
     const char *p, *pstart;
-- 
2.1.0.rc1

  parent reply	other threads:[~2014-08-15 13:37 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-15 13:35 [Qemu-devel] [PATCH v2 00/26] Extract qmp.c and monitor.c core and wire QMP into qemu-nbd Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 01/26] qmp: Extract system emulation related code from qmp.c into qmp-system.c Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 02/26] monitor: Make some function public Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 03/26] monitor: Convert Monitor reset_seen field too boolean Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 04/26] monitor: Convert mon_cmd_t to MonitorCommand Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 05/26] monitor: Extract monitor-system.h header Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 06/26] monitor: Make monitor_fprintf public before extracting it Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 07/26] monitor: Extract monitor_fprintf to monitor-system.c Benoît Canet
2014-08-15 13:35 ` Benoît Canet [this message]
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 09/26] monitor: Make some function to extract public Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 10/26] monitor: Extract a couple of function to monitor-system.c Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 11/26] monitor: Make do_info_help public Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 12/26] monitor: Extract do_info_help in monitor-system.c Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 13/26] monitor: Make some monitor functions public before moving them " Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 14/26] monitor: Make do_loadvm public before moving it to monitor-system.c Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 15/26] monitor: Move do_loadvm from monitor.c " Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 16/26] monitor: Make commands public before moving them " Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 17/26] monitor: Move MonitorCommand arrays and some function from monitor.c " Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 18/26] monitor: Move more functions " Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 19/26] monitor: Move two net " Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 20/26] monitor: Move qmp_rtc_reset_reinjection " Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 21/26] monitor-system: Switch back functions to static Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 22/26] monitor: Extract hardware dependent completion function from monitor.c to monitor-system.c Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 23/26] monitor: Cleanup monitor.c includes after extracting monitor-system.c Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 24/26] qemu-nbd: build QAPI block core into qemu-nbd Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 25/26] qapi: Add a script to filter qmp-commands-old.h to generate a subset of it Benoît Canet
2014-08-15 13:35 ` [Qemu-devel] [PATCH v2 26/26] qemu-nbd: Add --qmp option to qemu-nbd Benoît Canet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408109759-1100-9-git-send-email-benoit.canet@nodalink.com \
    --to=benoit.canet@nodalink.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).