From patchwork Wed May 17 15:38:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 763670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wSdlV2y4Nz9s7F for ; Thu, 18 May 2017 01:39:02 +1000 (AEST) Received: from localhost ([::1]:49535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB12R-0000lP-UL for incoming@patchwork.ozlabs.org; Wed, 17 May 2017 11:38:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dB11r-0000l1-A9 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dB11o-0004q7-94 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dB11o-0004pu-34 for qemu-devel@nongnu.org; Wed, 17 May 2017 11:38:20 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11FBE8535D for ; Wed, 17 May 2017 15:38:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11FBE8535D Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 11FBE8535D Received: from secure.mitica (ovpn-117-44.ams2.redhat.com [10.36.117.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EEC817A7B; Wed, 17 May 2017 15:38:17 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 17 May 2017 17:38:08 +0200 Message-Id: <20170517153812.21993-2-quintela@redhat.com> In-Reply-To: <20170517153812.21993-1-quintela@redhat.com> References: <20170517153812.21993-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 May 2017 15:38:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/5] hmp: Use visitor api for hmp_migrate_set_parameter() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We only use it for int64 at this point, I am not able to find a way to parse an int with MiB units. Signed-off-by: Juan Quintela Reviewed-by: Markus Armbruster --- hmp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hmp.c b/hmp.c index b9dd933..acbbc5c 100644 --- a/hmp.c +++ b/hmp.c @@ -29,6 +29,7 @@ #include "monitor/qdev.h" #include "qapi/opts-visitor.h" #include "qapi/qmp/qerror.h" +#include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" #include "qapi/util.h" #include "qapi-visit.h" @@ -1523,8 +1524,9 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) { const char *param = qdict_get_str(qdict, "parameter"); const char *valuestr = qdict_get_str(qdict, "value"); + Visitor *v = string_input_visitor_new(valuestr); uint64_t valuebw = 0; - long valueint = 0; + int64_t valueint = 0; Error *err = NULL; bool use_int_value = false; int i, ret; @@ -1582,9 +1584,8 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) } if (use_int_value) { - if (qemu_strtol(valuestr, NULL, 10, &valueint) < 0) { - error_setg(&err, "Unable to parse '%s' as an int", - valuestr); + visit_type_int(v, param, &valueint, &err); + if (err) { goto cleanup; } /* Set all integers; only one has_FOO will be set, and @@ -1608,6 +1609,7 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) } cleanup: + visit_free(v); if (err) { error_report_err(err); }