From patchwork Tue Jun 14 20:59:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9176967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E3136021C for ; Tue, 14 Jun 2016 21:12:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2A26281DB for ; Tue, 14 Jun 2016 21:12:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5EC12824A; Tue, 14 Jun 2016 21:12:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A79E281DB for ; Tue, 14 Jun 2016 21:12:53 +0000 (UTC) Received: from localhost ([::1]:38205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCvdj-0002G7-Tq for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 Jun 2016 17:12:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCvQs-00088z-Ig for qemu-devel@nongnu.org; Tue, 14 Jun 2016 16:59:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCvQr-0007ih-FN for qemu-devel@nongnu.org; Tue, 14 Jun 2016 16:59:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCvQr-0007ic-7J for qemu-devel@nongnu.org; Tue, 14 Jun 2016 16:59:33 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A02EC63E12; Tue, 14 Jun 2016 20:59:32 +0000 (UTC) Received: from localhost (vpn1-7-151.gru2.redhat.com [10.97.7.151]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5EKxVvh018481; Tue, 14 Jun 2016 16:59:32 -0400 From: Eduardo Habkost To: Peter Maydell Date: Tue, 14 Jun 2016 17:59:07 -0300 Message-Id: <1465937948-548-10-git-send-email-ehabkost@redhat.com> In-Reply-To: <1465937948-548-1-git-send-email-ehabkost@redhat.com> References: <1465937948-548-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 14 Jun 2016 20:59:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 09/10] target-i386: Consolidate calls of object_property_parse() in x86_cpu_parse_featurestr 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: Paolo Bonzini , Richard Henderson , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 74 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 329d85c..3665fec 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1966,43 +1966,59 @@ static void x86_cpu_parse_featurestr(CPUState *cs, char *features, char *featurestr; /* Single 'key=value" string being parsed */ Error *local_err = NULL; - featurestr = features ? strtok(features, ",") : NULL; + if (!features) { + return; + } + + for (featurestr = strtok(features, ","); + featurestr && !local_err; + featurestr = strtok(NULL, ",")) { + const char *name; + const char *val = NULL; + char *eq = NULL; - while (featurestr) { - char *val; + /* Compatibility syntax: */ if (featurestr[0] == '+') { add_flagname_to_bitmaps(featurestr + 1, plus_features, &local_err); + continue; } else if (featurestr[0] == '-') { add_flagname_to_bitmaps(featurestr + 1, minus_features, &local_err); - } else if ((val = strchr(featurestr, '='))) { - *val = 0; val++; - feat2prop(featurestr); - if (!strcmp(featurestr, "tsc-freq")) { - int64_t tsc_freq; - char *err; - char num[32]; - - tsc_freq = qemu_strtosz_suffix_unit(val, &err, - QEMU_STRTOSZ_DEFSUFFIX_B, 1000); - if (tsc_freq < 0 || *err) { - error_setg(errp, "bad numerical value %s", val); - return; - } - snprintf(num, sizeof(num), "%" PRId64, tsc_freq); - object_property_parse(OBJECT(cpu), num, "tsc-frequency", - &local_err); - } else { - object_property_parse(OBJECT(cpu), val, featurestr, &local_err); - } + continue; + } + + eq = strchr(featurestr, '='); + if (eq) { + *eq++ = 0; + val = eq; } else { - feat2prop(featurestr); - object_property_parse(OBJECT(cpu), "on", featurestr, &local_err); + val = "on"; } - if (local_err) { - error_propagate(errp, local_err); - return; + + feat2prop(featurestr); + name = featurestr; + + /* Special case: */ + if (!strcmp(name, "tsc-freq")) { + int64_t tsc_freq; + char *err; + char num[32]; + + tsc_freq = qemu_strtosz_suffix_unit(val, &err, + QEMU_STRTOSZ_DEFSUFFIX_B, 1000); + if (tsc_freq < 0 || *err) { + error_setg(errp, "bad numerical value %s", val); + return; + } + snprintf(num, sizeof(num), "%" PRId64, tsc_freq); + val = num; + name = "tsc-frequency"; } - featurestr = strtok(NULL, ","); + + object_property_parse(OBJECT(cpu), val, name, &local_err); + } + + if (local_err) { + error_propagate(errp, local_err); } }