On 4/12/24 8:36 AM, Marc Hartmayer wrote:
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(a)linux.ibm.com>
---
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,
};
Reviewed-by: Jonathon Jongsma <jjongsma(a)redhat.com>