diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2011-12-18 17:05:07 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-19 10:27:33 -0600 |
commit | 7db4c4e8e53fc6fe9fee3fe6f6e822f7f1549352 (patch) | |
tree | 17bbed2c3a87dc3776e564c1733d50f72b883ad7 /hw/qdev-properties.c | |
parent | e3cb6ba65d265f2cc1313ee26e879407ff24663c (diff) |
qom: interpret the return value when setting legacy properties
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev-properties.c')
-rw-r--r-- | hw/qdev-properties.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index f0b811c806..de618f2aeb 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -614,6 +614,28 @@ int qdev_prop_exists(DeviceState *dev, const char *name) return qdev_prop_find(dev, name) ? true : false; } +void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, + Property *prop, const char *value) +{ + switch (ret) { + case -EEXIST: + error_set(errp, QERR_PROPERTY_VALUE_IN_USE, + dev->info->name, prop->name, value); + break; + default: + case -EINVAL: + error_set(errp, QERR_PROPERTY_VALUE_BAD, + dev->info->name, prop->name, value); + break; + case -ENOENT: + error_set(errp, QERR_PROPERTY_VALUE_NOT_FOUND, + dev->info->name, prop->name, value); + break; + case 0: + break; + } +} + int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) { Property *prop; @@ -632,21 +654,10 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value) } ret = prop->info->parse(dev, prop, value); if (ret < 0) { - switch (ret) { - case -EEXIST: - qerror_report(QERR_PROPERTY_VALUE_IN_USE, - dev->info->name, name, value); - break; - default: - case -EINVAL: - qerror_report(QERR_PROPERTY_VALUE_BAD, - dev->info->name, name, value); - break; - case -ENOENT: - qerror_report(QERR_PROPERTY_VALUE_NOT_FOUND, - dev->info->name, name, value); - break; - } + Error *err; + error_set_from_qdev_prop_error(&err, ret, dev, prop, value); + qerror_report_err(err); + error_free(err); return -1; } return 0; |