]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virnetdevmacvlan.c: Introduce mutex for macvlan creation
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 28 Feb 2013 14:59:01 +0000 (15:59 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 1 Mar 2013 10:33:29 +0000 (11:33 +0100)
commit1cf97c87c05bc44d577d545d29d9c94764ea5975
treebdbe2210dd5f82b167c00ea4b58b582194edd9df
parent9c4ecb3e8eeb7d38704c47079ce2e4375ac6465a
virnetdevmacvlan.c: Introduce mutex for macvlan creation

Currently, after we removed the qemu driver lock, it may happen
that two or more threads will start up a machine with macvlan and
race over virNetDevMacVLanCreateWithVPortProfile(). However,
there's a racy section in which we are generating a sequence of
possible device names and detecting if they exits. If we found
one which doesn't we try to create a device with that name.
However, the other thread is doing just the same. Assume it will
succeed and we must therefore fail. If this happens more than 5
times (which in massive parallel startup surely will) we return
-1 without any error reported. This patch is a simple hack to
both of these problems. It introduces a mutex, so only one thread
will enter the section, and if it runs out of possibilities,
error is reported. Moreover, the number of retries is raised to 20.
src/util/virnetdevmacvlan.c