From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Paul Brook <paul@codesourcery.com>,
Gerd Hoffman <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] Introduce CharDriverState qdev property type
Date: Fri, 17 Jul 2009 09:41:24 -0500 [thread overview]
Message-ID: <1247841685-18495-2-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1247841685-18495-1-git-send-email-aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
hw/qdev-properties.c | 23 +++++++++++++++++++++++
hw/qdev.h | 4 ++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 06c25af..bfe77d1 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -145,6 +145,24 @@ PropertyInfo qdev_prop_macaddr = {
.print = print_mac,
};
+/* -- character device --- */
+
+static int print_chrdev(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+ void **ptr = qdev_get_prop_ptr(dev, prop);
+ CharDriverState *chr = *ptr;
+
+ return snprintf(dest, len, "chr: %s", chr->label);
+}
+
+PropertyInfo qdev_prop_chrdev = {
+ .name = "chrdev",
+ .type = PROP_TYPE_CHRDEV,
+ .size = sizeof(CharDriverState*),
+ .print = print_chrdev,
+};
+
+
/* --- public helpers --- */
static Property *qdev_prop_walk(Property *props, const char *name)
@@ -229,6 +247,11 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);
}
+void qdev_prop_set_chrdev(DeviceState *dev, const char *name, CharDriverState *value)
+{
+ qdev_prop_set(dev, name, &value, PROP_TYPE_CHRDEV);
+}
+
void qdev_prop_set_defaults(DeviceState *dev, Property *props)
{
char *dst;
diff --git a/hw/qdev.h b/hw/qdev.h
index 11744fa..97722b1 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -3,6 +3,7 @@
#include "hw.h"
#include "sys-queue.h"
+#include "qemu-char.h"
typedef struct Property Property;
@@ -61,6 +62,7 @@ enum PropertyType {
PROP_TYPE_TADDR,
PROP_TYPE_MACADDR,
PROP_TYPE_PTR,
+ PROP_TYPE_CHRDEV,
};
struct PropertyInfo {
@@ -148,6 +150,7 @@ extern PropertyInfo qdev_prop_uint32;
extern PropertyInfo qdev_prop_hex32;
extern PropertyInfo qdev_prop_ptr;
extern PropertyInfo qdev_prop_macaddr;
+extern PropertyInfo qdev_prop_chrdev;
/* Set properties between creation and init. */
void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
@@ -157,6 +160,7 @@ void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
/* FIXME: Remove opaque pointer properties. */
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
+void qdev_prop_set_chrdev(DeviceState *dev, const char *name, CharDriverState *chr);
void qdev_prop_set_defaults(DeviceState *dev, Property *props);
void qdev_prop_register_compat(CompatProperty *props);
--
1.6.2.5
next prev parent reply other threads:[~2009-07-17 14:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 14:41 [Qemu-devel] [PATCH 0/2][RFC] Introduce macros for setting properties Anthony Liguori
2009-07-17 14:41 ` Anthony Liguori [this message]
2009-07-21 14:46 ` [Qemu-devel] Re: [PATCH 1/2] Introduce CharDriverState qdev property type Gerd Hoffmann
2009-07-21 14:53 ` Anthony Liguori
2009-07-21 15:03 ` Gerd Hoffmann
2009-07-21 15:14 ` Gerd Hoffmann
2009-07-21 15:23 ` Anthony Liguori
2009-07-21 15:34 ` Gerd Hoffmann
2009-07-21 15:47 ` Anthony Liguori
2009-07-22 9:48 ` Gerd Hoffmann
2009-07-17 14:41 ` [Qemu-devel] [PATCH 2/2] Introduce macro for defining qdev properties Anthony Liguori
2009-07-17 17:23 ` Blue Swirl
2009-07-17 17:26 ` Anthony Liguori
2009-07-17 17:33 ` Paul Brook
2009-07-17 18:11 ` Anthony Liguori
2009-07-17 18:32 ` Blue Swirl
2009-07-17 20:05 ` Anthony Liguori
2009-07-17 22:58 ` Paul Brook
2009-07-18 12:43 ` Jamie Lokier
2009-07-18 16:13 ` Anthony Liguori
2009-07-20 2:29 ` Jamie Lokier
2009-07-21 8:30 ` [Qemu-devel] " Gerd Hoffmann
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=1247841685-18495-2-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=kraxel@redhat.com \
--cc=paul@codesourcery.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).