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>
This commit is contained in:
parent
6c4e9d487f
commit
5f7655f6ef
@ -19,6 +19,7 @@
|
|||||||
#include "hw/virtio/virtio-rng.h"
|
#include "hw/virtio/virtio-rng.h"
|
||||||
#include "sysemu/rng.h"
|
#include "sysemu/rng.h"
|
||||||
#include "sysemu/runstate.h"
|
#include "sysemu/runstate.h"
|
||||||
|
#include "sysemu/rng-random.h"
|
||||||
#include "qom/object_interfaces.h"
|
#include "qom/object_interfaces.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
@ -192,27 +193,24 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vrng->conf.rng == NULL) {
|
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);
|
&local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
object_unref(OBJECT(vrng->conf.default_backend));
|
object_unref(default_backend);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
object_property_add_child(OBJECT(dev),
|
object_property_add_child(OBJECT(dev), "default-backend",
|
||||||
"default-backend",
|
default_backend, &error_abort);
|
||||||
OBJECT(vrng->conf.default_backend),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* The child property took a reference, we can safely drop ours now */
|
/* 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_property_set_link(OBJECT(dev), default_backend,
|
||||||
OBJECT(vrng->conf.default_backend),
|
"rng", &error_abort);
|
||||||
"rng", NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vrng->rng = vrng->conf.rng;
|
vrng->rng = vrng->conf.rng;
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "hw/virtio/virtio.h"
|
#include "hw/virtio/virtio.h"
|
||||||
#include "sysemu/rng.h"
|
#include "sysemu/rng.h"
|
||||||
#include "sysemu/rng-random.h"
|
|
||||||
#include "standard-headers/linux/virtio_rng.h"
|
#include "standard-headers/linux/virtio_rng.h"
|
||||||
|
|
||||||
#define TYPE_VIRTIO_RNG "virtio-rng-device"
|
#define TYPE_VIRTIO_RNG "virtio-rng-device"
|
||||||
@ -27,7 +26,6 @@ struct VirtIORNGConf {
|
|||||||
RngBackend *rng;
|
RngBackend *rng;
|
||||||
uint64_t max_bytes;
|
uint64_t max_bytes;
|
||||||
uint32_t period_ms;
|
uint32_t period_ms;
|
||||||
RngRandom *default_backend;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct VirtIORNG {
|
typedef struct VirtIORNG {
|
||||||
|
Loading…
Reference in New Issue
Block a user