diff options
author | Markus Armbruster <armbru@redhat.com> | 2019-08-20 18:06:14 +0200 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2019-09-04 06:32:51 -0400 |
commit | 5f7655f6ef1583c4b15c5a6e1aa2348538f6104b (patch) | |
tree | fccd3260282d36c120ff17d52d05c873c0775500 /hw/virtio/virtio-rng.c | |
parent | 6c4e9d487fea67ceaebf5942be5b76ed675d0e9a (diff) | |
download | qemu-5f7655f6ef1583c4b15c5a6e1aa2348538f6104b.zip qemu-5f7655f6ef1583c4b15c5a6e1aa2348538f6104b.tar.gz qemu-5f7655f6ef1583c4b15c5a6e1aa2348538f6104b.tar.bz2 |
virtio-rng: Keep the default backend out of VirtIORNGConf
The default backend is only used within virtio_rng_device_realize().
Replace VirtIORNGConf member default_backend by a local variable.
Adjust its type to reduce conversions.
While there, pass &error_abort instead of NULL when failure would be a
programming error.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20190820160615.14616-3-lvivier@redhat.com>
Diffstat (limited to 'hw/virtio/virtio-rng.c')
-rw-r--r-- | hw/virtio/virtio-rng.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index d1650e1..fcf3b2e 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -19,6 +19,7 @@ #include "hw/virtio/virtio-rng.h" #include "sysemu/rng.h" #include "sysemu/runstate.h" +#include "sysemu/rng-random.h" #include "qom/object_interfaces.h" #include "trace.h" @@ -192,27 +193,24 @@ 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)); + Object *default_backend = object_new(TYPE_RNG_RANDOM); - user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend), + user_creatable_complete(USER_CREATABLE(default_backend), &local_err); if (local_err) { error_propagate(errp, local_err); - object_unref(OBJECT(vrng->conf.default_backend)); + object_unref(default_backend); return; } - object_property_add_child(OBJECT(dev), - "default-backend", - OBJECT(vrng->conf.default_backend), - NULL); + object_property_add_child(OBJECT(dev), "default-backend", + default_backend, &error_abort); /* The child property took a reference, we can safely drop ours now */ - object_unref(OBJECT(vrng->conf.default_backend)); + object_unref(default_backend); - object_property_set_link(OBJECT(dev), - OBJECT(vrng->conf.default_backend), - "rng", NULL); + object_property_set_link(OBJECT(dev), default_backend, + "rng", &error_abort); } vrng->rng = vrng->conf.rng; |