From 0a54a0ce3e7659d7804274fcb058154d52fb8d82 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 14 Feb 2012 10:19:52 +0100 Subject: qdev: allow setting properties to NULL SPARC and PPC set properties to NULL. This can be done with an empty string value. Signed-off-by: Paolo Bonzini Signed-off-by: Blue Swirl --- hw/qdev-properties.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'hw/qdev-properties.c') diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index b6d6fcff01..6f09a3568b 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -613,7 +613,7 @@ static void set_pointer(Object *obj, Visitor *v, Property *prop, } if (!*str) { g_free(str); - error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + *ptr = NULL; return; } ret = parse(dev, str, ptr); @@ -1120,7 +1120,8 @@ void qdev_prop_set_string(DeviceState *dev, const char *name, char *value) int qdev_prop_set_drive(DeviceState *dev, const char *name, BlockDriverState *value) { Error *errp = NULL; - object_property_set_str(OBJECT(dev), bdrv_get_device_name(value), + const char *bdrv_name = value ? bdrv_get_device_name(value) : ""; + object_property_set_str(OBJECT(dev), bdrv_name, name, &errp); if (errp) { qerror_report_err(errp); @@ -1139,16 +1140,18 @@ void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverS void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value) { Error *errp = NULL; - assert(value->label); - object_property_set_str(OBJECT(dev), value->label, name, &errp); + assert(!value || value->label); + object_property_set_str(OBJECT(dev), + value ? value->label : "", name, &errp); assert(!errp); } void qdev_prop_set_netdev(DeviceState *dev, const char *name, VLANClientState *value) { Error *errp = NULL; - assert(value->name); - object_property_set_str(OBJECT(dev), value->name, name, &errp); + assert(!value || value->name); + object_property_set_str(OBJECT(dev), + value ? value->name : "", name, &errp); assert(!errp); } -- cgit v1.2.3