Received: from [140.186.70.92] (port=52233 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OK4xG-00007q-DL for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:35:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OK4xE-0006d3-BN for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:35:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32796) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OK4xE-0006cl-4e for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:35:04 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 3/9] QMP: First half of the new argument checking code References: <1275424897-32253-1-git-send-email-lcapitulino@redhat.com> <1275424897-32253-4-git-send-email-lcapitulino@redhat.com> <20100602105319.54b66398@redhat.com> Date: Thu, 03 Jun 2010 09:35:00 +0200 In-Reply-To: <20100602105319.54b66398@redhat.com> (Luiz Capitulino's message of "Wed, 2 Jun 2010 10:53:19 -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 08:59:11 +0200 > Markus Armbruster wrote: > >> Luiz Capitulino writes: > > [...] > >> > + >> > + type = qobject_to_qstring(obj); >> > + assert(type != NULL); >> > + >> > + if (qstring_get_str(type)[0] == 'O') { >> > + QemuOptsList *opts_list = qemu_find_opts(cmd_arg_name); >> > + assert(opts_list); >> > + res->result = check_opts(opts_list, res->qdict); >> >> I doubt this is the right place for calling check_opts. > > Can you suggest the right place? It's related to check_arg(). I figure it should be dropped along with it in 5/9. The new checker needs to cope with 'O': 1. Client must provide all mandatory arguments 'O' options are optional, so there's nothing to do for check_mandatory_args(). 2. Each argument provided by the client must be valid 3. Each argument provided by the client must have the type expected by the command 'O' comes in two flavours, like the underlying QemuOptsList: desc present (not yet implemented) and empty. Empty desc means we accept any option. check_client_args_type() needs to accept unknown arguments. Is this broken in your patch? Non-empty desc probably should be exploded by qdict_from_args_type(), i.e. instead of putting (NAME, "O") into the dictionary, put the contents of QemuOptsList's desc. Problem: key is obvious (desc->name), but value is not. Maybe you need to represent "expected type" differently, so you can cover both arg_type codes and the QemuOptType values. What its user really needs to know is the set of expected types. Why not put that, in a suitable encoding. I recommend to implement only empty desc here for now, and non-empty when we implement it. Would be nice if you could keep it in mind, so we don't have to dig up too much of the argument checker for it.