Patchwork [14/22] qdev: move Property-related declarations to qdev-properties.h

login
register
mail settings
Submitter Michael Roth
Date July 24, 2012, 5:20 p.m.
Message ID <1343150454-4677-15-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/172989/
State New
Headers show

Comments

Michael Roth - July 24, 2012, 5:20 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 hw/qdev-properties.h |  130 ++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h            |  126 +-----------------------------------------------
 2 files changed, 131 insertions(+), 125 deletions(-)
 create mode 100644 hw/qdev-properties.h
Anthony Liguori - July 24, 2012, 10:28 p.m.
Michael Roth <mdroth@linux.vnet.ibm.com> writes:

License please.

Regards,

Anthony Liguori

> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  hw/qdev-properties.h |  130 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  hw/qdev.h            |  126 +-----------------------------------------------
>  2 files changed, 131 insertions(+), 125 deletions(-)
>  create mode 100644 hw/qdev-properties.h
>
> diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
> new file mode 100644
> index 0000000..329ef70
> --- /dev/null
> +++ b/hw/qdev-properties.h
> @@ -0,0 +1,130 @@
> +#ifndef QDEV_PROPERTIES_H
> +#define QDEV_PROPERTIES_H
> +
> +#include "qemu/object.h"
> +#include "qemu-queue.h"
> +
> +typedef struct Property Property;
> +
> +typedef struct PropertyInfo PropertyInfo;
> +
> +struct Property {
> +    const char   *name;
> +    PropertyInfo *info;
> +    int          offset;
> +    uint8_t      bitnr;
> +    uint8_t      qtype;
> +    int64_t      defval;
> +};
> +
> +struct PropertyInfo {
> +    const char *name;
> +    const char *legacy_name;
> +    const char **enum_table;
> +    int (*parse)(DeviceState *dev, Property *prop, const char *str);
> +    int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
> +    ObjectPropertyAccessor *get;
> +    ObjectPropertyAccessor *set;
> +    ObjectPropertyRelease *release;
> +};
> +
> +typedef struct GlobalProperty {
> +    const char *driver;
> +    const char *property;
> +    const char *value;
> +    QTAILQ_ENTRY(GlobalProperty) next;
> +} GlobalProperty;
> +
> +extern PropertyInfo qdev_prop_bit;
> +extern PropertyInfo qdev_prop_uint8;
> +extern PropertyInfo qdev_prop_uint16;
> +extern PropertyInfo qdev_prop_uint32;
> +extern PropertyInfo qdev_prop_int32;
> +extern PropertyInfo qdev_prop_uint64;
> +extern PropertyInfo qdev_prop_hex8;
> +extern PropertyInfo qdev_prop_hex32;
> +extern PropertyInfo qdev_prop_hex64;
> +extern PropertyInfo qdev_prop_string;
> +extern PropertyInfo qdev_prop_chr;
> +extern PropertyInfo qdev_prop_ptr;
> +extern PropertyInfo qdev_prop_macaddr;
> +extern PropertyInfo qdev_prop_losttickpolicy;
> +extern PropertyInfo qdev_prop_bios_chs_trans;
> +extern PropertyInfo qdev_prop_drive;
> +extern PropertyInfo qdev_prop_netdev;
> +extern PropertyInfo qdev_prop_vlan;
> +extern PropertyInfo qdev_prop_pci_devfn;
> +extern PropertyInfo qdev_prop_blocksize;
> +extern PropertyInfo qdev_prop_pci_host_devaddr;
> +
> +#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
> +        .name      = (_name),                                    \
> +        .info      = &(_prop),                                   \
> +        .offset    = offsetof(_state, _field)                    \
> +            + type_check(_type,typeof_field(_state, _field)),    \
> +        }
> +#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
> +        .name      = (_name),                                           \
> +        .info      = &(_prop),                                          \
> +        .offset    = offsetof(_state, _field)                           \
> +            + type_check(_type,typeof_field(_state, _field)),           \
> +        .qtype     = QTYPE_QINT,                                        \
> +        .defval    = (_type)_defval,                                    \
> +        }
> +#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) {  \
> +        .name      = (_name),                                    \
> +        .info      = &(qdev_prop_bit),                           \
> +        .bitnr    = (_bit),                                      \
> +        .offset    = offsetof(_state, _field)                    \
> +            + type_check(uint32_t,typeof_field(_state, _field)), \
> +        .qtype     = QTYPE_QBOOL,                                \
> +        .defval    = (bool)_defval,                              \
> +        }
> +
> +#define DEFINE_PROP_UINT8(_n, _s, _f, _d)                       \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
> +#define DEFINE_PROP_UINT16(_n, _s, _f, _d)                      \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
> +#define DEFINE_PROP_UINT32(_n, _s, _f, _d)                      \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
> +#define DEFINE_PROP_INT32(_n, _s, _f, _d)                      \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
> +#define DEFINE_PROP_UINT64(_n, _s, _f, _d)                      \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
> +#define DEFINE_PROP_HEX8(_n, _s, _f, _d)                       \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
> +#define DEFINE_PROP_HEX32(_n, _s, _f, _d)                       \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
> +#define DEFINE_PROP_HEX64(_n, _s, _f, _d)                       \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
> +#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)                   \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
> +
> +#define DEFINE_PROP_PTR(_n, _s, _f)             \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
> +#define DEFINE_PROP_CHR(_n, _s, _f)             \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
> +#define DEFINE_PROP_STRING(_n, _s, _f)             \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
> +#define DEFINE_PROP_NETDEV(_n, _s, _f)             \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
> +#define DEFINE_PROP_VLAN(_n, _s, _f)             \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
> +#define DEFINE_PROP_DRIVE(_n, _s, _f) \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
> +#define DEFINE_PROP_MACADDR(_n, _s, _f)         \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
> +#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
> +                        LostTickPolicy)
> +#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
> +#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
> +    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
> +#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
> +    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
> +
> +#define DEFINE_PROP_END_OF_LIST()               \
> +    {}
> +
> +#endif
> diff --git a/hw/qdev.h b/hw/qdev.h
> index a2cbd9d..c9b5453 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
> @@ -8,10 +8,7 @@
>  #include "qapi/qapi-visit-core.h"
>  #include "qemu/object.h"
>  #include "error.h"
> -
> -typedef struct Property Property;
> -
> -typedef struct PropertyInfo PropertyInfo;
> +#include "qdev-properties.h"
>  
>  typedef struct CompatProperty CompatProperty;
>  
> @@ -122,33 +119,6 @@ struct BusState {
>      QLIST_ENTRY(BusState) sibling;
>  };
>  
> -struct Property {
> -    const char   *name;
> -    PropertyInfo *info;
> -    int          offset;
> -    uint8_t      bitnr;
> -    uint8_t      qtype;
> -    int64_t      defval;
> -};
> -
> -struct PropertyInfo {
> -    const char *name;
> -    const char *legacy_name;
> -    const char **enum_table;
> -    int (*parse)(DeviceState *dev, Property *prop, const char *str);
> -    int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
> -    ObjectPropertyAccessor *get;
> -    ObjectPropertyAccessor *set;
> -    ObjectPropertyRelease *release;
> -};
> -
> -typedef struct GlobalProperty {
> -    const char *driver;
> -    const char *property;
> -    const char *value;
> -    QTAILQ_ENTRY(GlobalProperty) next;
> -} GlobalProperty;
> -
>  /*** Board API.  This should go away once we have a machine config file.  ***/
>  
>  DeviceState *qdev_create(BusState *bus, const char *name);
> @@ -215,100 +185,6 @@ void do_info_qdm(Monitor *mon);
>  int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
>  int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
>  
> -/*** qdev-properties.c ***/
> -
> -extern PropertyInfo qdev_prop_bit;
> -extern PropertyInfo qdev_prop_uint8;
> -extern PropertyInfo qdev_prop_uint16;
> -extern PropertyInfo qdev_prop_uint32;
> -extern PropertyInfo qdev_prop_int32;
> -extern PropertyInfo qdev_prop_uint64;
> -extern PropertyInfo qdev_prop_hex8;
> -extern PropertyInfo qdev_prop_hex32;
> -extern PropertyInfo qdev_prop_hex64;
> -extern PropertyInfo qdev_prop_string;
> -extern PropertyInfo qdev_prop_chr;
> -extern PropertyInfo qdev_prop_ptr;
> -extern PropertyInfo qdev_prop_macaddr;
> -extern PropertyInfo qdev_prop_losttickpolicy;
> -extern PropertyInfo qdev_prop_bios_chs_trans;
> -extern PropertyInfo qdev_prop_drive;
> -extern PropertyInfo qdev_prop_netdev;
> -extern PropertyInfo qdev_prop_vlan;
> -extern PropertyInfo qdev_prop_pci_devfn;
> -extern PropertyInfo qdev_prop_blocksize;
> -extern PropertyInfo qdev_prop_pci_host_devaddr;
> -
> -#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
> -        .name      = (_name),                                    \
> -        .info      = &(_prop),                                   \
> -        .offset    = offsetof(_state, _field)                    \
> -            + type_check(_type,typeof_field(_state, _field)),    \
> -        }
> -#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
> -        .name      = (_name),                                           \
> -        .info      = &(_prop),                                          \
> -        .offset    = offsetof(_state, _field)                           \
> -            + type_check(_type,typeof_field(_state, _field)),           \
> -        .qtype     = QTYPE_QINT,                                        \
> -        .defval    = (_type)_defval,                                    \
> -        }
> -#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) {  \
> -        .name      = (_name),                                    \
> -        .info      = &(qdev_prop_bit),                           \
> -        .bitnr    = (_bit),                                      \
> -        .offset    = offsetof(_state, _field)                    \
> -            + type_check(uint32_t,typeof_field(_state, _field)), \
> -        .qtype     = QTYPE_QBOOL,                                \
> -        .defval    = (bool)_defval,                              \
> -        }
> -
> -#define DEFINE_PROP_UINT8(_n, _s, _f, _d)                       \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
> -#define DEFINE_PROP_UINT16(_n, _s, _f, _d)                      \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
> -#define DEFINE_PROP_UINT32(_n, _s, _f, _d)                      \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
> -#define DEFINE_PROP_INT32(_n, _s, _f, _d)                      \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
> -#define DEFINE_PROP_UINT64(_n, _s, _f, _d)                      \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
> -#define DEFINE_PROP_HEX8(_n, _s, _f, _d)                       \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
> -#define DEFINE_PROP_HEX32(_n, _s, _f, _d)                       \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
> -#define DEFINE_PROP_HEX64(_n, _s, _f, _d)                       \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
> -#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)                   \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
> -
> -#define DEFINE_PROP_PTR(_n, _s, _f)             \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
> -#define DEFINE_PROP_CHR(_n, _s, _f)             \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
> -#define DEFINE_PROP_STRING(_n, _s, _f)             \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
> -#define DEFINE_PROP_NETDEV(_n, _s, _f)             \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
> -#define DEFINE_PROP_VLAN(_n, _s, _f)             \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
> -#define DEFINE_PROP_DRIVE(_n, _s, _f) \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
> -#define DEFINE_PROP_MACADDR(_n, _s, _f)         \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
> -#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
> -                        LostTickPolicy)
> -#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
> -#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
> -    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
> -#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
> -    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
> -
> -#define DEFINE_PROP_END_OF_LIST()               \
> -    {}
> -
>  /* Set properties between creation and init.  */
>  void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
>  int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
> -- 
> 1.7.9.5

