]> xenbits.xensource.com Git - people/aperard/qemu-dm.git/commitdiff
target-i386: Introduce feat2prop() for CPU properties
authorIgor Mammedov <imammedo@redhat.com>
Fri, 26 Apr 2013 16:04:32 +0000 (18:04 +0200)
committerAnthony PERARD <anthony.perard@citrix.com>
Mon, 8 Jul 2013 20:51:14 +0000 (21:51 +0100)
This helper replaces '_' with '-' in a uniform way.
As a side effect, even custom mappings must use '-' now.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
[AF: Split off; operate on NUL-terminated string rather than '=' delimiter]
Signed-off-by: Andreas Färber <afaerber@suse.de>
(cherry picked from commit 72ac2e876ddc6158f5b6d5f758d4e38c436010ed)

Conflicts:
target-i386/cpu.c

target-i386/cpu.c

index 787c43640e0f83764da7ae9d9f6814848152c44b..ecc1d48f202a6c0562b946f65bef621469ce30c2 100644 (file)
@@ -1208,6 +1208,16 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
     cpu->env.tsc_khz = value / 1000;
 }
 
+/* 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 = '-';
+    }
+}
+
 static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
 {
     unsigned int i;
@@ -1258,6 +1268,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
                             &minus_svm_features, &minus_7_0_ebx_features);
         } else if ((val = strchr(featurestr, '='))) {
             *val = 0; val++;
+            feat2prop(featurestr);
             if (!strcmp(featurestr, "family")) {
                 char *err;
                 numvalue = strtoul(val, &err, 0);
@@ -1315,10 +1326,10 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
                     x86_cpu_def->vendor3 |= ((uint8_t)val[i + 8]) << (8 * i);
                 }
                 x86_cpu_def->vendor_override = 1;
-            } else if (!strcmp(featurestr, "model_id")) {
+            } else if (!strcmp(featurestr, "model-id")) {
                 pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
                         val);
-            } else if (!strcmp(featurestr, "tsc_freq")) {
+            } else if (!strcmp(featurestr, "tsc-freq")) {
                 int64_t tsc_freq;
                 char *err;
 
@@ -1329,7 +1340,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
                     goto error;
                 }
                 x86_cpu_def->tsc_khz = tsc_freq / 1000;
-            } else if (!strcmp(featurestr, "hv_spinlocks")) {
+            } else if (!strcmp(featurestr, "hv-spinlocks")) {
                 char *err;
                 numvalue = strtoul(val, &err, 0);
                 if (!*val || *err) {