Blame SOURCES/kvm-target-i386-Convert-hv_spinlocks-to-static-property.patch

0a122b
From 8b2c0bd8595d7e175c04f80fbc3035cd538aab2b Mon Sep 17 00:00:00 2001
0a122b
From: Vadim Rozenfeld <vrozenfe@redhat.com>
0a122b
Date: Mon, 3 Mar 2014 12:09:21 +0100
0a122b
Subject: [PATCH 09/12] target-i386: Convert 'hv_spinlocks' to static property
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
RH-Author: Vadim Rozenfeld <vrozenfe@redhat.com>
0a122b
Message-id: <1393848564-10511-10-git-send-email-vrozenfe@redhat.com>
0a122b
Patchwork-id: 57965
0a122b
O-Subject: [RHEL-7.0 qemu-kvm v4 PATCH 09/12] target-i386: Convert 'hv_spinlocks' to static property
0a122b
Bugzilla: 1057173
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Juan Quintela <quintela@redhat.com>
0a122b
0a122b
From: Igor Mammedov <imammedo@redhat.com>
0a122b
0a122b
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
0a122b
Signed-off-by: Andreas Färber <afaerber@suse.de>
0a122b
(cherry picked from commit c8f0f88e2a4cf27bde27a31a98badd61fe212652)
0a122b
---
0a122b
 target-i386/cpu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
0a122b
 1 file changed, 44 insertions(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 target-i386/cpu.c |   45 ++++++++++++++++++++++++++++++++++++++++++++-
0a122b
 1 files changed, 44 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
0a122b
index 7a8cb01..db51f72 100644
0a122b
--- a/target-i386/cpu.c
0a122b
+++ b/target-i386/cpu.c
0a122b
@@ -1511,6 +1511,46 @@ static void x86_cpu_get_feature_words(Object *obj, Visitor *v, void *opaque,
0a122b
     error_propagate(errp, err);
0a122b
 }
0a122b
 
0a122b
+static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
0a122b
+                                 const char *name, Error **errp)
0a122b
+{
0a122b
+    X86CPU *cpu = X86_CPU(obj);
0a122b
+    int64_t value = cpu->hyperv_spinlock_attempts;
0a122b
+
0a122b
+    visit_type_int(v, &value, name, errp);
0a122b
+}
0a122b
+
0a122b
+static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
0a122b
+                                 const char *name, Error **errp)
0a122b
+{
0a122b
+    const int64_t min = 0xFFF;
0a122b
+    const int64_t max = UINT_MAX;
0a122b
+    X86CPU *cpu = X86_CPU(obj);
0a122b
+    Error *err = NULL;
0a122b
+    int64_t value;
0a122b
+
0a122b
+    visit_type_int(v, &value, name, &err;;
0a122b
+    if (err) {
0a122b
+        error_propagate(errp, err);
0a122b
+        return;
0a122b
+    }
0a122b
+
0a122b
+    if (value < min || value > max) {
0a122b
+        error_setg(errp, "Property %s.%s doesn't take value %" PRId64
0a122b
+                  " (minimum: %" PRId64 ", maximum: %" PRId64 ")",
0a122b
+                  object_get_typename(obj), name ? name : "null",
0a122b
+                  value, min, max);
0a122b
+        return;
0a122b
+    }
0a122b
+    cpu->hyperv_spinlock_attempts = value;
0a122b
+}
0a122b
+
0a122b
+static PropertyInfo qdev_prop_spinlocks = {
0a122b
+    .name  = "int",
0a122b
+    .get   = x86_get_hv_spinlocks,
0a122b
+    .set   = x86_set_hv_spinlocks,
0a122b
+};
0a122b
+
0a122b
 static int cpu_x86_find_by_name(X86CPU *cpu, x86_def_t *x86_cpu_def,
0a122b
                                 const char *name)
0a122b
 {
0a122b
@@ -1628,6 +1668,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
0a122b
             } else if (!strcmp(featurestr, "hv-spinlocks")) {
0a122b
                 char *err;
0a122b
                 const int min = 0xFFF;
0a122b
+                char num[32];
0a122b
                 numvalue = strtoul(val, &err, 0);
0a122b
                 if (!*val || *err) {
0a122b
                     error_setg(errp, "bad numerical value %s", val);
0a122b
@@ -1639,7 +1680,8 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
0a122b
                             min);
0a122b
                     numvalue = min;
0a122b
                 }
0a122b
-                cpu->hyperv_spinlock_attempts = numvalue;
0a122b
+                snprintf(num, sizeof(num), "%" PRId32, numvalue);
0a122b
+                object_property_parse(OBJECT(cpu), num, featurestr, errp);
0a122b
             } else {
0a122b
                 error_setg(errp, "unrecognized feature %s", featurestr);
0a122b
                 goto out;
0a122b
@@ -2588,6 +2630,7 @@ static int64_t x86_cpu_get_arch_id(CPUState *cs)
0a122b
 
0a122b
 static Property x86_cpu_properties[] = {
0a122b
     DEFINE_PROP_BOOL("pmu", X86CPU, enable_pmu, false),
0a122b
+    { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
0a122b
     DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false),
0a122b
     DEFINE_PROP_BOOL("hv-vapic", X86CPU, hyperv_vapic, false),
0a122b
     DEFINE_PROP_END_OF_LIST()
0a122b
-- 
0a122b
1.7.1
0a122b