From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=52927 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJoQL-0005HG-Ie for qemu-devel@nongnu.org; Wed, 02 Jun 2010 09:56:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJoQJ-0006hw-Q2 for qemu-devel@nongnu.org; Wed, 02 Jun 2010 09:56:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47339) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJoQJ-0006hf-IM for qemu-devel@nongnu.org; Wed, 02 Jun 2010 09:55:59 -0400 Date: Wed, 2 Jun 2010 10:55:48 -0300 From: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH 8/9] QMP: Introduce qmp_check_input_obj() Message-ID: <20100602105548.74a90768@redhat.com> In-Reply-To: References: <1275424897-32253-1-git-send-email-lcapitulino@redhat.com> <1275424897-32253-9-git-send-email-lcapitulino@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: jan.kiszka@siemens.com, qemu-devel@nongnu.org On Wed, 02 Jun 2010 09:39:26 +0200 Markus Armbruster wrote: > Luiz Capitulino writes: > > > This is similar to qmp_check_client_args(), but checks if > > the input object follows the specification (QMP/qmp-spec.txt > > section 2.3). > > > > As we're limited to three keys, the work here is quite simple: > > we iterate over the input object, each time checking if the > > given argument complies to the specification. > > > > Signed-off-by: Luiz Capitulino > > --- > > monitor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ > > 1 files changed, 45 insertions(+), 0 deletions(-) > > > > diff --git a/monitor.c b/monitor.c > > index 1875731..654b193 100644 > > --- a/monitor.c > > +++ b/monitor.c > > @@ -4271,6 +4271,45 @@ static int qmp_check_client_args(const mon_cmd_t *cmd, QDict *client_args) > > return res.result; > > } > > > > +/* > > + * Input object checking rules > > + * > > + * 1. "execute" key must exist (not checked here) > > + * 2. "execute" key must be a string > > + * 3. "arguments" key must be a dict > > + * 4. "id" key can be anything (ie. json-value) > > Really? Checking qmp-spec.txt... yes, really. Is it a good idea to > permit objects and arrays? It was Avi's suggestion to allow anything, maybe arrays don't make sense but objects do.