qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Juan Quintela <quintela@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Blue Swirl <blauwirbel@gmail.com>, Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] [PATCH] monitor: Allow to exclude commands from QMP
Date: Mon, 28 Jun 2010 18:27:47 +0200	[thread overview]
Message-ID: <4C28CD83.1080103@siemens.com> (raw)
In-Reply-To: <20100628132012.0be57f24@redhat.com>

Luiz Capitulino wrote:
> On Mon, 28 Jun 2010 16:40:58 +0200
> Jan Kiszka <jan.kiszka@siemens.com> wrote:
> 
>> Luiz Capitulino wrote:
>>> On Wed, 23 Jun 2010 12:28:27 +0200
>>> Jan Kiszka <jan.kiszka@siemens.com> wrote:
>>>
>>>> Markus Armbruster wrote:
>>>>> Jan Kiszka <jan.kiszka@web.de> writes:
>>>>>
>>>>>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>>>>>
>>>>>> This enables command line completion inside option strings. A list of
>>>>>> expected key names and their completion type can be appended to the 'O'
>>>>>> inside parentheses ('O(key:type,...)'). The first use case is block
>>>>>> device completion for the 'drive' option of 'device_add'.
>>>>>>
>>>>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>>>>> ---
>>>>>>  monitor.c       |   68 ++++++++++++++++++++++++++++++++++++++++++++++---------
>>>>>>  qemu-monitor.hx |    2 +-
>>>>>>  2 files changed, 58 insertions(+), 12 deletions(-)
>>>>>>
>>>>>> diff --git a/monitor.c b/monitor.c
>>>>>> index c1006b4..3e0d862 100644
>>>>>> --- a/monitor.c
>>>>>> +++ b/monitor.c
>>>>>> @@ -68,6 +68,9 @@
>>>>>>   * 'O'          option string of the form NAME=VALUE,...
>>>>>>   *              parsed according to QemuOptsList given by its name
>>>>>>   *              Example: 'device:O' uses qemu_device_opts.
>>>>>> + *              Command completion for specific keys can be requested via
>>>>>> + *              appending '(NAME:TYPE,...)' with 'F', 'B' as type.
>>>>>> + *              Example: 'device:O(bus:Q)' to expand 'bus=...' as qtree path.
>>>>>>   *              Restriction: only lists with empty desc are supported
>>>>>>   *              TODO lift the restriction
>>>>>>   * 'i'          32 bit integer
>>>>> Ugh.
>>>>>
>>>>> Replacement of args_type by a proper data structure is long overdue.  We
>>>>> keep piling features into that poor, hapless string.
>>>>>
>>>>> Information on how to complete QemuOptsList options arguably belongs
>>>>> into the option description, i.e. QemuOptDesc.
>>>> For sure, that would be better. I just wonder how much of it should be
>>>> stuffed into this series. I guess I will drop this part for now, just
>>>> focusing on what device_show makes direct use of. Same for separate args
>>>> for HMP and QMP.
>>> IIRC, the separate args idea use case was to allow commands like device_del
>>> to have an ID argument and a path argument, right? If so, I think it doesn't
>>> matter anymore as we have agreed on having a device argument which would
>>> accept both, even under QMP, right Markus?
>> To my understanding: As a leading element in qdev path, at least to
>> address a device, maybe also to abbreviate only the beginning of a full
>> path (that's currently to major remaining open issue).
> 
> I'm ok with it if it's unambiguous.
> 
>>> By the way, if you send patches 09/23, 10/23, 15/23, (maybe) 16/23, 21/23
>>> and 22/23 in a different series, I could try pushing them in my next
>>> pull request.
>> Do they need rebasing? If not, feel free to pick them up as you like. My
>> series requires a v5 round anyway once discussion on path construction
>> finally came to an end.
> 
> Done for them all, except 16/23 which mentions device_show in the changelog.

If that's the only issue of 16/23, feel free to pick up the cleaned
version below.

> 
> I should send a pull request until this Wednesday.

Great, thanks.

Jan

-------------->

Ported commands that are marked 'user_only' will not be considered for
QMP monitor sessions. This allows to implement new commands that do not
(yet) provide a sufficiently stable interface for QMP use.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

For Luiz' queue, depends on "monitor: Establish cmd flags and convert
the async tag" as posted earlier.

 monitor.c |   18 +++++++++++++++---
 monitor.h |    1 +
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 281a6f2..99c07d2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -330,6 +330,11 @@ static inline bool monitor_handler_is_async(const mon_cmd_t *cmd)
     return cmd->flags & MONITOR_CMD_ASYNC;
 }
 
+static inline bool monitor_cmd_user_only(const mon_cmd_t *cmd)
+{
+    return (cmd->flags & MONITOR_CMD_USER_ONLY);
+}
+
 static inline int monitor_has_error(const Monitor *mon)
 {
     return mon->error != NULL;
@@ -612,6 +617,11 @@ static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
         goto help;
     }
 
