[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/37] qdev: export qdev_prop_find() and allow it to
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 09/37] qdev: export qdev_prop_find() and allow it to be used with DeviceClass instead of Object |
Date: |
Mon, 22 Oct 2012 17:02:55 +0200 |
Operating on DeviceClass instead of DEVICE will allow to find static properties
before DEVICE instance is created. It will be used later in
compat_normalize_cpu_model()
to convert legacy CPUID features into corresponding static properties.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/qdev-properties.h | 4 +++-
qom/qdev-properties.c | 16 +++++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
index ddcf774..b2f7142 100644
--- a/hw/qdev-properties.h
+++ b/hw/qdev-properties.h
@@ -98,7 +98,7 @@ extern PropertyInfo qdev_prop_pci_host_devaddr;
{}
/* Set properties between creation and init. */
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
+void *qdev_get_prop_ptr(DeviceState *dev, const Property *prop);
int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
void qdev_prop_set_bit(DeviceState *dev, const char *name, bool value);
void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value);
@@ -128,4 +128,6 @@ void error_set_from_qdev_prop_error(Error **errp, int ret,
DeviceState *dev,
*/
void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
+const Property *qdev_prop_find(const DeviceClass *dc, const char *name);
+
#endif
diff --git a/qom/qdev-properties.c b/qom/qdev-properties.c
index 2e82cb9..cc37479 100644
--- a/qom/qdev-properties.c
+++ b/qom/qdev-properties.c
@@ -6,7 +6,7 @@
#include "net/hub.h"
#include "qapi/qapi-visit-core.h"
-void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
+void *qdev_get_prop_ptr(DeviceState *dev, const Property *prop)
{
void *ptr = dev;
ptr += prop->offset;
@@ -784,13 +784,13 @@ static Property *qdev_prop_walk(Property *props, const
char *name)
return NULL;
}
-static Property *qdev_prop_find(DeviceState *dev, const char *name)
+const Property *qdev_prop_find(const DeviceClass *dc, const char *name)
{
ObjectClass *class;
Property *prop;
/* device properties */
- class = object_get_class(OBJECT(dev));
+ class = OBJECT_CLASS(dc);
do {
prop = qdev_prop_walk(DEVICE_CLASS(class)->props, name);
if (prop) {
@@ -907,10 +907,11 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char
*name, uint8_t *value)
void qdev_prop_set_enum(DeviceState *dev, const char *name, int value)
{
- Property *prop;
+ const Property *prop;
Error *errp = NULL;
+ DeviceClass *dc = DEVICE_CLASS(object_get_class(OBJECT(dev)));
- prop = qdev_prop_find(dev, name);
+ prop = qdev_prop_find(dc, name);
object_property_set_str(OBJECT(dev), prop->info->enum_table[value],
name, &errp);
assert_no_error(errp);
@@ -918,10 +919,11 @@ void qdev_prop_set_enum(DeviceState *dev, const char
*name, int value)
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
{
- Property *prop;
+ const Property *prop;
void **ptr;
+ DeviceClass *dc = DEVICE_CLASS(object_get_class(OBJECT(dev)));
- prop = qdev_prop_find(dev, name);
+ prop = qdev_prop_find(dc, name);
assert(prop && prop->info == &qdev_prop_ptr);
ptr = qdev_get_prop_ptr(dev, prop);
*ptr = value;
--
1.7.11.7
[Qemu-devel] [PATCH 37/37] target-i386: cleanup cpu_x86_find_by_name(), only fill x86_def_t in it, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 26/37] target-i386: convert "vendor" property to static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 30/37] target-i386: convert "model" to static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 24/37] target-i386: use define for cpuid vendor string size, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 09/37] qdev: export qdev_prop_find() and allow it to be used with DeviceClass instead of Object,
Igor Mammedov <=
[Qemu-devel] [PATCH 27/37] target-i386: convert "tsc-frequency" to static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 15/37] target-i386: set default value of "hypervisor" feature using static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 22/37] target-i386: convert 'hv_vapic' to static property, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 05/37] target-i386: move out CPU features initialization in separate func, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 32/37] target-i386: use static properties for setting cpuid features, Igor Mammedov, 2012/10/22
[Qemu-devel] [PATCH 29/37] target-i386: convert "stepping" to static property, Igor Mammedov, 2012/10/22