Change locking for udev monitor and callbacks
Change locking for udev monitor and callbacks

We're seeing bugs apparently resulting from thread unsafety of
libpciaccess, such as
https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/726099
To prevent those, as suggested by danpb on irc, move the
nodeDeviceLock(driverState) higher into the callers.  In
particular:

  udevDeviceMonitorStartup should hold the lock while calling
  udevEnumerateDevices(), and udevEventHandleCallback should hold it
  over its entire execution.

It's not clear to me whether it is ok to hold the
nodeDeviceLock while taking the virNodeDeviceObjLock(dev) on a
device.  If not, then the lock will need to be dropped around
the calling of udevSetupSystemDev(), and udevAddOneDevice()
may not actually be safe to call from higher layers with the
driverstate lock held.

libvirt 0.8.8 with this patch on it seems to work fine for me.
Assuming it looks ok and I haven't done anything obviously dumb,
I'll ask the bug submitters to try this patch.

Signed-off-by: Serge Hallyn <3df611b026e4639bee8aef7a4beb2e39fcebb313@ubuntu.com>

taget/libvirt,zippy2/libvirt,fabianfreyer/libvirt,taget/libvirt,trainstack/libvirt,danwent/libvirt-ovs,datto/libvirt,siboulet/libvirt-openvz,rlaager/libvirt,rmarwaha/libvirt,bjzhang/libvirt,trainstack/libvirt,iam-TJ/libvirt,nertpinx/libvirt,iam-TJ/libvirt,warewolf/libvirt,zhlcindy/libvirt-1.1.4-maintain,novel/fbsd-libvirt,libvirt/libvirt,jeckersb/libvirt,bjzhang/libvirt,crobinso/libvirt,rbu/libvirt,dumbbell/libvirt,datto/libvirt,leilihh/libvirt,VenkatDatta/libvirt,leilihh/libvirt,rmarwaha/libvirt,foomango/libvirt,leilihh/libvirt,eskultety/libvirt,kantai/libvirt-vfork,datto/libvirt,siboulet/libvirt-openvz,warewolf/libvirt,libvirt/libvirt,andreabolognani/libvirt,zhlcindy/libvirt-1.1.4-maintain,siboulet/libvirt-openvz,jeckersb/libvirt,jardasgit/libvirt,olafhering/libvirt,leilihh/libvirt,elmarco/libvirt,danwent/libvirt-ovs,emaste/libvirt,bjzhang/libvirt,rlaager/libvirt,trainstack/libvirt,danwent/libvirt-ovs,wiedi/libvirt,nertpinx/libvirt,cbosdo/libvirt,eskultety/libvirt,shugaoye/libvirt,crobinso/libvirt,datto/libvirt,iam-TJ/libvirt,warewolf/libvirt,foomango/libvirt,soulxu/libvirt-xuhj,iam-TJ/libvirt,nertpinx/libvirt,zhlcindy/libvirt-1.1.4-maintain,VenkatDatta/libvirt,soulxu/libvirt-xuhj,olafhering/libvirt,cbosdo/libvirt,rlaager/libvirt,jardasgit/libvirt,wiedi/libvirt,novel/fbsd-libvirt,emaste/libvirt,taget/libvirt,trainstack/libvirt,foomango/libvirt,rmarwaha/libvirt,dumbbell/libvirt,rbu/libvirt,novel/fbsd-libvirt,taget/libvirt,agx/libvirt,cbosdo/libvirt,jfehlig/libvirt,emaste/libvirt,danwent/libvirt-ovs,shugaoye/libvirt,eskultety/libvirt,emaste/libvirt,jfehlig/libvirt,warewolf/libvirt,warewolf/libvirt,rmarwaha/libvirt,elmarco/libvirt,usc-isi/libvirt,emaste/libvirt,rlaager/libvirt,cbosdo/libvirt,rmarwaha/libvirt1,rmarwaha/libvirt1,libvirt/libvirt,shugaoye/libvirt,VenkatDatta/libvirt,elmarco/libvirt,elmarco/libvirt,dumbbell/libvirt,shugaoye/libvirt,foomango/libvirt,fabianfreyer/libvirt,emaste/libvirt,rmarwaha/libvirt1,zhlcindy/libvirt-1.1.4-maintain,fabianfreyer/libvirt,zhlcindy/libvirt-1.1.4-maintain,rlaager/libvirt,usc-isi/libvirt,jfehlig/libvirt,soulxu/libvirt-xuhj,bjzhang/libvirt,jardasgit/libvirt,libvirt/libvirt,taget/libvirt,rmarwaha/libvirt,novel/fbsd-libvirt,kantai/libvirt-vfork,dumbbell/libvirt,wiedi/libvirt,kantai/libvirt-vfork,agx/libvirt,soulxu/libvirt-xuhj,warewolf/libvirt,usc-isi/libvirt,andreabolognani/libvirt,agx/libvirt,rmarwaha/libvirt1,wiedi/libvirt,jeckersb/libvirt,jeckersb/libvirt,eskultety/libvirt,rbu/libvirt,wiedi/libvirt,usc-isi/libvirt,nertpinx/libvirt,eskultety/libvirt,iam-TJ/libvirt,olafhering/libvirt,andreabolognani/libvirt,novel/fbsd-libvirt,trainstack/libvirt,cbosdo/libvirt,jfehlig/libvirt,elmarco/libvirt,jardasgit/libvirt,nertpinx/libvirt,shugaoye/libvirt,siboulet/libvirt-openvz,novel/fbsd-libvirt,wiedi/libvirt,andreabolognani/libvirt,siboulet/libvirt-openvz,fabianfreyer/libvirt,leilihh/libvirt,dumbbell/libvirt,leilihh/libvirt,rmarwaha/libvirt,agx/libvirt,crobinso/libvirt,jeckersb/libvirt,warewolf/libvirt,agx/libvirt,rbu/libvirt,jeckersb/libvirt,novel/fbsd-libvirt,jardasgit/libvirt,trainstack/libvirt,fabianfreyer/libvirt,novel/fbsd-libvirt,andreabolognani/libvirt,VenkatDatta/libvirt,VenkatDatta/libvirt,wiedi/libvirt,dumbbell/libvirt,danwent/libvirt-ovs,soulxu/libvirt-xuhj,kantai/libvirt-vfork,zippy2/libvirt,kantai/libvirt-vfork,olafhering/libvirt,iam-TJ/libvirt,iam-TJ/libvirt,usc-isi/libvirt,datto/libvirt,zippy2/libvirt,crobinso/libvirt,novel/fbsd-libvirt,emaste/libvirt,bjzhang/libvirt,trainstack/libvirt,rbu/libvirt,zippy2/libvirt,foomango/libvirt,rmarwaha/libvirt1,jeckersb/libvirt,rmarwaha/libvirt1