On Tue, 2021-11-09 at 16:24 +0100, Michal Prívozník wrote:
On 11/9/21 3:16 PM, Tim Wiederhake wrote:
> On Mon, 2021-11-01 at 15:16 +0100, Michal Privoznik wrote:
> > I've been looking at our tests lately and noticed an opportunity
> > to
> > rewrite pieces of code to g_auto() magic.
> >
> > Michal Prívozník (7):
> > qemuagenttest: Don't leak virTypedParameter on failure
> > Prefer g_auto(GStrv) over g_strfreev()
> > qemu: Use g_autoptr(qemuMonitorCPUModelInfo)
> > qemuConnectStealCPUModelFromInfo: Drop needless 'cleanup' label
> > tests: Use g_autoptr(qemuMonitorTest)
> > test: Use g_autofree more
> > tests: Drop cleanup/error labels
> >
> > src/bhyve/bhyve_command.c | 3 +-
> > src/bhyve/bhyve_parse_command.c | 22 +--
> > src/libxl/libxl_conf.c | 9 +-
> > src/libxl/xen_common.c | 18 +-
> > src/libxl/xen_xl.c | 17 +-
> > src/lxc/lxc_container.c | 4 +-
> > src/lxc/lxc_native.c | 24 +--
> > src/qemu/qemu_driver.c | 17 +-
> > src/remote/remote_daemon_dispatch.c | 3 +-
> > src/remote/remote_driver.c | 4 +-
> > src/storage/storage_backend_rbd.c | 3 +-
> > src/util/vircgroup.c | 3 +-
> > src/util/vircgroupv2.c | 4 +-
> > src/util/virfirmware.c | 6 +-
> > src/util/viruri.c | 3 +-
> > src/vbox/vbox_common.c | 12 +-
> > src/vbox/vbox_snapshot_conf.c | 40 ++--
> > src/vbox/vbox_tmpl.c | 3 +-
> > src/vz/vz_sdk.c | 3 +-
> > tests/qemuagenttest.c | 286 ++++++++++++----------
> > ------
> > tests/qemucapabilitiestest.c | 22 +--
> > tests/qemuhotplugtest.c | 3 +-
> > tests/qemumigparamstest.c | 40 ++--
> > tests/qemumonitorjsontest.c | 95 ++++-----
> > tests/qemumonitortestutils.c | 63 +++---
> > tests/vboxsnapshotxmltest.c | 3 +-
> > tests/virconftest.c | 3 +-
> > tests/virfiletest.c | 3 +-
> > tests/virstringtest.c | 3 +-
> > tools/virsh-host.c | 13 +-
> > tools/virt-login-shell-helper.c | 7 +-
> > tools/vsh.c | 4 +-
> > 32 files changed, 279 insertions(+), 464 deletions(-)
> >
>
> When applying this series, compiling with ASAN enabled, and running
> "virsh hypervisor-cpu-compare empty.xml" with "empty.xml" ==
> "<cpu/>",
> I see the following error message:
>
> =================================================================
> ==45506==ERROR: AddressSanitizer: heap-use-after-free on address
> 0x602000009b70 at pc 0x5588d1c81aa8 bp 0x7fffc8510af0 sp
> 0x7fffc8510ae8
> READ of size 8 at 0x602000009b70 thread T0
> #0 0x5588d1c81aa7 in cmdHypervisorCPUCompare
> ../../git/libvirt/tools/virsh-host.c:1605
> #1 0x5588d1cead5d in vshCommandRun
> ../../git/libvirt/tools/vsh.c:1309
> #2 0x5588d1bd5331 in main ../../git/libvirt/tools/virsh.c:899
> #3 0x7fc8c4f32b74 in __libc_start_main
> (/lib64/libc.so.6+0x27b74)
> #4 0x5588d1bcef3d in _start
> (/home/twiederh/build/libvirt/tools/virsh+0x16bf3d)
Ah thanks, it's a problem in 2/7 where this needs to be squashed in:
diff --git i/tools/virsh-host.c w/tools/virsh-host.c
index f6aa532b40..fc84415e7b 100644
--- i/tools/virsh-host.c
+++ w/tools/virsh-host.c
@@ -1123,7 +1123,7 @@ vshExtractCPUDefXMLs(vshControl *ctl,
}
cleanup:
- return cpus;
+ return g_steal_pointer(&cpus);
error:
goto cleanup;
Michal
With that applied:
Reviewed-by: Tim Wiederhake <twiederh(a)redhat.com>