diff options
Diffstat (limited to 'qom')
-rw-r--r-- | qom/object_interfaces.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 1e9ad6f08a..7661270b98 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -8,6 +8,7 @@ #include "qapi/qobject-input-visitor.h" #include "qom/object_interfaces.h" #include "qemu/help_option.h" +#include "qemu/id.h" #include "qemu/module.h" #include "qemu/option.h" #include "qapi/opts-visitor.h" @@ -41,11 +42,19 @@ Object *user_creatable_add_type(const char *type, const char *id, const QDict *qdict, Visitor *v, Error **errp) { + ERRP_GUARD(); Object *obj; ObjectClass *klass; const QDictEntry *e; Error *local_err = NULL; + if (id != NULL && !id_wellformed(id)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifier"); + error_append_hint(errp, "Identifiers consist of letters, digits, " + "'-', '.', '_', starting with a letter.\n"); + return NULL; + } + klass = object_class_by_name(type); if (!klass) { error_setg(errp, "invalid object type: %s", type); |