Patch

diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h
new file mode 100644
index 0000000..329ef70
--- /dev/null
+++ b/hw/qdev-properties.h
@@ -0,0 +1,130 @@ 
+#ifndef QDEV_PROPERTIES_H
+#define QDEV_PROPERTIES_H
+
+#include "qemu/object.h"
+#include "qemu-queue.h"
+
+typedef struct Property Property;
+
+typedef struct PropertyInfo PropertyInfo;
+
+struct Property {
+    const char   *name;
+    PropertyInfo *info;
+    int          offset;
+    uint8_t      bitnr;
+    uint8_t      qtype;
+    int64_t      defval;
+};
+
+struct PropertyInfo {
+    const char *name;
+    const char *legacy_name;
+    const char **enum_table;
+    int (*parse)(DeviceState *dev, Property *prop, const char *str);
+    int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
+    ObjectPropertyAccessor *get;
+    ObjectPropertyAccessor *set;
+    ObjectPropertyRelease *release;
+};
+
+typedef struct GlobalProperty {
+    const char *driver;
+    const char *property;
+    const char *value;
+    QTAILQ_ENTRY(GlobalProperty) next;
+} GlobalProperty;
+
+extern PropertyInfo qdev_prop_bit;
+extern PropertyInfo qdev_prop_uint8;
+extern PropertyInfo qdev_prop_uint16;
+extern PropertyInfo qdev_prop_uint32;
+extern PropertyInfo qdev_prop_int32;
+extern PropertyInfo qdev_prop_uint64;
+extern PropertyInfo qdev_prop_hex8;
+extern PropertyInfo qdev_prop_hex32;
+extern PropertyInfo qdev_prop_hex64;
+extern PropertyInfo qdev_prop_string;
+extern PropertyInfo qdev_prop_chr;
+extern PropertyInfo qdev_prop_ptr;
+extern PropertyInfo qdev_prop_macaddr;
+extern PropertyInfo qdev_prop_losttickpolicy;
+extern PropertyInfo qdev_prop_bios_chs_trans;
+extern PropertyInfo qdev_prop_drive;
+extern PropertyInfo qdev_prop_netdev;
+extern PropertyInfo qdev_prop_vlan;
+extern PropertyInfo qdev_prop_pci_devfn;
+extern PropertyInfo qdev_prop_blocksize;
+extern PropertyInfo qdev_prop_pci_host_devaddr;
+
+#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
+        .name      = (_name),                                    \
+        .info      = &(_prop),                                   \
+        .offset    = offsetof(_state, _field)                    \
+            + type_check(_type,typeof_field(_state, _field)),    \
+        }
+#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
+        .name      = (_name),                                           \
+        .info      = &(_prop),                                          \
+        .offset    = offsetof(_state, _field)                           \
+            + type_check(_type,typeof_field(_state, _field)),           \
+        .qtype     = QTYPE_QINT,                                        \
+        .defval    = (_type)_defval,                                    \
+        }
+#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) {  \
+        .name      = (_name),                                    \
+        .info      = &(qdev_prop_bit),                           \
+        .bitnr    = (_bit),                                      \
+        .offset    = offsetof(_state, _field)                    \
+            + type_check(uint32_t,typeof_field(_state, _field)), \
+        .qtype     = QTYPE_QBOOL,                                \
+        .defval    = (bool)_defval,                              \
+        }
+
+#define DEFINE_PROP_UINT8(_n, _s, _f, _d)                       \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
+#define DEFINE_PROP_UINT16(_n, _s, _f, _d)                      \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
+#define DEFINE_PROP_UINT32(_n, _s, _f, _d)                      \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
+#define DEFINE_PROP_INT32(_n, _s, _f, _d)                      \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
+#define DEFINE_PROP_UINT64(_n, _s, _f, _d)                      \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
+#define DEFINE_PROP_HEX8(_n, _s, _f, _d)                       \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
+#define DEFINE_PROP_HEX32(_n, _s, _f, _d)                       \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
+#define DEFINE_PROP_HEX64(_n, _s, _f, _d)                       \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
+#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)                   \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
+
+#define DEFINE_PROP_PTR(_n, _s, _f)             \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
+#define DEFINE_PROP_CHR(_n, _s, _f)             \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
+#define DEFINE_PROP_STRING(_n, _s, _f)             \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
+#define DEFINE_PROP_NETDEV(_n, _s, _f)             \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
+#define DEFINE_PROP_VLAN(_n, _s, _f)             \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
+#define DEFINE_PROP_DRIVE(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
+#define DEFINE_PROP_MACADDR(_n, _s, _f)         \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
+#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
+                        LostTickPolicy)
+#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
+#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
+    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
+#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
+    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
+
+#define DEFINE_PROP_END_OF_LIST()               \
+    {}
+
+#endif
diff --git a/hw/qdev.h b/hw/qdev.h
index a2cbd9d..c9b5453 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -8,10 +8,7 @@ 
 #include "qapi/qapi-visit-core.h"
 #include "qemu/object.h"
 #include "error.h"
