From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=41437 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJp9F-00066Z-2U for qemu-devel@nongnu.org; Wed, 02 Jun 2010 10:42:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJp9A-0006mn-FJ for qemu-devel@nongnu.org; Wed, 02 Jun 2010 10:42:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56944) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OJp9A-0006mf-9E for qemu-devel@nongnu.org; Wed, 02 Jun 2010 10:42:20 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 8/9] QMP: Introduce qmp_check_input_obj() References: <1275424897-32253-1-git-send-email-lcapitulino@redhat.com> <1275424897-32253-9-git-send-email-lcapitulino@redhat.com> <20100602105548.74a90768@redhat.com> Date: Wed, 02 Jun 2010 16:42:17 +0200 In-Reply-To: <20100602105548.74a90768@redhat.com> (Luiz Capitulino's message of "Wed, 2 Jun 2010 10:55:48 -0300") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: jan.kiszka@siemens.com, qemu-devel@nongnu.org Luiz Capitulino writes: > 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. If we permit objects, we can just as well permit anything.