[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/23] qdev: allow classes to overload qdev function
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 05/23] qdev: allow classes to overload qdev functions |
Date: |
Mon, 30 Jan 2012 15:08:43 -0600 |
This allows us to drop per-Device registration functions by allowing the
class_init functions to overload qdev methods.
Signed-off-by: Anthony Liguori <address@hidden>
---
hw/qdev.c | 53 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index b273cd2..c9f890c 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -50,21 +50,39 @@ static void qdev_subclass_init(ObjectClass *klass, void
*data)
DeviceClass *dc = DEVICE_CLASS(klass);
DeviceInfo *info = data;
- dc->fw_name = info->fw_name;
- dc->alias = info->alias;
- dc->desc = info->desc;
- dc->props = info->props;
- dc->no_user = info->no_user;
-
- dc->reset = info->reset;
-
- dc->vmsd = info->vmsd;
-
- dc->init = info->init;
- dc->unplug = info->unplug;
- dc->exit = info->exit;
- dc->bus_info = info->bus_info;
-
+ if (info->fw_name) {
+ dc->fw_name = info->fw_name;
+ }
+ if (info->alias) {
+ dc->alias = info->alias;
+ }
+ if (info->desc) {
+ dc->desc = info->desc;
+ }
+ if (info->props) {
+ dc->props = info->props;
+ }
+ if (info->no_user) {
+ dc->no_user = info->no_user;
+ }
+ if (info->reset) {
+ dc->reset = info->reset;
+ }
+ if (info->vmsd) {
+ dc->vmsd = info->vmsd;
+ }
+ if (info->init) {
+ dc->init = info->init;
+ }
+ if (info->unplug) {
+ dc->unplug = info->unplug;
+ }
+ if (info->exit) {
+ dc->exit = info->exit;
+ }
+ if (info->bus_info) {
+ dc->bus_info = info->bus_info;
+ }
if (info->class_init) {
info->class_init(klass, data);
}
@@ -131,8 +149,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const
char *name)
/* first check device names */
for (info = device_info_list; info != NULL; info = info->next) {
- if (bus_info && info->bus_info != bus_info)
- continue;
if (strcmp(info->name, name) != 0)
continue;
return info;
@@ -140,8 +156,6 @@ static DeviceInfo *qdev_find_info(BusInfo *bus_info, const
char *name)
/* failing that check the aliases */
for (info = device_info_list; info != NULL; info = info->next) {
- if (bus_info && info->bus_info != bus_info)
- continue;
if (!info->alias)
continue;
if (strcmp(info->alias, name) != 0)
@@ -164,7 +178,6 @@ static DeviceState *qdev_create_from_info(BusState *bus,
DeviceInfo *info)
DeviceState *dev;
Property *prop;
- assert(bus->info == info->bus_info);
dev = DEVICE(object_new(info->name));
dev->parent_bus = bus;
qdev_prop_set_defaults(dev, qdev_get_props(dev));
--
1.7.4.1
- [Qemu-devel] [PATCH 01/23] usb-hid: simplify class initialization a bit, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 03/23] qdev: make DeviceInfo private, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 04/23] qdev: remove info from class, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 06/23] qdev: refactor device creation to allow bus_info to be set only in class, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 07/23] qdev: kill off DeviceInfo list, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 05/23] qdev: allow classes to overload qdev functions,
Anthony Liguori <=
- [Qemu-devel] [PATCH 18/23] qom: accept any compatible type when setting a link property, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 08/23] qdev: register all types natively through QEMU Object Model, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 11/23] qom: allow object_class_foreach to take additional parameters to refine search, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 15/23] qdev: split out UI portions into a new function, Anthony Liguori, 2012/01/30
- [Qemu-devel] [PATCH 21/23] object: sure up reference counting, Anthony Liguori, 2012/01/30