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 <mar...@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