[RFC PATCH v1 11/15] node_device_udev: Use `stateShutdownPrepare` and `stateShutdownWait`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the proper driver functions for the node state shutdown preparation and
wait. In the next patch, these functions will be extended.

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
---
 src/node_device/node_device_udev.c | 54 +++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 12 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 672da8f5a19f..cec7d837c43e 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1736,18 +1736,8 @@ nodeStateCleanup(void)
 
     priv = driver->privateData;
     if (priv) {
-        VIR_WITH_OBJECT_LOCK_GUARD(priv) {
-            priv->udevThreadQuit = true;
-            virCondSignal(&priv->udevThreadCond);
-        }
-        if (priv->initThread) {
-            virThreadJoin(priv->initThread);
-            g_clear_pointer(&priv->initThread, g_free);
-        }
-        if (priv->udevThread) {
-            virThreadJoin(priv->udevThread);
-            g_clear_pointer(&priv->udevThread, g_free);
-        }
+        g_clear_pointer(&priv->initThread, g_free);
+        g_clear_pointer(&priv->udevThread, g_free);
     }
 
     virObjectUnref(priv);
@@ -2440,12 +2430,52 @@ static virConnectDriver udevConnectDriver = {
     .nodeDeviceDriver = &udevNodeDeviceDriver,
 };
 
+static int
+nodeStateShutdownPrepare(void)
+{
+    udevEventData *priv = NULL;
+
+    if (!driver)
+        return 0;
+
+    priv = driver->privateData;
+    if (!priv)
+        return 0;
+
+    VIR_WITH_OBJECT_LOCK_GUARD(priv) {
+        priv->udevThreadQuit = true;
+        virCondSignal(&priv->udevThreadCond);
+    }
+    return 0;
+}
+
+static int
+nodeStateShutdownWait(void)
+{
+    udevEventData *priv = NULL;
+
+    if (!driver)
+        return 0;
+
+    priv = driver->privateData;
+    if (!priv)
+        return 0;
+
+    if (priv->initThread)
+      virThreadJoin(priv->initThread);
+
+    if (priv->udevThread)
+      virThreadJoin(priv->udevThread);
+    return 0;
+}
 
 static virStateDriver udevStateDriver = {
     .name = "udev",
     .stateInitialize = nodeStateInitialize, /* 0.7.3 */
     .stateCleanup = nodeStateCleanup, /* 0.7.3 */
     .stateReload = nodeStateReload, /* 0.7.3 */
+    .stateShutdownPrepare = nodeStateShutdownPrepare,
+    .stateShutdownWait = nodeStateShutdownWait,
 };
 
 
-- 
2.34.1
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux