aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-02-02 09:43:02 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-02-07 13:52:42 +0100
commit4f2d3d705c1ae7dce29254e2c4645c84e77a74d4 (patch)
tree7f525b04ca416995c309d49869ba53f1b2c9a016 /hw/qdev.h
parent7a7aae21ccab06606cee9aba846d2e30cb616763 (diff)
qdev: initialize properties via QOM
Similarly, use the object properties also to set the default values of the qdev properties. This requires reordering registration and initialization. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/qdev.h')
-rw-r--r--hw/qdev.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/hw/qdev.h b/hw/qdev.h
index 9ccd5c3db5..a3bcf0b11b 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -112,8 +112,9 @@ struct Property {
const char *name;
PropertyInfo *info;
int offset;
- int bitnr;
- void *defval;
+ uint8_t bitnr;
+ uint8_t qtype;
+ int64_t defval;
};
enum PropertyType {
@@ -255,7 +256,8 @@ extern PropertyInfo qdev_prop_pci_devfn;
.info = &(_prop), \
.offset = offsetof(_state, _field) \
+ type_check(_type,typeof_field(_state, _field)), \
- .defval = (_type[]) { _defval }, \
+ .qtype = QTYPE_QINT, \
+ .defval = (_type)_defval, \
}
#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
.name = (_name), \
@@ -263,7 +265,8 @@ extern PropertyInfo qdev_prop_pci_devfn;
.bitnr = (_bit), \
.offset = offsetof(_state, _field) \
+ type_check(uint32_t,typeof_field(_state, _field)), \
- .defval = (bool[]) { (_defval) }, \
+ .qtype = QTYPE_QBOOL, \
+ .defval = (bool)_defval, \
}
#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \