From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sdyhk-00033F-5m for qemu-devel@nongnu.org; Mon, 11 Jun 2012 03:06:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sdyhf-0004k7-Cs for qemu-devel@nongnu.org; Mon, 11 Jun 2012 03:06:23 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:49687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sdyhf-0004jw-44 for qemu-devel@nongnu.org; Mon, 11 Jun 2012 03:06:19 -0400 Received: by pbbro12 with SMTP id ro12so5718867pbb.4 for ; Mon, 11 Jun 2012 00:06:17 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FD598E2.80108@redhat.com> Date: Mon, 11 Jun 2012 09:06:10 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1337683555-13301-1-git-send-email-lersek@redhat.com> <4FCE7684.2070206@redhat.com> <4FCF5512.9000704@redhat.com> <4FD36C30.40804@redhat.com> In-Reply-To: <4FD36C30.40804@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 00/16] introduce OptsVisitor, rebase -net/-netdev parsing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: Michael Roth , qemu-devel@nongnu.org, =?ISO-8859-15?Q?Andreas_F=E4rber?= Il 09/06/2012 17:30, Laszlo Ersek ha scritto: > The net init functions all depend on integer optarg values being > non-negative. Originally this is (or should be...) ensured by > parse_option_number() [qemu-option.c] calling strtoull(), and "more > recently" by opts_type_int() in this series. > > i. If the opts visitor should be able to parse negative integers > (currently not necessary for net/netdev types), then I have to change > opts_type_int() accordingly. To restore the non-negative invariants, I > must either reintroduce ">= 0" manual checks in the net init funcs > (conflicts with our frugality), or constrain myself to > uint8/uint16/uint32/uint64 field types in the json. I think this is the best choice. Use uint* types. > +{ 'type': 'NetdevVdeOptions', > + 'data': { > + '*sock': 'str', > + '*port': 'int', > + '*group': 'str', > + '*mode': 'int' } } Lucky, both of these can be uint16 so that assignment to int is safe. > +{ 'type': 'NetLegacy', > + 'data': { > + '*vlan': 'int', > + 'name': 'str', > + 'opts': 'NetClientOptions' } } Just a 32-bit token, int32 will be fine. > +{ 'type': 'NetLegacyNicOptions', > + 'data': { > + '*netdev': 'str', > + '*macaddr': 'str', > + '*model': 'str', > + '*addr': 'str', > + '*vectors': 'int' } } Has to be tested anyway against 0x7ffffff (only six "f"s), so uint32 is good here too. Paolo