1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-26 14:03:49 +03:00

virnetdev: Use VIR_WITH_MUTEX_LOCK_GUARD in virNetDevGenerateName()

The virNetDevGenerateName() function uses a global array of
virNetDevGenName structs to find next unused name for network
device. This obviously needs some locking and in fact each member
of the array has its own lock. However, these members are not
virObjects, they are just plain structs, therefore
VIR_WITH_MUTEX_LOCK_GUARD() must be used instead of
VIR_WITH_OBJECT_LOCK_GUARD() to lock individual mutexes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Michal Privoznik 2022-03-17 09:19:39 +01:00
parent e5c10018c5
commit fcbb8e916b

View File

@ -3616,7 +3616,7 @@ virNetDevGenerateName(char **ifname, virNetDevGenNameType type)
g_autofree char *try = NULL;
int id = 0;
VIR_WITH_OBJECT_LOCK_GUARD(&virNetDevGenNames[type].mutex) {
VIR_WITH_MUTEX_LOCK_GUARD(&virNetDevGenNames[type].mutex) {
id = ++virNetDevGenNames[type].lastID;
/* reset before overflow */