]> xenbits.xensource.com Git - libvirt.git/commit
Change locking for udev monitor and callbacks
authorSerge Hallyn <serge.hallyn@canonical.com>
Tue, 5 Apr 2011 21:14:17 +0000 (16:14 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 6 Apr 2011 16:20:47 +0000 (10:20 -0600)
commit2879582847303297965e0c441edbe7daca07872c
tree8248168bb8cb1999560d6e0d03cf639848a6542c
parent25b39315d679b909db4d8a895269746e74eb0fe5
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 <serge.hallyn@ubuntu.com>
src/node_device/node_device_udev.c