-
-typedef struct Property Property;
-
-typedef struct PropertyInfo PropertyInfo;
+#include "qdev-properties.h"
 
 typedef struct CompatProperty CompatProperty;
 
@@ -122,33 +119,6 @@  struct BusState {
     QLIST_ENTRY(BusState) sibling;
 };
 
-struct Property {
-    const char   *name;
-    PropertyInfo *info;
-    int          offset;
-    uint8_t      bitnr;
-    uint8_t      qtype;
-    int64_t      defval;
-};
-
-struct PropertyInfo {
-    const char *name;
-    const char *legacy_name;
-    const char **enum_table;
-    int (*parse)(DeviceState *dev, Property *prop, const char *str);
-    int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
-    ObjectPropertyAccessor *get;
-    ObjectPropertyAccessor *set;
-    ObjectPropertyRelease *release;
-};
-
-typedef struct GlobalProperty {
-    const char *driver;
-    const char *property;
-    const char *value;
-    QTAILQ_ENTRY(GlobalProperty) next;
-} GlobalProperty;
-
 /*** Board API.  This should go away once we have a machine config file.  ***/
 
 DeviceState *qdev_create(BusState *bus, const char *name);
@@ -215,100 +185,6 @@  void do_info_qdm(Monitor *mon);
 int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
 
