Patchwork [20/37] target-i386: convert 'hv_spinlocks' to static property

login
register
mail settings
Submitter Igor Mammedov
Date Oct. 22, 2012, 3:03 p.m.
Message ID <1350918203-25198-21-git-send-email-imammedo@redhat.com>
Download mbox | patch
Permalink /patch/193220/
State New
Headers show

Comments

Igor Mammedov - Oct. 22, 2012, 3:03 p.m.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
  * in addition use error_setg() instead of error_set()
---
 target-i386/cpu.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 9cdcae8..122e01a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -148,6 +148,39 @@  PropertyInfo qdev_prop_kvmclock = {
 
 #endif
 
+static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    int64_t value = hyperv_get_spinlock_retries();
+
+    visit_type_int(v, &value, name, errp);
+}
+
+static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
+                                 const char *name, Error **errp)
+{
+    int64_t value;
+
+    visit_type_int(v, &value, name, errp);
+    if (error_is_set(errp)) {
+        return;
+    }
+    if (!value) {
+        error_setg(errp, "Property '%s.%s' doesn't take value '%s'",
+                   object_get_typename(obj), name, "0");
+        return;
+    }
+    hyperv_set_spinlock_retries(value);
+}
+
+PropertyInfo qdev_prop_spinlocks = {
+    .name  = "int",
+    .get   = x86_get_hv_spinlocks,
+    .set   = x86_set_hv_spinlocks,
+};
+#define DEFINE_PROP_HV_SPINLOCKS(_n)                                           \
+    DEFINE_ABSTRACT_PROP(_n, qdev_prop_spinlocks)
+
 static Property cpu_x86_properties[] = {
     DEFINE_PROP_BIT("f-fpu", X86CPU, env.cpuid_features,  0, false),
     DEFINE_PROP_BIT("f-vme", X86CPU, env.cpuid_features,  1, false),
@@ -262,6 +295,7 @@  static Property cpu_x86_properties[] = {
     DEFINE_PROP_BIT("vendor-override", X86CPU, env.cpuid_vendor_override, 0, false),
     DEFINE_PROP_UINT32("xlevel", X86CPU, env.cpuid_xlevel, 0),
     DEFINE_PROP_UINT32("level", X86CPU, env.cpuid_level, 0),
+    DEFINE_PROP_HV_SPINLOCKS("hv_spinlocks"),
     DEFINE_PROP_END_OF_LIST(),
  };