From: Gerd Hoffmann <kraxel@redhat.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] qdev: keep track of property types, print properties.
Date: Thu, 28 May 2009 17:38:32 +0200 [thread overview]
Message-ID: <4A1EAFF8.4070400@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 251 bytes --]
Hi,
This patch makes qemu keep track od property types. Types are checked
when reading them and the information is also used to print them. The
patch depends on the "info qtree" monitor command patch sent earlier today.
please apply,
Gerd
[-- Attachment #2: 0001-qdev-keep-track-of-property-types-print-properties.patch --]
[-- Type: text/plain, Size: 2606 bytes --]
>From a74479d447f79582eb624bcdcc6ffc9f53d38252 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Thu, 28 May 2009 17:33:54 +0200
Subject: [PATCH] qdev: keep track of property types, print properties.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/qdev.c | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index d2eeb9a..f271b7f 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -33,6 +33,10 @@
struct DeviceProperty {
const char *name;
+ enum {
+ PROP_INT,
+ PROP_PTR,
+ } type;
union {
uint64_t i;
void *ptr;
@@ -138,6 +142,7 @@ void qdev_set_prop_int(DeviceState *dev, const char *name, uint64_t value)
DeviceProperty *prop;
prop = create_prop(dev, name);
+ prop->type = PROP_INT;
prop->value.i = value;
}
@@ -146,6 +151,7 @@ void qdev_set_prop_ptr(DeviceState *dev, const char *name, void *value)
DeviceProperty *prop;
prop = create_prop(dev, name);
+ prop->type = PROP_PTR;
prop->value.ptr = value;
}
@@ -191,7 +197,7 @@ uint64_t qdev_get_prop_int(DeviceState *dev, const char *name, uint64_t def)
DeviceProperty *prop;
prop = find_prop(dev, name);
- if (!prop)
+ if (!prop || prop->type != PROP_INT)
return def;
return prop->value.i;
@@ -203,6 +209,7 @@ void *qdev_get_prop_ptr(DeviceState *dev, const char *name)
prop = find_prop(dev, name);
assert(prop);
+ assert(prop->type == PROP_PTR);
return prop->value.ptr;
}
@@ -318,11 +325,23 @@ void qbus_print(Monitor *mon, BusState *bus, int indent)
{
struct DeviceState *dev;
struct BusState *child;
+ struct DeviceProperty *prop;
monitor_printf(mon, "%*sbus: name %s, type %d\n", indent, "",
bus->name, bus->type);
LIST_FOREACH(dev, &bus->children, sibling) {
- monitor_printf(mon, "%*sdev: %s\n", indent+2, "", dev->type->name);
+ monitor_printf(mon, "%*sdev: %s", indent+2, "", dev->type->name);
+ for (prop = dev->props; prop; prop = prop->next) {
+ switch (prop->type) {
+ case PROP_INT:
+ monitor_printf(mon, ", %s=%" PRId64, prop->name, prop->value.i);
+ break;
+ case PROP_PTR:
+ monitor_printf(mon, ", %s=%p", prop->name, prop->value.ptr);
+ break;
+ }
+ }
+ monitor_printf(mon, "\n");
LIST_FOREACH(child, &dev->child_bus, sibling) {
qbus_print(mon, child, indent+4);
}
--
1.6.2.2
reply other threads:[~2009-05-28 15:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4A1EAFF8.4070400@redhat.com \
--to=kraxel@redhat.com \
--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).