[libvirt] [PATCH] libvirtd: fix potential deadlock when starting vm

John Ferlan jferlan at redhat.com
Tue Oct 16 21:57:17 UTC 2018



On 10/11/18 4:13 AM, Bingsong Si wrote:
> On CentOS 6, udev_monitor_receive_device will block until the socket becomes

Is this really CentOS6 only or just where you've seen it?

> readable, udevEventHandleThread will hold the lock all the time and
> udevEventHandleCallback hard to get the lock, will block the event poll.
> To fix this, set dataReady to false after receive an udev event.
> 
> Signed-off-by: Bingsong Si <owen.si at ucloud.cn>
> ---
>  src/node_device/node_device_udev.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 

I've CC'd Erik since he wrote and perhaps remembers all the "gotchas" he
discovered in the udev callback code.

I wonder if this has to do with the EAGAIN and EWOULDBLOCK @errno checks
done in the !device loop that are different in "older" (much older) code.

Although I have this very vague recollection that there was some problem
with centos6 that was fixed by some OS patch.  Hopefully Erik remembers
(and maybe we should log it in the code at this point ;-)) - I did do
some searching, but came up empty.

John

> diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
> index 22897591de..ce1101d7cc 100644
> --- a/src/node_device/node_device_udev.c
> +++ b/src/node_device/node_device_udev.c
> @@ -1616,6 +1616,7 @@ udevEventHandleThread(void *opaque ATTRIBUTE_UNUSED)
>  
>          errno = 0;
>          device = udev_monitor_receive_device(priv->udev_monitor);
> +        priv->dataReady = false;
>          virObjectUnlock(priv);
>  
>          if (!device) {
> @@ -1637,10 +1638,6 @@ udevEventHandleThread(void *opaque ATTRIBUTE_UNUSED)
>                  return;
>              }
>  
> -            virObjectLock(priv);
> -            priv->dataReady = false;
> -            virObjectUnlock(priv);
> -
>              continue;
>          }
>  
> 




More information about the libvir-list mailing list