qdev: move qdev->info to class
Right now, DeviceInfo acts as the class for qdev. In order to switch to a
proper ObjectClass derivative, we need to ween all of the callers off of
interacting directly with the info pointer.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/hw/qdev.h b/hw/qdev.h
index 1e01a04..e13111f 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -69,9 +69,12 @@
#define TYPE_DEVICE "device"
#define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
+#define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
+#define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
typedef struct DeviceClass {
ObjectClass parent_class;
+ DeviceInfo *info;
} DeviceClass;
/* This structure should not be accessed directly. We declare it here
@@ -83,7 +86,6 @@
enum DevState state;
QemuOpts *opts;
int hotplugged;
- DeviceInfo *info;
BusState *parent_bus;
int num_gpio_out;
qemu_irq *gpio_out;
@@ -389,9 +391,19 @@
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
Property *prop, const char *value);
+DeviceInfo *qdev_get_info(DeviceState *dev);
+
static inline const char *qdev_fw_name(DeviceState *dev)
{
- return dev->info->fw_name ? : dev->info->alias ? : dev->info->name;
+ DeviceInfo *info = qdev_get_info(dev);
+
+ if (info->fw_name) {
+ return info->fw_name;
+ } else if (info->alias) {
+ return info->alias;
+ }
+
+ return info->name;
}
char *qdev_get_fw_dev_path(DeviceState *dev);