Use QERR_INVALID_PARAMETER_VALUE for consistency, and avoid an assertion failure if the class name is incorrect.
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- qmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qmp.c b/qmp.c index 2ff943d..a3b0b73 100644 --- a/qmp.c +++ b/qmp.c @@ -541,7 +541,8 @@ void object_add(const char *type, const char *id, const QDict *qdict, Error *local_err = NULL; if (!object_class_by_name(type)) { - error_setg(errp, "invalid class name"); + error_set(errp, QERR_INVALID_PARAMETER_VALUE, + "qom-type", "a valid class name"); return; } @@ -556,8 +557,8 @@ void object_add(const char *type, const char *id, const QDict *qdict, } if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { - error_setg(&local_err, "object '%s' isn't supported by object-add", - id); + error_setg(&local_err, "class '%s' isn't supported by object-add", + type); goto out; } -- 1.8.5.3