[PATCH v2 0/5] qdev release function cleanups + unit test

Chandan Somani posted 5 patches 4 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260108230311.584141-1-csomani@redhat.com
Maintainers: Stefan Berger <stefanb@linux.vnet.ibm.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Peter Maydell <peter.maydell@linaro.org>, Yoshinori Sato <yoshinori.sato@nifty.com>, Jiri Pirko <jiri@resnulli.us>, Jason Wang <jasowang@redhat.com>, Alistair Francis <alistair@alistair23.me>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Eric Auger <eric.auger@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
backends/tpm/tpm_util.c           |  1 +
block/accounting.c                |  1 -
hw/core/qdev-properties-system.c  |  1 +
hw/core/qdev-properties.c         | 24 ++++----
hw/input/stellaris_gamepad.c      |  8 ---
hw/intc/arm_gicv3_common.c        |  8 ---
hw/intc/rx_icu.c                  |  8 ---
hw/misc/arm_sysctl.c              |  2 -
hw/misc/mps2-scc.c                |  8 ---
hw/net/rocker/rocker.c            |  1 -
hw/nvram/xlnx-efuse.c             |  8 ---
hw/nvram/xlnx-versal-efuse-ctrl.c |  8 ---
hw/virtio/virtio-iommu-pci.c      |  8 ---
tests/unit/meson.build            |  1 +
tests/unit/test-qdev.c            | 96 +++++++++++++++++++++++++++++++
15 files changed, 111 insertions(+), 72 deletions(-)
create mode 100644 tests/unit/test-qdev.c
[PATCH v2 0/5] qdev release function cleanups + unit test
Posted by Chandan Somani 4 weeks, 1 day ago
Hello,
  This was originally a single patch to make the property array release
function free the property array instead of having the users free it
in their exit functions. This fixes leaks and reduces code overhead.
After review, Marc-André asked to include some work he did on
this earlier
(https://patchew.org/QEMU/20250429140306.190384-1-marcandre.lureau@redhat.com/).
I have included his patches that added unit testing and made some
release functions idempotent.

Chandan Somani (1):
  qdev: Free property array on release

Marc-André Lureau (4):
  qdev: make release_string() idempotent
  qdev: make release_drive() idempotent
  qdev: make release_tpm() idempotent
  tests: add /qdev/free-properties test

 backends/tpm/tpm_util.c           |  1 +
 block/accounting.c                |  1 -
 hw/core/qdev-properties-system.c  |  1 +
 hw/core/qdev-properties.c         | 24 ++++----
 hw/input/stellaris_gamepad.c      |  8 ---
 hw/intc/arm_gicv3_common.c        |  8 ---
 hw/intc/rx_icu.c                  |  8 ---
 hw/misc/arm_sysctl.c              |  2 -
 hw/misc/mps2-scc.c                |  8 ---
 hw/net/rocker/rocker.c            |  1 -
 hw/nvram/xlnx-efuse.c             |  8 ---
 hw/nvram/xlnx-versal-efuse-ctrl.c |  8 ---
 hw/virtio/virtio-iommu-pci.c      |  8 ---
 tests/unit/meson.build            |  1 +
 tests/unit/test-qdev.c            | 96 +++++++++++++++++++++++++++++++
 15 files changed, 111 insertions(+), 72 deletions(-)
 create mode 100644 tests/unit/test-qdev.c

-- 
2.51.1


Re: [PATCH v2 0/5] qdev release function cleanups + unit test
Posted by Stefan Hajnoczi 3 weeks, 4 days ago
On Thu, Jan 08, 2026 at 03:03:06PM -0800, Chandan Somani wrote:
> Hello,
>   This was originally a single patch to make the property array release
> function free the property array instead of having the users free it
> in their exit functions. This fixes leaks and reduces code overhead.
> After review, Marc-André asked to include some work he did on
> this earlier
> (https://patchew.org/QEMU/20250429140306.190384-1-marcandre.lureau@redhat.com/).
> I have included his patches that added unit testing and made some
> release functions idempotent.
> 
> Chandan Somani (1):
>   qdev: Free property array on release
> 
> Marc-André Lureau (4):
>   qdev: make release_string() idempotent
>   qdev: make release_drive() idempotent
>   qdev: make release_tpm() idempotent
>   tests: add /qdev/free-properties test
> 
>  backends/tpm/tpm_util.c           |  1 +
>  block/accounting.c                |  1 -
>  hw/core/qdev-properties-system.c  |  1 +
>  hw/core/qdev-properties.c         | 24 ++++----
>  hw/input/stellaris_gamepad.c      |  8 ---
>  hw/intc/arm_gicv3_common.c        |  8 ---
>  hw/intc/rx_icu.c                  |  8 ---
>  hw/misc/arm_sysctl.c              |  2 -
>  hw/misc/mps2-scc.c                |  8 ---
>  hw/net/rocker/rocker.c            |  1 -
>  hw/nvram/xlnx-efuse.c             |  8 ---
>  hw/nvram/xlnx-versal-efuse-ctrl.c |  8 ---
>  hw/virtio/virtio-iommu-pci.c      |  8 ---
>  tests/unit/meson.build            |  1 +
>  tests/unit/test-qdev.c            | 96 +++++++++++++++++++++++++++++++
>  15 files changed, 111 insertions(+), 72 deletions(-)
>  create mode 100644 tests/unit/test-qdev.c
> 
> -- 
> 2.51.1
> 

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Re: [PATCH v2 0/5] qdev release function cleanups + unit test
Posted by Chandan Somani 1 week, 2 days ago
Hi Paolo,
  Could you please take a look at this qdev patch and put it through your
tree if it looks good?

Thanks,
Chandan

On Thu, Jan 8, 2026 at 3:03 PM Chandan Somani <csomani@redhat.com> wrote:

> Hello,
>   This was originally a single patch to make the property array release
> function free the property array instead of having the users free it
> in their exit functions. This fixes leaks and reduces code overhead.
> After review, Marc-André asked to include some work he did on
> this earlier
> (
> https://patchew.org/QEMU/20250429140306.190384-1-marcandre.lureau@redhat.com/
> ).
> I have included his patches that added unit testing and made some
> release functions idempotent.
>
> Chandan Somani (1):
>   qdev: Free property array on release
>
> Marc-André Lureau (4):
>   qdev: make release_string() idempotent
>   qdev: make release_drive() idempotent
>   qdev: make release_tpm() idempotent
>   tests: add /qdev/free-properties test
>
>  backends/tpm/tpm_util.c           |  1 +
>  block/accounting.c                |  1 -
>  hw/core/qdev-properties-system.c  |  1 +
>  hw/core/qdev-properties.c         | 24 ++++----
>  hw/input/stellaris_gamepad.c      |  8 ---
>  hw/intc/arm_gicv3_common.c        |  8 ---
>  hw/intc/rx_icu.c                  |  8 ---
>  hw/misc/arm_sysctl.c              |  2 -
>  hw/misc/mps2-scc.c                |  8 ---
>  hw/net/rocker/rocker.c            |  1 -
>  hw/nvram/xlnx-efuse.c             |  8 ---
>  hw/nvram/xlnx-versal-efuse-ctrl.c |  8 ---
>  hw/virtio/virtio-iommu-pci.c      |  8 ---
>  tests/unit/meson.build            |  1 +
>  tests/unit/test-qdev.c            | 96 +++++++++++++++++++++++++++++++
>  15 files changed, 111 insertions(+), 72 deletions(-)
>  create mode 100644 tests/unit/test-qdev.c
>
> --
> 2.51.1
>
>