virNetDevVethCreate: Serialize callers
virNetDevVethCreate: Serialize callers

Consider dozen of LXC domains, each of them having this type of interface:

    <interface type='network'>
      <mac address='52:54:00:a7:05:4b'/>
      <source network='default'/>
    </interface>

When starting these domain in parallel, all workers may meet in
virNetDevVethCreate() where a race starts. Race over allocating veth
pairs because allocation requires two steps:

  1) find first nonexistent '/sys/class/net/vnet%d/'
  2) run 'ip link add ...' command

Now consider two threads. Both of them find N as the first unused veth
index but only one of them succeeds allocating it. The other one fails.
For such cases, we are running the allocation in a loop with 10 rounds.
However this is very flaky synchronization. It should be rather used
when libvirt is competing with other process than when libvirt threads
fight each other. Therefore, internally we should use mutex to serialize
callers, and do the allocation in loop (just in case we are competing
with a different process). By the way we have something similar already
since 1cf97c87.

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

rlaager/libvirt,rlaager/libvirt,nertpinx/libvirt,taget/libvirt,taget/libvirt,libvirt/libvirt,libvirt/libvirt,eskultety/libvirt,crobinso/libvirt,zippy2/libvirt,zippy2/libvirt,olafhering/libvirt,jfehlig/libvirt,elmarco/libvirt,shugaoye/libvirt,nertpinx/libvirt,elmarco/libvirt,olafhering/libvirt,agx/libvirt,VenkatDatta/libvirt,datto/libvirt,jfehlig/libvirt,eskultety/libvirt,shugaoye/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,nertpinx/libvirt,jfehlig/libvirt,taget/libvirt,shugaoye/libvirt,rlaager/libvirt,datto/libvirt,jardasgit/libvirt,fabianfreyer/libvirt,nertpinx/libvirt,fabianfreyer/libvirt,shugaoye/libvirt,libvirt/libvirt,crobinso/libvirt,elmarco/libvirt,jardasgit/libvirt,VenkatDatta/libvirt,agx/libvirt,elmarco/libvirt,libvirt/libvirt,VenkatDatta/libvirt,rlaager/libvirt,zippy2/libvirt,eskultety/libvirt,elmarco/libvirt,agx/libvirt,VenkatDatta/libvirt,jfehlig/libvirt,nertpinx/libvirt,rlaager/libvirt,crobinso/libvirt,olafhering/libvirt,agx/libvirt,jardasgit/libvirt,datto/libvirt,fabianfreyer/libvirt,jardasgit/libvirt,andreabolognani/libvirt,datto/libvirt,fabianfreyer/libvirt,eskultety/libvirt,olafhering/libvirt,crobinso/libvirt,jardasgit/libvirt,VenkatDatta/libvirt,shugaoye/libvirt,eskultety/libvirt,zippy2/libvirt,datto/libvirt,taget/libvirt,andreabolognani/libvirt,andreabolognani/libvirt,taget/libvirt,agx/libvirt,andreabolognani/libvirt