diff options
author | Fam Zheng <famz@redhat.com> | 2017-07-14 10:14:52 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-07-14 12:04:42 +0200 |
commit | 5b4ff3c661374b2df247e12b58667e4643b30af1 (patch) | |
tree | 96beea107bb99a102dbbb423e061d841adf788a5 /include | |
parent | faabdbb792889bf011a593578d1de51e14616bb7 (diff) |
qdev: Introduce DEFINE_PROP_LINK
This property can be used to replace the object_property_add_link in
device code, to add a link to other objects, which is a common pattern.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170714021509.23681-4-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/hw/qdev-core.h | 1 | ||||
-rw-r--r-- | include/hw/qdev-properties.h | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 33518eec12..08d1d2c6f9 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -233,6 +233,7 @@ struct Property { int arrayoffset; PropertyInfo *arrayinfo; int arrayfieldsize; + const char *link_type; }; struct PropertyInfo { diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 9edded29d2..876ba2e283 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -30,6 +30,7 @@ extern PropertyInfo qdev_prop_pci_devfn; extern PropertyInfo qdev_prop_blocksize; extern PropertyInfo qdev_prop_pci_host_devaddr; extern PropertyInfo qdev_prop_arraylen; +extern PropertyInfo qdev_prop_link; #define DEFINE_PROP(_name, _state, _field, _prop, _type) { \ .name = (_name), \ @@ -117,6 +118,14 @@ extern PropertyInfo qdev_prop_arraylen; .arrayoffset = offsetof(_state, _arrayfield), \ } +#define DEFINE_PROP_LINK(_name, _state, _field, _type, _ptr_type) { \ + .name = (_name), \ + .info = &(qdev_prop_link), \ + .offset = offsetof(_state, _field) \ + + type_check(_ptr_type, typeof_field(_state, _field)), \ + .link_type = _type, \ + } + #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ DEFINE_PROP_UNSIGNED(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ |