From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkzYX-0003OV-JA for qemu-devel@nongnu.org; Mon, 25 Nov 2013 12:02:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VkzYS-0004LD-8K for qemu-devel@nongnu.org; Mon, 25 Nov 2013 12:02:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkzYR-0004L3-Ts for qemu-devel@nongnu.org; Mon, 25 Nov 2013 12:02:36 -0500 Message-ID: <52938285.9020605@redhat.com> Date: Mon, 25 Nov 2013 18:01:57 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1385001528-12003-1-git-send-email-imammedo@redhat.com> <1385001528-12003-6-git-send-email-imammedo@redhat.com> <87r4aaxdqt.fsf@blackfin.pond.sub.org> <20131125163642.4d832fd5@nial.usersys.redhat.com> <20131125160337.GB10326@redhat.com> <52937BA2.6020605@redhat.com> <52937E44.10503@redhat.com> In-Reply-To: <52937E44.10503@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 05/27] qapi: add SIZE type parser to string_input_visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: peter.maydell@linaro.org, stefanha@redhat.com, stefanb@linux.vnet.ibm.com, qemu-devel@nongnu.org, hutao@cn.fujitsu.com, quintela@redhat.com, mjt@tls.msk.ru, mdroth@linux.vnet.ibm.com, Markus Armbruster , vasilis.liaskovitis@profitbricks.com, "Michael S. Tsirkin" , kraxel@redhat.com, aliguori@amazon.com, Igor Mammedov , marcel.a@redhat.com, lcapitulino@redhat.com, chegu_vinod@hp.com, afaerber@suse.de -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Il 25/11/2013 17:43, Eric Blake ha scritto: >>> This is unfortunately a counter-example to the rule that HMP >>> commands should always be implemented in terms of their QMP >>> counterparts. I do not believe this is really a problem. It >>> can be fixed later; for now, I think "perfect is the enemy of >>> good" applies. > Hey - I just realized that now that we have anonymous unions, we > could theoretically extend QMP to allow a union between 'int' and > 'string' - if an 'int' is passed, it is in bytes; if a 'string' is > passed, then parse it the way HMP would (so the string "1G" would > be equivalent to the raw int 1073741824). But I don't know if it > will help you (libvirt will still prefer to use raw ints in any > QMP log you read off of libvirt interactions). No, I think this is not the right solution. The parsing should not be handled at the schema level, because there is really no fixed schema (like device_add for example). Right now, we have (almost) always: HMP QMP | | | | hmp_cont (manually written) qmp_marshal_cont (generated) \ / \ / qmp_cont (manually written) where hmp_cont and qmp_marshal_cont both take QDicts, while qmp_cont takes a list of parameters. object_add cannot be described by a schema, so the implementation should take a Visitor instead, and the would have to be written by hand too: HMP QMP | | | | hmp_object_add (manually written) qmp_object_add (manually written) \ / \ / qapi_object_add(const char *type, const char *id, Visitor *v, Error **errp) However, we don't have the infrastructure to do it; hmp_object_add and qmp_object_add cannot yet be simple wrappers around a common function. We can fix that in due time. Paolo -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJSk4KFAAoJEBvWZb6bTYbyyJQP/AlDytO9om7XNu/+/7XGNVYj HxiQSpOo3OgOeyLqJLSV2iBxP1F2YPG3IQ1MQE6aWbPdraMtBt0bnpEQDW5GinX6 f91cnpZi3Yf+3v2/rzmtEs1+3ACOjrn1rVBQiGrbbPiFr7Oa49RD5gWo06M2vZin mfNt3hfUHrmS096IzxGF/sjFstDacnigJZYHHHImqWdHv7BS1I1fK4JptU8ESTEV lLxvphcPKUGoTkLuDSy/6+TwLpr87aLjXFH7GrDUPdmGC/IcJYIDLMP3kjX3KdaA sizqN/pATsxDpOMi/cxnD5onZsFi0J1RiIKxXRbdSLMD0udJUuRrcy19AnUvxhAI gcJy32vj1QWff58S21O7ZbMPCHGClbed3j350wsciumObXneQbcd9iCU//L+Kcfh DqAJmEqSn/kC6vny2JIKL2ZPzETxX6BtnRYIK1lQpYHhy/WC8x9pEs4wltWlVyEQ sY6qq1brNKzCfBpe2WQiHHKHkZ3sw59Pt5bT0ToIpPODIqAyCoeFWh2yXdIEIKmp U7VfBsjk7D6mSqCONgz74Qkjl8olNjlX4vCCXvjTiXghghF84dohNJG7klie75ad arAVmRUTNeR39AY7BCnEKBGFt/OBQal++2ZN/r4AJk7xODs35qF6FMKioAHstt0Z buoUSQmj9X7iuQV3Jriv =fuqh -----END PGP SIGNATURE-----