Laurent Vivier <lviv...@redhat.com> writes: > On 10/05/2019 18:36, Markus Armbruster wrote: >> Laurent Vivier <lviv...@redhat.com> writes: >> >>> Signed-off-by: Laurent Vivier <lviv...@redhat.com> >>> --- >>> backends/rng-builtin.c | 8 +++----- >>> hw/virtio/virtio-rng.c | 2 +- >>> include/hw/virtio/virtio-rng.h | 4 ++-- >>> include/sysemu/rng-builtin.h | 17 +++++++++++++++++ >>> qemu-options.hx | 5 ++--- >>> 5 files changed, 25 insertions(+), 11 deletions(-) >>> create mode 100644 include/sysemu/rng-builtin.h > ... >>> diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h >>> index 922dce7caccf..f9b6339b19a4 100644 >>> --- a/include/hw/virtio/virtio-rng.h >>> +++ b/include/hw/virtio/virtio-rng.h > ... >>> #define TYPE_VIRTIO_RNG "virtio-rng-device" >>> @@ -26,7 +26,7 @@ struct VirtIORNGConf { >>> RngBackend *rng; >>> uint64_t max_bytes; >>> uint32_t period_ms; >>> - RngRandom *default_backend; >>> + RngBuiltin *default_backend; >> >> This member appears to be superfluous. As far as I can tell, it's only >> used in the part of virtio-rng.c visible above. If you replace it by a >> local variable there (in a separate patch, perhaps), this patch will >> become simpler. In particular, you won't need to create rng-builtin.h. >> > > I don't understand how we can remove the rng-builtin.h as we need its > macros for "RNG_BUILTIN(object_new(TYPE_RNG_BUILTIN))". Could you > explain?
You're right, you'll still need TYPE_RNG_BUILTIN. You don't actually need RNG_BUILTIN(), because you can make the local variable Object *. Bonus: saves a couple of OBJECT(). If nothing but TYPE_RNG_BUILTIN is left in rng-builtin.h, I'd stick it into rng.h instead.