[libvirt] [PATCH 0/2] udev: Remove udev handle from main loop when udev thread stops

Changelog: + RFC -> v1: - Remove the event handle in the error path of nodeStateInitializeEnumerate - Added patch 2: wake up udev thread in case of an error Marc Hartmayer (2): udev: nodeStateInitializeEnumerate: remove watch handle in case of an error udev: wake up the udev thread for stopping it src/node_device/node_device_udev.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.0

If the udev thread is stopped, it must be ensured that the watch handle is also removed from the main loop. Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- src/node_device/node_device_udev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 54f372cd4a9f..4dd2e9004fd7 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1802,6 +1802,8 @@ nodeStateInitializeEnumerate(void *opaque) error: virObjectLock(priv); + ignore_value(virEventRemoveHandle(priv->watch)); + priv->watch = -1; priv->threadQuit = true; virObjectUnlock(priv); } -- 2.17.0

Signal the udev thread the change of `priv->threadQuit` by using the thread condition. Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> --- src/node_device/node_device_udev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index 4dd2e9004fd7..32e762009f1c 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1805,6 +1805,7 @@ nodeStateInitializeEnumerate(void *opaque) ignore_value(virEventRemoveHandle(priv->watch)); priv->watch = -1; priv->threadQuit = true; + virCondSignal(&priv->threadCond); virObjectUnlock(priv); } -- 2.17.0

On 2/20/19 5:05 AM, Marc Hartmayer wrote:
Changelog: + RFC -> v1: - Remove the event handle in the error path of nodeStateInitializeEnumerate - Added patch 2: wake up udev thread in case of an error
Marc Hartmayer (2): udev: nodeStateInitializeEnumerate: remove watch handle in case of an error udev: wake up the udev thread for stopping it
src/node_device/node_device_udev.c | 3 +++ 1 file changed, 3 insertions(+)
Reviewed-by: John Ferlan <jferlan@redhat.com> (series) and pushed, Tks - John
participants (2)
-
John Ferlan
-
Marc Hartmayer