From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Andreas Faerber <andreas.faerber@web.de>,
Anthony Liguori <aliguori@us.ibm.com>,
Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH 03/23] qdev: make DeviceInfo private
Date: Mon, 30 Jan 2012 15:08:41 -0600 [thread overview]
Message-ID: <1327957741-5842-3-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1327957741-5842-1-git-send-email-aliguori@us.ibm.com>
Introduce accessors and remove any code that directly accesses DeviceInfo
members.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/pci.c | 13 ++++++++-----
hw/qdev-properties.c | 4 ++--
hw/qdev.c | 30 +++++++++++++++++++++++++++++-
hw/qdev.h | 24 +++++++++---------------
4 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index 6a0b1f5..235ea00 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1673,6 +1673,7 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
char *path;
void *ptr;
char name[32];
+ const VMStateDescription *vmsd;
if (!pdev->romfile)
return 0;
@@ -1709,10 +1710,13 @@ static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
size = 1 << qemu_fls(size);
}
- if (qdev_get_info(&pdev->qdev)->vmsd)
- snprintf(name, sizeof(name), "%s.rom", qdev_get_info(&pdev->qdev)->vmsd->name);
- else
+ vmsd = qdev_get_vmsd(DEVICE(pdev));
+
+ if (vmsd) {
+ snprintf(name, sizeof(name), "%s.rom", vmsd->name);
+ } else {
snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev)));
+ }
pdev->has_rom = true;
memory_region_init_ram(&pdev->rom, name, size);
vmstate_register_ram(&pdev->rom, &pdev->qdev);
@@ -1953,8 +1957,7 @@ static int pci_qdev_find_recursive(PCIBus *bus,
}
/* roughly check if given qdev is pci device */
- if (qdev_get_info(qdev)->init == &pci_qdev_init &&
- qdev->parent_bus->info == &pci_bus_info) {
+ if (object_dynamic_cast(OBJECT(qdev), TYPE_PCI_DEVICE)) {
*pdev = PCI_DEVICE(qdev);
return 0;
}
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index c98219a..724dce5 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -966,7 +966,7 @@ static Property *qdev_prop_find(DeviceState *dev, const char *name)
Property *prop;
/* device properties */
- prop = qdev_prop_walk(qdev_get_info(dev)->props, name);
+ prop = qdev_prop_walk(qdev_get_props(dev), name);
if (prop)
return prop;
@@ -1166,7 +1166,7 @@ void qdev_prop_set_globals(DeviceState *dev)
QTAILQ_FOREACH(prop, &global_props, next) {
if (strcmp(object_get_typename(OBJECT(dev)), prop->driver) != 0 &&
- strcmp(qdev_get_info(dev)->bus_info->name, prop->driver) != 0) {
+ strcmp(qdev_get_bus_info(dev)->name, prop->driver) != 0) {
continue;
}
if (qdev_prop_parse(dev, prop->property, prop->value) != 0) {
diff --git a/hw/qdev.c b/hw/qdev.c
index a8c24de..18c5876 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -60,11 +60,39 @@ static void qdev_subclass_init(ObjectClass *klass, void *data)
}
}
-DeviceInfo *qdev_get_info(DeviceState *dev)
+static DeviceInfo *qdev_get_info(DeviceState *dev)
{
return DEVICE_GET_CLASS(dev)->info;
}
+const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
+{
+ return qdev_get_info(dev)->vmsd;
+}
+
+BusInfo *qdev_get_bus_info(DeviceState *dev)
+{
+ return qdev_get_info(dev)->bus_info;
+}
+
+Property *qdev_get_props(DeviceState *dev)
+{
+ return qdev_get_info(dev)->props;
+}
+
+const char *qdev_fw_name(DeviceState *dev)
+{
+ DeviceInfo *info = qdev_get_info(dev);
+
+ if (info->fw_name) {
+ return info->fw_name;
+ } else if (info->alias) {
+ return info->alias;
+ }
+
+ return object_get_typename(OBJECT(dev));
+}
+
void qdev_register_subclass(DeviceInfo *info, const char *parent)
{
TypeInfo type_info = {};
diff --git a/hw/qdev.h b/hw/qdev.h
index c9572a5..dc6a6fe 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -398,22 +398,8 @@ 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)
-{
- DeviceInfo *info = qdev_get_info(dev);
-
- if (info->fw_name) {
- return info->fw_name;
- } else if (info->alias) {
- return info->alias;
- }
-
- return object_get_typename(OBJECT(dev));
-}
-
char *qdev_get_fw_dev_path(DeviceState *dev);
+
/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
extern struct BusInfo system_bus_info;
@@ -661,4 +647,12 @@ void qdev_machine_init(void);
*/
void device_reset(DeviceState *dev);
+const VMStateDescription *qdev_get_vmsd(DeviceState *dev);
+
+const char *qdev_fw_name(DeviceState *dev);
+
+BusInfo *qdev_get_bus_info(DeviceState *dev);
+
+Property *qdev_get_props(DeviceState *dev);
+
#endif
--
1.7.4.1
next prev parent reply other threads:[~2012-01-30 21:09 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-30 21:08 [Qemu-devel] [PATCH 01/23] usb-hid: simplify class initialization a bit Anthony Liguori
2012-01-30 21:08 ` Anthony Liguori [this message]
2012-01-30 22:31 ` [Qemu-devel] [PATCH 03/23] qdev: make DeviceInfo private Andreas Färber
2012-01-30 21:08 ` [Qemu-devel] [PATCH 04/23] qdev: remove info from class Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 05/23] qdev: allow classes to overload qdev functions Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 06/23] qdev: refactor device creation to allow bus_info to be set only in class Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 07/23] qdev: kill off DeviceInfo list Anthony Liguori
2012-01-31 13:51 ` Andreas Färber
2012-01-30 21:08 ` [Qemu-devel] [PATCH 08/23] qdev: register all types natively through QEMU Object Model Anthony Liguori
2012-01-30 22:29 ` Peter Maydell
2012-01-30 22:43 ` Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 09/23] qdev: kill of DeviceInfo Anthony Liguori
2012-01-31 13:34 ` Andreas Färber
2012-02-01 19:46 ` Peter Maydell
2012-02-01 19:56 ` Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 10/23] qdev: remove baked in notion of aliases Anthony Liguori
2012-01-31 7:44 ` Paolo Bonzini
2012-01-30 21:08 ` [Qemu-devel] [PATCH 11/23] qom: allow object_class_foreach to take additional parameters to refine search Anthony Liguori
2012-01-31 13:42 ` Andreas Färber
2012-01-30 21:08 ` [Qemu-devel] [PATCH 12/23] qom: add new command to search for types Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 13/23] qdev: split out common init to instance_init Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 14/23] qdev: refactor away qdev_create_from_info Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 15/23] qdev: split out UI portions into a new function Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 16/23] qdev: nuke qdev_init_chardev() Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 17/23] qom: move properties from qdev to object Anthony Liguori
2012-01-31 7:46 ` Paolo Bonzini
2012-02-01 20:01 ` Anthony Liguori
2012-02-01 20:33 ` Paolo Bonzini
2012-01-30 21:08 ` [Qemu-devel] [PATCH 18/23] qom: accept any compatible type when setting a link property Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 19/23] qdev: implement cleanup logic in finalize Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 20/23] info qdm: do not require a parent_bus to be set Anthony Liguori
2012-01-30 21:08 ` [Qemu-devel] [PATCH 21/23] object: sure up reference counting Anthony Liguori
2012-01-31 7:49 ` Paolo Bonzini
2012-02-01 19:47 ` Peter Maydell
2012-02-01 19:55 ` Anthony Liguori
2012-01-30 21:09 ` [Qemu-devel] [PATCH 22/23] container: make a decendent of Object Anthony Liguori
2012-01-31 7:50 ` Paolo Bonzini
2012-01-31 9:21 ` Andreas Färber
2012-01-31 9:31 ` Paolo Bonzini
2012-02-01 19:48 ` Peter Maydell
2012-01-30 21:09 ` [Qemu-devel] [PATCH 23/23] not-for-upstream: fix device_del Anthony Liguori
2012-01-30 21:16 ` [Qemu-devel] [PATCH 00/23] qom: use Type system to register all devices Anthony Liguori
2012-01-30 22:46 ` Anthony Liguori
2012-02-01 19:55 ` Peter Maydell
2012-02-01 20:10 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327957741-5842-3-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=andreas.faerber@web.de \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).