libvirt currently manages mutexes manually. Manual mutex management suffers from the same drawbacks as manual memory management, and at least one lock-unlock mismatch exists currently in the code base, see https://listman.redhat.com/archives/libvir-list/2021-August/msg00125.html. This series lays the ground work for automatic mutex management in libvirt. Later series will continue to replace calls to virMutex{Lock,Unlock} and virObject{Lock,Unlock}. Patches 1 - 3 deal with a bug in clang (see patch 1 for explanation), patches 4 - 6 introduce a new type, virLockGuard, that handles the automatic mutex management, and patches 7-11 demonstrate the application of this new type. Patches that eliminate the majority of calls to virMutex{Lock,Unlock} are on stand-by, as well as patches that provide virLockGuard support for virObject and will be send once this series is accepted. Regards, Tim Tim Wiederhake (11): glibcompat: Add wrapper for g_auto* VIR_XPATH_NODE_AUTORESTORE: Add semicolon virxml: Simplify VIR_XPATH_NODE_AUTORESTORE internal: Add CONCAT macro virthread: Introduce virLockGuard virthread: Introduce WITH_VIR_MUTEX_LOCK_GUARD virChrdevFDStreamCloseCb: Use virLockGuard virChrdevFree: Use virLockGuard virChrdevOpen: Use virLockGuard networkBridgeNameValidate: Use virLockGuard networkBridgeNameValidate: Cleanup src/conf/backup_conf.c | 2 +- src/conf/checkpoint_conf.c | 2 +- src/conf/cpu_conf.c | 2 +- src/conf/domain_conf.c | 140 ++++++++++++++--------------- src/conf/interface_conf.c | 8 +- src/conf/netdev_vlan_conf.c | 2 +- src/conf/network_conf.c | 14 +-- src/conf/networkcommon_conf.c | 2 +- src/conf/node_device_conf.c | 42 ++++----- src/conf/numa_conf.c | 6 +- src/conf/snapshot_conf.c | 2 +- src/conf/storage_adapter_conf.c | 2 +- src/conf/storage_conf.c | 4 +- src/conf/storage_encryption_conf.c | 4 +- src/conf/storage_source_conf.c | 2 +- src/conf/virchrdev.c | 26 ++---- src/conf/virsavecookie.c | 2 +- src/cpu/cpu_map.c | 4 +- src/cpu/cpu_x86.c | 2 +- src/internal.h | 3 + src/libvirt_private.syms | 3 + src/lxc/lxc_domain.c | 2 +- src/network/bridge_driver.c | 11 +-- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_domain.c | 8 +- src/qemu/qemu_domainjob.c | 2 +- src/qemu/qemu_migration_cookie.c | 8 +- src/util/glibcompat.h | 20 +++++ src/util/virthread.c | 26 ++++++ src/util/virthread.h | 30 +++++++ src/util/virxml.h | 6 +- 31 files changed, 228 insertions(+), 161 deletions(-) -- 2.31.1