mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
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>
This commit is contained in:
parent
269e09f3fc
commit
57d3e1b3f5
3 changed files with 19 additions and 19 deletions
|
@ -15,6 +15,7 @@
|
|||
#include "hw/virtio/virtio.h"
|
||||
#include "hw/virtio/virtio-rng.h"
|
||||
#include "sysemu/rng.h"
|
||||
#include "qom/object_interfaces.h"
|
||||
|
||||
static bool is_guest_ready(VirtIORNG *vrng)
|
||||
{
|
||||
|
@ -148,6 +149,14 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
|
|||
if (vrng->conf.rng == NULL) {
|
||||
vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
|
||||
|
||||
user_creatable_complete(OBJECT(vrng->conf.default_backend),
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
object_unref(OBJECT(vrng->conf.default_backend));
|
||||
return;
|
||||
}
|
||||
|
||||
object_property_add_child(OBJECT(dev),
|
||||
"default-backend",
|
||||
OBJECT(vrng->conf.default_backend),
|
||||
|
@ -166,12 +175,6 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
|
|||
return;
|
||||
}
|
||||
|
||||
rng_backend_open(vrng->rng, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
|
||||
vrng->vq = virtio_add_queue(vdev, 8, handle_input);
|
||||
|
||||
assert(vrng->conf.max_bytes <= INT64_MAX);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue