Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nd5jm-0000DW-M4 for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:43:30 -0500 Received: from [199.232.76.173] (port=42225 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nd5jj-0000AY-Tx for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:43:28 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nd5ji-0001X5-GW for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:43:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29572) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nd5ji-0001Wv-1v for qemu-devel@nongnu.org; Thu, 04 Feb 2010 12:43:26 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o14HhONm022710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 4 Feb 2010 12:43:25 -0500 Received: from blackfin.pond.sub.org (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o14HhNF6019051 for ; Thu, 4 Feb 2010 12:43:24 -0500 From: Markus Armbruster Date: Thu, 04 Feb 2010 18:43:22 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Qemu-devel] Converting existing name=value,... arguments to QMP List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The human monitor uses positional arguments. This is fine; nobody wants to type "info item=network" instead of "info network". QMP uses named arguments. Also fine. Internally, we use named arguments: we pass them as QDict to the command handler. This involves associating positional arguments with names. Works fine. There's one little mess hiding in a corner, though: a few commands abuse a positional argument to get named arguments. That argument has the form of a "parameter string": NAME=VALUE,... For instance: pci_add auto nic model=e1000,macaddr=00:11:22:33:44:55 If we convert this naively, we get in QMP: { "execute": "pci_add", "arguments": { "pci_addr": "auto", "type": "nic", "opts": "model=e1000,macaddr=00:11:22:33:44:55" } } which is silly. Oops, we already did. A more appropriate encoding would be { "execute": "pci_add", "arguments": { "pci_addr": "auto", "type": "nic", "model": "e1000", "macaddr": "00:11:22:33:44:55" } } or maybe { "execute": "pci_add", "arguments": { "pci_addr": "auto", "type": "nic", "opts": { "model": "e1000", "macaddr": "00:11:22:33:44:55" } } } Done right, this involves lifting the parsing of the parameter string from the bowels of the handler up into the human monitor code. Could be somewhat messy. Parsing should be done with qemu_opts_parse(), of course. We need a way to declare which QemuOptList to use. Fortunately, we can look them up by name. We could create argument type 'O', followed by the name, with some suitable delimiter, say parenthesis. pci_add's args_type changes from .args_type = "pci_addr:s,type:s,opts:s?", to .args_type = "pci_addr:s,type:s,opts:O(net)", Opinions?