From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSsc3-0004i5-0s for qemu-devel@nongnu.org; Fri, 11 May 2012 12:22:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSsc1-0002Rh-AJ for qemu-devel@nongnu.org; Fri, 11 May 2012 12:22:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23718) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSsc1-0002RX-1F for qemu-devel@nongnu.org; Fri, 11 May 2012 12:22:37 -0400 Date: Fri, 11 May 2012 13:22:33 -0300 From: Luiz Capitulino Message-ID: <20120511132233.6732a013@doriath.home> In-Reply-To: <1335558083-26196-3-git-send-email-mdroth@linux.vnet.ibm.com> References: <1335558083-26196-1-git-send-email-mdroth@linux.vnet.ibm.com> <1335558083-26196-3-git-send-email-mdroth@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/7] qapi: QMP input visitor, handle floats parsed as ints List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, afaerber@suse.de On Fri, 27 Apr 2012 15:21:18 -0500 Michael Roth wrote: > JSON numbers can be interpreted as either integers or floating point > values depending on their representation. As a result, QMP input visitor > might visit a QInt when it was expecting a QFloat, so add handling to > account for this. > > Signed-off-by: Michael Roth > --- > qapi/qmp-input-visitor.c | 9 +++++++-- > 1 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c > index 4cdc47d..bc91134 100644 > --- a/qapi/qmp-input-visitor.c > +++ b/qapi/qmp-input-visitor.c > @@ -246,13 +246,18 @@ static void qmp_input_type_number(Visitor *v, double *obj, const char *name, > QmpInputVisitor *qiv = to_qiv(v); > QObject *qobj = qmp_input_get_object(qiv, name); > > - if (!qobj || qobject_type(qobj) != QTYPE_QFLOAT) { > + if (!qobj || (qobject_type(qobj) != QTYPE_QFLOAT && > + qobject_type(qobj) != QTYPE_QINT)) { > error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", > "double"); s/double/number It's also important to note that migrate_set_downtime is (positively) affected by this change. Today, it only accepts a double, eg.: { "execute": "migrate_set_downtime", "arguments": { "value": 1 } } { "error": { "class": "InvalidParameterType", "desc": "Invalid parameter type for 'value', expected: double", "data": { "name": "value", "expected": "double" } } } That's a bug (as it's documented to accept a number) and this patch fixes it. There's an interface change, but I think it won't cause problems in practice. Please, fix the error message above and would be nice to get this (and patch 02/07) as a separate series for 1.1. > return; > } > > - *obj = qfloat_get_double(qobject_to_qfloat(qobj)); > + if (qobject_type(qobj) == QTYPE_QINT) { > + *obj = qint_get_int(qobject_to_qint(qobj)); > + } else { > + *obj = qfloat_get_double(qobject_to_qfloat(qobj)); > + } > } > > static void qmp_input_start_optional(Visitor *v, bool *present,