From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M9oLJ-0007NO-1i for qemu-devel@nongnu.org; Thu, 28 May 2009 18:44:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M9oLE-0007Iu-4Y for qemu-devel@nongnu.org; Thu, 28 May 2009 18:44:56 -0400 Received: from [199.232.76.173] (port=40825 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9oLD-0007Ie-Qm for qemu-devel@nongnu.org; Thu, 28 May 2009 18:44:51 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37987) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M9oLD-0001a3-Bj for qemu-devel@nongnu.org; Thu, 28 May 2009 18:44:51 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4SMioOU029759 for ; Thu, 28 May 2009 18:44:50 -0400 From: Gerd Hoffmann Date: Fri, 29 May 2009 00:44:39 +0200 Message-Id: <1243550679-9027-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1243550679-9027-1-git-send-email-kraxel@redhat.com> References: <1243550679-9027-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 2/2] qdev: kill DeviceState->nd, use properties instead. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- 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