qom: Improve {qom,device}-list-properties error messages

device-list-properties reports

    Parameter 'typename' expects device

when @typename exists, but isn't a TYPE_DEVICE.  Improve this to

    Parameter 'typename' expects a non-abstract device type

qom-list-properties reports

    Parameter 'typename' expects object

when @typename exists, but isn't a TYPE_OBJECT.  Improve this to

    Parameter 'typename' expects a QOM type

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20201113082626.2725812-10-armbru@redhat.com>
This commit is contained in:
Markus Armbruster 2020-11-13 09:26:25 +01:00
parent 9fc0ab5c9c
commit 74b97760dc
1 changed files with 6 additions and 11 deletions

View File

@ -138,15 +138,10 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,
return NULL;
}
klass = object_class_dynamic_cast(klass, TYPE_DEVICE);
if (klass == NULL) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", TYPE_DEVICE);
return NULL;
}
if (object_class_is_abstract(klass)) {
if (!object_class_dynamic_cast(klass, TYPE_DEVICE)
|| object_class_is_abstract(klass)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename",
"non-abstract device type");
"a non-abstract device type");
return NULL;
}
@ -208,9 +203,9 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
return NULL;
}
klass = object_class_dynamic_cast(klass, TYPE_OBJECT);
if (klass == NULL) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename", TYPE_OBJECT);
if (!object_class_dynamic_cast(klass, TYPE_OBJECT)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "typename",
"a QOM type");
return NULL;
}