+    if (monitor_ctrl_mode(mon) && monitor_cmd_user_only(cmd)) {
+        qerror_report(QERR_COMMAND_NOT_FOUND, item);
+        return -1;
+    }
+
     if (monitor_handler_is_async(cmd)) {
         if (monitor_ctrl_mode(mon)) {
             qmp_async_info_handler(mon, cmd);
@@ -709,13 +719,14 @@ static void do_info_commands(Monitor *mon, QObject **ret_data)
     cmd_list = qlist_new();
 
     for (cmd = mon_cmds; cmd->name != NULL; cmd++) {
-        if (monitor_handler_ported(cmd) && !compare_cmd(cmd->name, "info")) {
+        if (monitor_handler_ported(cmd) && !monitor_cmd_user_only(cmd) &&
+            !compare_cmd(cmd->name, "info")) {
             qlist_append_obj(cmd_list, get_cmd_dict(cmd->name));
         }
     }
 
     for (cmd = info_cmds; cmd->name != NULL; cmd++) {
-        if (monitor_handler_ported(cmd)) {
+        if (monitor_handler_ported(cmd) && !monitor_cmd_user_only(cmd)) {
             char buf[128];
             snprintf(buf, sizeof(buf), "query-%s", cmd->name);
             qlist_append_obj(cmd_list, get_cmd_dict(buf));
@@ -4207,7 +4218,8 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens)
                       qobject_from_jsonf("{ 'item': %s }", info_item));
     } else {
         cmd = monitor_find_command(cmd_name);
-        if (!cmd || !monitor_handler_ported(cmd)) {
+        if (!cmd || !monitor_handler_ported(cmd)
+            || monitor_cmd_user_only(cmd)) {
             qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name);
             goto err_input;
         }
diff --git a/monitor.h b/monitor.h
index 9582b9c..38b22a4 100644
--- a/monitor.h
+++ b/monitor.h
@@ -17,6 +17,7 @@ extern Monitor *default_mon;
 
 /* flags for monitor commands */
 #define MONITOR_CMD_ASYNC       0x0001
+#define MONITOR_CMD_USER_ONLY   0x0002
 
 /* QMP events */
 typedef enum MonitorEvent {
-- 
1.7.1

  reply	other threads:[~2010-06-28 16:27 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 22:38 [Qemu-devel] [PATCH v4 00/23] qdev path reworks & basic device state visualization Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 01/23] qdev: Rework qtree path abbreviations Jan Kiszka
2010-06-23  8:44   ` Markus Armbruster
2010-06-23  9:32     ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 02/23] qdev: Restrict direct bus addressing via its name Jan Kiszka
2010-06-23  8:45   ` Markus Armbruster
2010-06-23 10:17     ` Jan Kiszka
2010-06-23 11:24       ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 03/23] qdev: Drop ID matching from qtree paths Jan Kiszka
2010-06-23  8:55   ` Markus Armbruster
2010-06-23 10:17     ` Jan Kiszka
2010-06-23 11:38       ` Markus Armbruster
2010-06-23 12:15         ` Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 04/23] qdev: Allow device addressing via 'driver.instance' Jan Kiszka
2010-06-23  9:10   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 05/23] qdev: Convert device and bus lists to QTAILQ Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 06/23] qdev: Push QMP mode checks into qbus_list_bus/dev Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 07/23] qdev: Allow device specification by qtree path for device_del Jan Kiszka
2010-06-23  9:37   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 08/23] qdev: Introduce qdev_iterate_recursive Jan Kiszka
2010-06-23  9:40   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 09/23] monitor: Fix leakage during completion processing Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 10/23] monitor: Fix command completion vs. boolean switches Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists Jan Kiszka
2010-06-23  9:45   ` Markus Armbruster
2010-06-23 10:28     ` Jan Kiszka
2010-06-23 17:08       ` Markus Armbruster
2010-06-28 14:28       ` Luiz Capitulino
2010-06-28 14:40         ` Jan Kiszka
2010-06-28 16:20           ` Luiz Capitulino
2010-06-28 16:27             ` Jan Kiszka [this message]
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 12/23] monitor: Add completion for qdev paths Jan Kiszka
2010-06-23  9:46   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 13/23] monitor: Allow to specify HMP-specifc command arguments Jan Kiszka
2010-06-23  9:56   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 14/23] monitor: return length of printed string via monitor_[v]printf Jan Kiszka
2010-06-23  9:57   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 15/23] monitor: Establish cmd flags and convert the async tag Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 16/23] monitor: Allow to exclude commands from QMP Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 17/23] Add base64 encoder/decoder Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 18/23] QMP: Reserve namespace for complex object classes Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 19/23] QMP: Add QBuffer Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 20/23] monitor: Add basic device state visualization Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 21/23] QMP: Teach basic capability negotiation to python example Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 22/23] QMP: Fix python helper /wrt long return strings Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 23/23] QMP: Add support for buffer class to qmp python helper Jan Kiszka
2010-06-23 10:01 ` [Qemu-devel] [PATCH v4 00/23] qdev path reworks & basic device state visualization Markus Armbruster

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=4C28CD83.1080103@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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).