aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-02-14 10:19:52 +0100
committerBlue Swirl <blauwirbel@gmail.com>2012-02-14 18:57:32 +0000
commit0a54a0ce3e7659d7804274fcb058154d52fb8d82 (patch)
tree6df5ecece1d70510a34f0d43c771c1627136b8b0
parent9d4df9c02866f39d3eef105033091f367cc7c29e (diff)
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 <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r--hw/qdev-properties.c15
1 files changed, 9 insertions, 6 deletions
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);
}