From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIHgp-0001v7-Kq for qemu-devel@nongnu.org; Fri, 15 Aug 2014 09:37:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIHgf-00065O-SH for qemu-devel@nongnu.org; Fri, 15 Aug 2014 09:37:07 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:42476 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIHgf-00064n-HA for qemu-devel@nongnu.org; Fri, 15 Aug 2014 09:36:57 -0400 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Fri, 15 Aug 2014 15:35:37 +0200 Message-Id: <1408109759-1100-6-git-send-email-benoit.canet@nodalink.com> In-Reply-To: <1408109759-1100-1-git-send-email-benoit.canet@nodalink.com> References: <1408109759-1100-1-git-send-email-benoit.canet@nodalink.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 05/26] monitor: Extract monitor-system.h header List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com This header will allow allow splitting the monitor into two parts. Signed-off-by: Beno=C3=AEt Canet --- include/monitor/monitor-system.h | 99 ++++++++++++++++++++++++++++++++++= ++++++ monitor.c | 57 ++--------------------- 2 files changed, 102 insertions(+), 54 deletions(-) create mode 100644 include/monitor/monitor-system.h diff --git a/include/monitor/monitor-system.h b/include/monitor/monitor-s= ystem.h new file mode 100644 index 0000000..e7b99ce --- /dev/null +++ b/include/monitor/monitor-system.h @@ -0,0 +1,99 @@ +/* + * QEMU monitor + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining= a copy + * of this software and associated documentation files (the "Software"),= to deal + * in the Software without restriction, including without limitation the= rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or = sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be includ= ed in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRE= SS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHA= LL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING= S IN + * THE SOFTWARE. + */ + +#ifndef MONITOR_COMMANDS_H +#define MONITOR_COMMANDS_H + +#include "monitor/monitor.h" +#include "qapi/error.h" +#include "qapi/qmp/qlist.h" +#include "qapi/qmp/qstring.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/json-streamer.h" +#include "qapi/qmp/json-parser.h" +#include +#include "hw/pci/pci.h" + +#include + +#define MAX_ARGS 16 + +struct MonitorCommand; + +typedef struct MonitorControl { + QObject *id; + JSONMessageParser parser; + int command_mode; +} MonitorControl; + +struct Monitor { + CharDriverState *chr; + bool reset_seen; + int flags; + int suspend_cnt; + bool skip_flush; + + QemuMutex out_lock; + QString *outbuf; + guint out_watch; + + /* Read under either BQL or out_lock, written with BQL+out_lock. */ + int mux_out; + + ReadLineState *rs; + MonitorControl *mc; + CPUState *mon_cpu; + BlockDriverCompletionFunc *password_completion_cb; + void *password_opaque; + struct MonitorCommand *cmd_table; + QError *error; + QLIST_HEAD(,mon_fd_t) fds; + QLIST_ENTRY(Monitor) entry; +}; + +typedef struct MonitorCommand { + const char *name; + const char *args_type; + const char *params; + const char *help; + void (*user_print)(Monitor *mon, const QObject *data); + union { + void (*cmd)(Monitor *mon, const QDict *qdict); + int (*cmd_new)(Monitor *mon, const QDict *params, QObject **ret= _data); + int (*cmd_async)(Monitor *mon, const QDict *params, + MonitorCompletion *cb, void *opaque); + } mhandler; + int flags; + /* @sub_table is a list of 2nd level of commands. If it do not exist= , + * mhandler should be used. If it exist, sub_table[?].mhandler shoul= d be + * used, and mhandler of 1st level plays the role of help function. + */ + struct MonitorCommand *sub_table; + void (*command_completion)(ReadLineState *rs, int nb_args, const cha= r *str); +} MonitorCommand; + +int get_expr(Monitor *mon, int64_t *pval, const char **pp); +int get_double(Monitor *mon, double *pval, const char **pp); + +#endif diff --git a/monitor.c b/monitor.c index f57dae5..8c90c11 100644 --- a/monitor.c +++ b/monitor.c @@ -37,6 +37,7 @@ #include "ui/qemu-spice.h" #include "sysemu/sysemu.h" #include "monitor/monitor.h" +#include "monitor/monitor-system.h" #include "qemu/readline.h" #include "ui/console.h" #include "ui/input.h" @@ -123,27 +124,6 @@ struct MonitorCompletionData { void (*user_print)(Monitor *mon, const QObject *data); }; =20 -typedef struct MonitorCommand { - const char *name; - const char *args_type; - const char *params; - const char *help; - void (*user_print)(Monitor *mon, const QObject *data); - union { - void (*cmd)(Monitor *mon, const QDict *qdict); - int (*cmd_new)(Monitor *mon, const QDict *params, QObject **ret= _data); - int (*cmd_async)(Monitor *mon, const QDict *params, - MonitorCompletion *cb, void *opaque); - } mhandler; - int flags; - /* @sub_table is a list of 2nd level of commands. If it do not exist= , - * mhandler should be used. If it exist, sub_table[?].mhandler shoul= d be - * used, and mhandler of 1st level plays the role of help function. - */ - struct MonitorCommand *sub_table; - void (*command_completion)(ReadLineState *rs, int nb_args, const cha= r *str); -} MonitorCommand; - /* file descriptors passed via SCM_RIGHTS */ typedef struct mon_fd_t mon_fd_t; struct mon_fd_t { @@ -170,12 +150,6 @@ struct MonFdset { QLIST_ENTRY(MonFdset) next; }; =20 -typedef struct MonitorControl { - QObject *id; - JSONMessageParser parser; - int command_mode; -} MonitorControl; - /* * To prevent flooding clients, events can be throttled. The * throttling is calculated globally, rather than per-Monitor @@ -189,31 +163,6 @@ typedef struct MonitorQAPIEventState { QObject *data; /* Event pending delayed dispatch */ } MonitorQAPIEventState; =20 -struct Monitor { - CharDriverState *chr; - bool reset_seen; - int flags; - int suspend_cnt; - bool skip_flush; - - QemuMutex out_lock; - QString *outbuf; - guint out_watch; - - /* Read under either BQL or out_lock, written with BQL+out_lock. */ - int mux_out; - - ReadLineState *rs; - MonitorControl *mc; - CPUState *mon_cpu; - BlockDriverCompletionFunc *password_completion_cb; - void *password_opaque; - MonitorCommand *cmd_table; - QError *error; - QLIST_HEAD(,mon_fd_t) fds; - QLIST_ENTRY(Monitor) entry; -}; - /* QMP checker flags */ #define QMP_ACCEPT_UNKNOWNS 1 =20 @@ -3540,7 +3489,7 @@ static int64_t expr_sum(Monitor *mon) return val; } =20 -static int get_expr(Monitor *mon, int64_t *pval, const char **pp) +int get_expr(Monitor *mon, int64_t *pval, const char **pp) { pch =3D *pp; if (sigsetjmp(expr_env, 0)) { @@ -3554,7 +3503,7 @@ static int get_expr(Monitor *mon, int64_t *pval, co= nst char **pp) return 0; } =20 -static int get_double(Monitor *mon, double *pval, const char **pp) +int get_double(Monitor *mon, double *pval, const char **pp) { const char *p =3D *pp; char *tailp; --=20 2.1.0.rc1