Message ID | 20160719085432.4572-29-marcandre.lureau@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> --- a/hw/input/virtio-input-hid.c > +++ b/hw/input/virtio-input-hid.c > + .instance_finalize = virtio_input_finalize, > --- a/hw/input/virtio-input.c > +++ b/hw/input/virtio-input.c > +void virtio_input_finalize(Object *obj) > +{ > + VirtIOInput *vinput = VIRTIO_INPUT(obj); > + VirtIOInputConfig *cfg, *next; > + > + QTAILQ_FOREACH_SAFE(cfg, &vinput->cfg_list, node, next) { > + QTAILQ_REMOVE(&vinput->cfg_list, cfg, node); > + g_free(cfg); > + } > +} I think you can keep this local to virtio-input.c and simply hook it into the abstract base class (TYPE_VIRTIO_INPUT). Other than that it looks fine to me. cheers, Gerd
Hi ----- Original Message ----- > > --- a/hw/input/virtio-input-hid.c > > +++ b/hw/input/virtio-input-hid.c > > > + .instance_finalize = virtio_input_finalize, > > > --- a/hw/input/virtio-input.c > > +++ b/hw/input/virtio-input.c > > > +void virtio_input_finalize(Object *obj) > > +{ > > + VirtIOInput *vinput = VIRTIO_INPUT(obj); > > + VirtIOInputConfig *cfg, *next; > > + > > + QTAILQ_FOREACH_SAFE(cfg, &vinput->cfg_list, node, next) { > > + QTAILQ_REMOVE(&vinput->cfg_list, cfg, node); > > + g_free(cfg); > > + } > > +} > > I think you can keep this local to virtio-input.c and simply hook it > into the abstract base class (TYPE_VIRTIO_INPUT). > Yes, not sure why I didn't do that in the first, place. fixed.
diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 3ee0c18..0e5596e 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -340,6 +340,7 @@ static const TypeInfo virtio_input_hid_info = { .instance_size = sizeof(VirtIOInputHID), .class_init = virtio_input_hid_class_init, .abstract = true, + .instance_finalize = virtio_input_finalize, }; /* ----------------------------------------------------------------- */ diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index edf6990..36a7d5e 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -285,6 +285,16 @@ static void virtio_input_device_realize(DeviceState *dev, Error **errp) virtio_input_save, virtio_input_load, vinput); } +void virtio_input_finalize(Object *obj) +{ + VirtIOInput *vinput = VIRTIO_INPUT(obj); + VirtIOInputConfig *cfg, *next; + + QTAILQ_FOREACH_SAFE(cfg, &vinput->cfg_list, node, next) { + QTAILQ_REMOVE(&vinput->cfg_list, cfg, node); + g_free(cfg); + } +} static void virtio_input_device_unrealize(DeviceState *dev, Error **errp) { VirtIOInputClass *vic = VIRTIO_INPUT_GET_CLASS(dev); diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h index 55db310..8fd790f 100644 --- a/include/hw/virtio/virtio-input.h +++ b/include/hw/virtio/virtio-input.h @@ -104,5 +104,6 @@ void virtio_input_add_config(VirtIOInput *vinput, virtio_input_config *config); void virtio_input_idstr_config(VirtIOInput *vinput, uint8_t select, const char *string); +void virtio_input_finalize(Object *obj); #endif /* QEMU_VIRTIO_INPUT_H */