qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 2/2] qdev: kill DeviceState->nd, use properties instead.
Date: Fri, 29 May 2009 00:44:39 +0200	[thread overview]
Message-ID: <1243550679-9027-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1243550679-9027-1-git-send-email-kraxel@redhat.com>


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev.c |   18 ++++++++++++------
 hw/qdev.h |    1 -
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/hw/qdev.c b/hw/qdev.c
index d723b3e..8c06fce 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -182,8 +182,12 @@ void qdev_set_prop_ptr(DeviceState *dev, const char *name, void *value)
 
 void qdev_set_netdev(DeviceState *dev, NICInfo *nd)
 {
-    assert(!dev->nd);
-    dev->nd = nd;
+    qdev_set_prop_int(dev, "nic_vlan", nd->vlan->id);
+    qdev_set_prop_bin(dev, "nic_addr", nd->macaddr, 6);
+    if (nd->name)
+        qdev_set_prop_str(dev, "nic_name", nd->name);
+    if (nd->model)
+        qdev_set_prop_str(dev, "nic_model", nd->model);
 }
 
 
@@ -294,16 +298,18 @@ VLANClientState *qdev_get_vlan_client(DeviceState *dev,
                                       NetCleanup *cleanup,
                                       void *opaque)
 {
-    NICInfo *nd = dev->nd;
-    assert(nd);
-    return qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+    int vlan = qdev_get_prop_int(dev, "nic_vlan", 0);
+
+    return qemu_new_vlan_client(qemu_find_vlan(vlan),
+                                qdev_get_prop_str(dev, "nic_model", NULL),
+                                qdev_get_prop_str(dev, "nic_name", NULL),
                                 fd_read, fd_can_read, cleanup, opaque);
 }
 
 
 void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr)
 {
-    memcpy(macaddr, dev->nd->macaddr, 6);
+    qdev_get_prop_bin(dev, "nic_addr", macaddr, 6);
 }
 
 static int next_block_unit[IF_COUNT];
diff --git a/hw/qdev.h b/hw/qdev.h
index 2f5d9dc..3adc680 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -21,7 +21,6 @@ struct DeviceState {
     int num_gpio_in;
     qemu_irq *gpio_in;
     LIST_HEAD(, BusState) child_bus;
-    NICInfo *nd;
     LIST_ENTRY(DeviceState) sibling;
 };
 
-- 
1.6.2.2

  reply	other threads:[~2009-05-28 22:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-28 22:44 [Qemu-devel] [PATCH 1/2] qdev: add string and binary properties Gerd Hoffmann
2009-05-28 22:44 ` Gerd Hoffmann [this message]
2009-05-29 12:10   ` [Qemu-devel] [PATCH 2/2] qdev: kill DeviceState->nd, use properties instead Paul Brook
2009-05-29 13:17     ` 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=1243550679-9027-2-git-send-email-kraxel@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).