qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: qemu-devel@nongnu.org
Cc: Mark McLoughlin <markmc@redhat.com>,
	kraxel@redhat.com, quintela@redhat.com
Subject: [Qemu-devel] [PATCH 6/7] qdev: add qdev_prop_get_{macaddr, net_client}()
Date: Thu, 12 Nov 2009 20:29:01 +0000	[thread overview]
Message-ID: <1258057742-18699-7-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1258057742-18699-1-git-send-email-markmc@redhat.com>

Probably the second worst idea in the world, ever.

While iterating over all NICs in the system, we need to be
able to query their 'net-client' and 'macaddr' properties.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 hw/qdev-properties.c |   31 ++++++++++++++++++++++++++++---
 hw/qdev.h            |    3 +++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index fe40813..11ae6ad 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -458,10 +458,10 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
     return prop->info->parse(dev, prop, value);
 }
 
-void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type)
+static void *qdev_prop_get(DeviceState *dev, const char *name,
+                           enum PropertyType type, Property **prop_ret)
 {
     Property *prop;
-    void *dst;
 
     prop = qdev_prop_find(dev, name);
     if (!prop) {
@@ -474,7 +474,20 @@ void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyT
                 __FUNCTION__, dev->info->name, name);
         abort();
     }
-    dst = qdev_get_prop_ptr(dev, prop);
+
+    if (prop_ret) {
+        *prop_ret = prop;
+    }
+
+    return qdev_get_prop_ptr(dev, prop);
+}
+
+void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type)
+{
+    Property *prop;
+    void *dst;
+
+    dst = qdev_prop_get(dev, name, type, &prop);
     memcpy(dst, src, prop->info->size);
 }
 
@@ -518,11 +531,23 @@ void qdev_prop_set_net_client(DeviceState *dev, const char *name, VLANClientStat
     qdev_prop_set(dev, name, &value, PROP_TYPE_NET_CLIENT);
 }
 
+VLANClientState *qdev_prop_get_net_client(DeviceState *dev, const char *name)
+{
+    VLANClientState **clientp = qdev_prop_get(dev, name, PROP_TYPE_NET_CLIENT, NULL);
+    return *clientp;
+}
+
 void qdev_prop_set_macaddr(DeviceState *dev, const char *name, uint8_t *value)
 {
     qdev_prop_set(dev, name, value, PROP_TYPE_MACADDR);
 }
 
+uint8_t *qdev_prop_get_macaddr(DeviceState *dev, const char *name)
+{
+    uint8_t *mac = qdev_prop_get(dev, name, PROP_TYPE_MACADDR, NULL);
+    return mac;
+}
+
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
 {
     qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);
diff --git a/hw/qdev.h b/hw/qdev.h
index 712ae3b..41b2f07 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -267,6 +267,9 @@ void qdev_prop_set_defaults(DeviceState *dev, Property *props);
 void qdev_prop_register_compat(CompatProperty *props);
 void qdev_prop_set_compat(DeviceState *dev);
 
+VLANClientState *qdev_prop_get_net_client(DeviceState *dev, const char *name);
+uint8_t *qdev_prop_get_macaddr(DeviceState *dev, const char *name);
+
 /* This is a nasty hack to allow passing a NULL bus to qdev_create.  */
 extern struct BusInfo system_bus_info;
 
-- 
1.6.2.5

  parent reply	other threads:[~2009-11-12 20:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-12 20:28 [Qemu-devel] [RFC PATCH 0/7] Fix qemu_announce_self() properly Mark McLoughlin
2009-11-12 20:28 ` [Qemu-devel] [PATCH 1/7] net: remove NICInfo::vc Mark McLoughlin
2009-11-12 20:28 ` [Qemu-devel] [PATCH 2/7] qdev: add "net-client" property Mark McLoughlin
2009-11-16  9:03   ` [Qemu-devel] " Gerd Hoffmann
2009-11-12 20:28 ` [Qemu-devel] [PATCH 3/7] net: create the VLANClientState for NICs early Mark McLoughlin
2009-11-16  9:26   ` [Qemu-devel] " Gerd Hoffmann
2009-11-12 20:28 ` [Qemu-devel] [PATCH 4/7] net: kill off NICInfo/NICConf::vlan/netdev Mark McLoughlin
2009-11-12 20:29 ` [Qemu-devel] [PATCH 5/7] qdev: add qdev_foreach() Mark McLoughlin
2009-11-16  9:28   ` [Qemu-devel] " Gerd Hoffmann
2009-11-20 14:20     ` Mark McLoughlin
2009-11-23  9:55       ` Gerd Hoffmann
2009-11-12 20:29 ` Mark McLoughlin [this message]
2009-11-12 20:29 ` [Qemu-devel] [PATCH 7/7] net: fix qemu_announce_self() Mark McLoughlin
2009-11-13  7:41   ` Mark McLoughlin
2009-11-13  8:14   ` Markus Armbruster

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=1258057742-18699-7-git-send-email-markmc@redhat.com \
    --to=markmc@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /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).