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>
This commit is contained in:
Anthony Liguori 2011-12-04 11:08:36 -06:00
parent 32fea4025b
commit 30fbb9fc7c
33 changed files with 119 additions and 93 deletions

View file

@ -69,9 +69,12 @@ typedef struct DeviceProperty
#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 @@ struct DeviceState {
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 qdev_prop_set_globals(DeviceState *dev);
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);