-/*** qdev-properties.c ***/
-
-extern PropertyInfo qdev_prop_bit;
-extern PropertyInfo qdev_prop_uint8;
-extern PropertyInfo qdev_prop_uint16;
-extern PropertyInfo qdev_prop_uint32;
-extern PropertyInfo qdev_prop_int32;
-extern PropertyInfo qdev_prop_uint64;
-extern PropertyInfo qdev_prop_hex8;
-extern PropertyInfo qdev_prop_hex32;
-extern PropertyInfo qdev_prop_hex64;
-extern PropertyInfo qdev_prop_string;
-extern PropertyInfo qdev_prop_chr;
-extern PropertyInfo qdev_prop_ptr;
-extern PropertyInfo qdev_prop_macaddr;
-extern PropertyInfo qdev_prop_losttickpolicy;
-extern PropertyInfo qdev_prop_bios_chs_trans;
-extern PropertyInfo qdev_prop_drive;
-extern PropertyInfo qdev_prop_netdev;
-extern PropertyInfo qdev_prop_vlan;
-extern PropertyInfo qdev_prop_pci_devfn;
-extern PropertyInfo qdev_prop_blocksize;
-extern PropertyInfo qdev_prop_pci_host_devaddr;
-
-#define DEFINE_PROP(_name, _state, _field, _prop, _type) { \
-        .name      = (_name),                                    \
-        .info      = &(_prop),                                   \
-        .offset    = offsetof(_state, _field)                    \
-            + type_check(_type,typeof_field(_state, _field)),    \
-        }
-#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) { \
-        .name      = (_name),                                           \
-        .info      = &(_prop),                                          \
-        .offset    = offsetof(_state, _field)                           \
-            + type_check(_type,typeof_field(_state, _field)),           \
-        .qtype     = QTYPE_QINT,                                        \
-        .defval    = (_type)_defval,                                    \
-        }
-#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) {  \
-        .name      = (_name),                                    \
-        .info      = &(qdev_prop_bit),                           \
-        .bitnr    = (_bit),                                      \
-        .offset    = offsetof(_state, _field)                    \
-            + type_check(uint32_t,typeof_field(_state, _field)), \
-        .qtype     = QTYPE_QBOOL,                                \
-        .defval    = (bool)_defval,                              \
-        }
-
-#define DEFINE_PROP_UINT8(_n, _s, _f, _d)                       \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
-#define DEFINE_PROP_UINT16(_n, _s, _f, _d)                      \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t)
-#define DEFINE_PROP_UINT32(_n, _s, _f, _d)                      \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t)
-#define DEFINE_PROP_INT32(_n, _s, _f, _d)                      \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t)
-#define DEFINE_PROP_UINT64(_n, _s, _f, _d)                      \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t)
-#define DEFINE_PROP_HEX8(_n, _s, _f, _d)                       \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex8, uint8_t)
-#define DEFINE_PROP_HEX32(_n, _s, _f, _d)                       \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex32, uint32_t)
-#define DEFINE_PROP_HEX64(_n, _s, _f, _d)                       \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_hex64, uint64_t)
-#define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d)                   \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t)
-
-#define DEFINE_PROP_PTR(_n, _s, _f)             \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, void*)
-#define DEFINE_PROP_CHR(_n, _s, _f)             \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharDriverState*)
-#define DEFINE_PROP_STRING(_n, _s, _f)             \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_string, char*)
-#define DEFINE_PROP_NETDEV(_n, _s, _f)             \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, VLANClientState*)
-#define DEFINE_PROP_VLAN(_n, _s, _f)             \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_vlan, VLANState*)
-#define DEFINE_PROP_DRIVE(_n, _s, _f) \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_drive, BlockDriverState *)
-#define DEFINE_PROP_MACADDR(_n, _s, _f)         \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr)
-#define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \
-                        LostTickPolicy)
-#define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int)
-#define DEFINE_PROP_BLOCKSIZE(_n, _s, _f, _d) \
-    DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blocksize, uint16_t)
-#define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \
-    DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress)
-
-#define DEFINE_PROP_END_OF_LIST()               \
-    {}
-
 /* Set properties between creation and init.  */
 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);