[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/2] qdev: kill DeviceState->nd, use properties inst
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 2/2] qdev: kill DeviceState->nd, use properties instead. |
Date: |
Fri, 29 May 2009 00:44:39 +0200 |
Signed-off-by: Gerd Hoffmann <address@hidden>
---
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