From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdJiu-0000IN-9F for qemu-devel@nongnu.org; Sat, 09 Jun 2012 07:20:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SdJis-0000ZJ-61 for qemu-devel@nongnu.org; Sat, 09 Jun 2012 07:20:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SdJir-0000ZB-Qq for qemu-devel@nongnu.org; Sat, 09 Jun 2012 07:20:50 -0400 Message-ID: <4FD331CE.7080500@redhat.com> Date: Sat, 09 Jun 2012 13:21:50 +0200 From: Laszlo Ersek MIME-Version: 1.0 References: <4FCE7684.2070206@redhat.com> <4FCF5512.9000704@redhat.com> <4FCF5BA8.3010201@suse.de> <4FCF64E4.50701@redhat.com> <20120606151640.GA7733@illuin> <4FCF777B.7000806@redhat.com> <20120606161446.GC7733@illuin> <4FCF8A0F.3020306@redhat.com> <20120606200907.GQ2916@illuin> <4FD090B2.4090305@redhat.com> <20120607152928.GU2916@illuin> <4FD0CCED.3000702@redhat.com> In-Reply-To: <4FD0CCED.3000702@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 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: Paolo Bonzini Cc: qemu-devel@nongnu.org, Michael Roth , =?ISO-8859-1?Q?Andreas_F=E4?= =?ISO-8859-1?Q?rber?= On 06/07/12 17:46, Paolo Bonzini wrote: > Il 07/06/2012 17:29, Michael Roth ha scritto: >> For QEMU <-> X serialization/deserialization, such as a visitor which >> implements a wire encoding (QMP being the only example currently), we need to >> take care that the wire encoding is compatible with the representation >> expected by the other end (according to the QAPI schema or whatever other >> means we use to document it). This holds for QMP/JSON, and we'll need to take >> care that it holds for anything that's added in the future. > > Actually the string visitor does indeed need an uint64 visitor exactly > for this reason. Will be done before 1.2. :) > > Laszlo's option visitor needs the same, but it's not in the tree. Here's my implementation (will post as part of my v2 series). The common part could be extracted to "cutils.c". Laszlo static void opts_type_uint64(Visitor *v, uint64_t *obj, const char *name, Error **errp) { OptsVisitor *ov = DO_UPCAST(OptsVisitor, visitor, v); const QemuOpt *opt; const char *str; opt = lookup_scalar(ov, name, errp); if (!opt) { return; } str = opt->str; if (str != NULL) { while (isspace((unsigned char)*str)) { ++str; } if (*str != '-' && *str != '\0') { unsigned long long val; char *endptr; /* non-empty, non-negative subject sequence */ errno = 0; val = strtoull(str, &endptr, 0); if (*endptr == '\0' && errno == 0 && val <= UINT64_MAX) { *obj = val; processed(ov, name); return; } } } error_set(errp, QERR_INVALID_PARAMETER_VALUE, opt->name, "an uint64 value"); }