cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 5b321366d742d4efe826036108b06796563ea0ed Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <5b321366d742d4efe826036108b06796563ea0ed.1387298827.git.minovotn@redhat.com>
0a122b
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
0a122b
From: "Michael S. Tsirkin" <mst@redhat.com>
0a122b
Date: Tue, 17 Dec 2013 15:17:53 +0100
0a122b
Subject: [PATCH 25/56] qom: add pointer to int property helpers
0a122b
0a122b
RH-Author: Michael S. Tsirkin <mst@redhat.com>
0a122b
Message-id: <1387293161-4085-26-git-send-email-mst@redhat.com>
0a122b
Patchwork-id: 56331
0a122b
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 25/57] qom: add pointer to int property helpers
0a122b
Bugzilla: 1034876
0a122b
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
0a122b
Make it easy to add read-only helpers for simple
0a122b
integer properties in memory.
0a122b
0a122b
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
0a122b
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
0a122b
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
0a122b
Tested-by: Igor Mammedov <imammedo@redhat.com>
0a122b
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
(cherry picked from commit e732ea638705da35445a42dee32691fbe813d3e0)
0a122b
---
0a122b
 include/qom/object.h | 21 ++++++++++++++++++
0a122b
 qom/object.c         | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
0a122b
 2 files changed, 81 insertions(+)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 include/qom/object.h | 21 ++++++++++++++++++
0a122b
 qom/object.c         | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
0a122b
 2 files changed, 81 insertions(+)
0a122b
0a122b
diff --git a/include/qom/object.h b/include/qom/object.h
0a122b
index dbe1413..193bfeb 100644
0a122b
--- a/include/qom/object.h
0a122b
+++ b/include/qom/object.h
0a122b
@@ -790,6 +790,27 @@ void object_property_add(Object *obj, const char *name, const char *type,
0a122b
 void object_property_del(Object *obj, const char *name, Error **errp);
0a122b
 
0a122b
 /**
0a122b
+ * object_property_add_uint8_ptr:
0a122b
+ * object_property_add_uint16_ptr:
0a122b
+ * object_property_add_uint32_ptr:
0a122b
+ * object_property_add_uint64_ptr:
0a122b
+ * @obj: the object to add a property to
0a122b
+ * @name: the name of the property
0a122b
+ * @v: pointer to value
0a122b
+ *
0a122b
+ * Add an integer property in memory.  This function will add a
0a122b
+ * property of the appropriate type.
0a122b
+ */
0a122b
+void object_property_add_uint8_ptr(Object *obj, const char *name,
0a122b
+                                   const uint8_t *v, Error **errp);
0a122b
+void object_property_add_uint16_ptr(Object *obj, const char *name,
0a122b
+                                    const uint16_t *v, Error **errp);
0a122b
+void object_property_add_uint32_ptr(Object *obj, const char *name,
0a122b
+                                    const uint32_t *v, Error **errp);
0a122b
+void object_property_add_uint64_ptr(Object *obj, const char *name,
0a122b
+                                    const uint64_t *v, Error **Errp);
0a122b
+
0a122b
+/**
0a122b
  * object_property_find:
0a122b
  * @obj: the object
0a122b
  * @name: the name of the property
0a122b
diff --git a/qom/object.c b/qom/object.c
0a122b
index 05e2636..d04a96b 100644
0a122b
--- a/qom/object.c
0a122b
+++ b/qom/object.c
0a122b
@@ -1331,6 +1331,66 @@ static char *qdev_get_type(Object *obj, Error **errp)
0a122b
     return g_strdup(object_get_typename(obj));
0a122b
 }
0a122b
 
0a122b
+static void property_get_uint8_ptr(Object *obj, Visitor *v,
0a122b
+                                   void *opaque, const char *name,
0a122b
+                                   Error **errp)
0a122b
+{
0a122b
+    uint8_t value = *(uint8_t *)opaque;
0a122b
+    visit_type_uint8(v, &value, name, errp);
0a122b
+}
0a122b
+
0a122b
+static void property_get_uint16_ptr(Object *obj, Visitor *v,
0a122b
+                                   void *opaque, const char *name,
0a122b
+                                   Error **errp)
0a122b
+{
0a122b
+    uint16_t value = *(uint16_t *)opaque;
0a122b
+    visit_type_uint16(v, &value, name, errp);
0a122b
+}
0a122b
+
0a122b
+static void property_get_uint32_ptr(Object *obj, Visitor *v,
0a122b
+                                   void *opaque, const char *name,
0a122b
+                                   Error **errp)
0a122b
+{
0a122b
+    uint32_t value = *(uint32_t *)opaque;
0a122b
+    visit_type_uint32(v, &value, name, errp);
0a122b
+}
0a122b
+
0a122b
+static void property_get_uint64_ptr(Object *obj, Visitor *v,
0a122b
+                                   void *opaque, const char *name,
0a122b
+                                   Error **errp)
0a122b
+{
0a122b
+    uint64_t value = *(uint64_t *)opaque;
0a122b
+    visit_type_uint64(v, &value, name, errp);
0a122b
+}
0a122b
+
0a122b
+void object_property_add_uint8_ptr(Object *obj, const char *name,
0a122b
+                                   const uint8_t *v, Error **errp)
0a122b
+{
0a122b
+    object_property_add(obj, name, "uint8", property_get_uint8_ptr,
0a122b
+                        NULL, NULL, (void *)v, errp);
0a122b
+}
0a122b
+
0a122b
+void object_property_add_uint16_ptr(Object *obj, const char *name,
0a122b
+                                    const uint16_t *v, Error **errp)
0a122b
+{
0a122b
+    object_property_add(obj, name, "uint16", property_get_uint16_ptr,
0a122b
+                        NULL, NULL, (void *)v, errp);
0a122b
+}
0a122b
+
0a122b
+void object_property_add_uint32_ptr(Object *obj, const char *name,
0a122b
+                                    const uint32_t *v, Error **errp)
0a122b
+{
0a122b
+    object_property_add(obj, name, "uint32", property_get_uint32_ptr,
0a122b
+                        NULL, NULL, (void *)v, errp);
0a122b
+}
0a122b
+
0a122b
+void object_property_add_uint64_ptr(Object *obj, const char *name,
0a122b
+                                    const uint64_t *v, Error **errp)
0a122b
+{
0a122b
+    object_property_add(obj, name, "uint64", property_get_uint64_ptr,
0a122b
+                        NULL, NULL, (void *)v, errp);
0a122b
+}
0a122b
+
0a122b
 static void object_instance_init(Object *obj)
0a122b
 {
0a122b
     object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
0a122b
-- 
0a122b
1.7.11.7
0a122b