char: use a const CharDriver

No need to allocate & copy fields, let's use static const struct instead.

Add an alias field to the CharDriver structure to cover the cases where
we previously registered a driver twice under two names.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Marc-André Lureau 2016-10-21 16:07:45 +03:00 committed by Paolo Bonzini
parent bd1caa3f8e
commit 0b812f3192
7 changed files with 150 additions and 85 deletions

View file

@ -130,8 +130,11 @@ static CharDriverState *chr_testdev_init(const char *id,
static void register_types(void)
{
register_char_driver("testdev", CHARDEV_BACKEND_KIND_TESTDEV, NULL,
chr_testdev_init);
static const CharDriver driver = {
.kind = CHARDEV_BACKEND_KIND_TESTDEV,
.create = chr_testdev_init,
};
register_char_driver(&driver);
}
type_init(register_types);