diff options
author | Igor Mammedov | 2014-01-16 17:34:39 +0100 |
---|---|---|
committer | Luiz Capitulino | 2014-01-28 18:47:11 +0100 |
commit | 57d3e1b3f52d07d215ed96df946ee01f8d9f9526 (patch) | |
tree | f7f8878e8a800b87076adfc8a1e90fe480b42881 /backends | |
parent | add optional 2nd stage initialization to -object/object-add commands (diff) | |
download | qemu-57d3e1b3f52d07d215ed96df946ee01f8d9f9526.tar.gz qemu-57d3e1b3f52d07d215ed96df946ee01f8d9f9526.tar.xz qemu-57d3e1b3f52d07d215ed96df946ee01f8d9f9526.zip |
virtio_rng: replace custom backend API with UserCreatable.complete() callback
in addition fix default backend leak by releasing it if its
initialization failed.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'backends')
-rw-r--r-- | backends/rng.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/backends/rng.c b/backends/rng.c index 7bab806ee1..8b8d5a4973 100644 --- a/backends/rng.c +++ b/backends/rng.c @@ -41,9 +41,9 @@ static bool rng_backend_prop_get_opened(Object *obj, Error **errp) return s->opened; } -void rng_backend_open(RngBackend *s, Error **errp) +static void rng_backend_complete(UserCreatable *uc, Error **errp) { - object_property_set_bool(OBJECT(s), true, "opened", errp); + object_property_set_bool(OBJECT(uc), true, "opened", errp); } static void rng_backend_prop_set_opened(Object *obj, bool value, Error **errp) @@ -77,12 +77,20 @@ static void rng_backend_init(Object *obj) NULL); } +static void rng_backend_class_init(ObjectClass *oc, void *data) +{ + UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc); + + ucc->complete = rng_backend_complete; +} + static const TypeInfo rng_backend_info = { .name = TYPE_RNG_BACKEND, .parent = TYPE_OBJECT, .instance_size = sizeof(RngBackend), .instance_init = rng_backend_init, .class_size = sizeof(RngBackendClass), + .class_init = rng_backend_class_init, .abstract = true, .interfaces = (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, |