From patchwork Thu May 2 13:35:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 240978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A9EEE2C0097 for ; Thu, 2 May 2013 23:37:00 +1000 (EST) Received: from localhost ([::1]:38547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXtgw-00038R-RM for incoming@patchwork.ozlabs.org; Thu, 02 May 2013 09:36:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXtgA-000309-UR for qemu-devel@nongnu.org; Thu, 02 May 2013 09:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UXtg3-0004Wb-QP for qemu-devel@nongnu.org; Thu, 02 May 2013 09:36:10 -0400 Received: from cantor2.suse.de ([195.135.220.15]:46618 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UXtg3-0004Vd-H2 for qemu-devel@nongnu.org; Thu, 02 May 2013 09:36:03 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B67CAA55B5; Thu, 2 May 2013 15:36:01 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Thu, 2 May 2013 15:35:38 +0200 Message-Id: <1367501755-32272-13-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1367501755-32272-1-git-send-email-afaerber@suse.de> References: <1367501755-32272-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH 12/29] target-i386: Introduce feat2prop() for CPU properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Igor Mammedov This helper replaces '_' with '-' in a uniform way. As a side effect, even custom mappings must use '-' now. Signed-off-by: Igor Mammedov [AF: Split off; operate on NUL-terminated string rather than '=' delimiter] Signed-off-by: Andreas Färber --- target-i386/cpu.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index f34ba23..697848d 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1307,6 +1307,16 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *name) return -1; } +/* Convert all '_' in a feature string option name to '-', to make feature + * name conform to QOM property naming rule, which uses '-' instead of '_'. + */ +static inline void feat2prop(char *s) +{ + while ((s = strchr(s, '_'))) { + *s = '-'; + } +} + /* Parse "+feature,-feature,feature=foo" CPU feature string */ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp) @@ -1329,6 +1339,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp) add_flagname_to_bitmaps(featurestr + 1, minus_features); } else if ((val = strchr(featurestr, '='))) { *val = 0; val++; + feat2prop(featurestr); if (!strcmp(featurestr, "family")) { object_property_parse(OBJECT(cpu), val, featurestr, errp); } else if (!strcmp(featurestr, "model")) { @@ -1355,9 +1366,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp) object_property_parse(OBJECT(cpu), num, featurestr, errp); } else if (!strcmp(featurestr, "vendor")) { object_property_parse(OBJECT(cpu), val, featurestr, errp); - } else if (!strcmp(featurestr, "model_id")) { - object_property_parse(OBJECT(cpu), val, "model-id", errp); - } else if (!strcmp(featurestr, "tsc_freq")) { + } else if (!strcmp(featurestr, "model-id")) { + object_property_parse(OBJECT(cpu), val, featurestr, errp); + } else if (!strcmp(featurestr, "tsc-freq")) { int64_t tsc_freq; char *err; char num[32]; @@ -1370,7 +1381,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp) } snprintf(num, sizeof(num), "%" PRId64, tsc_freq); object_property_parse(OBJECT(cpu), num, "tsc-frequency", errp); - } else if (!strcmp(featurestr, "hv_spinlocks")) { + } else if (!strcmp(featurestr, "hv-spinlocks")) { char *err; numvalue = strtoul(val, &err, 0); if (!*val || *err) {