stateShutdown is supposed to inform driver that it will be closed soon so that
the driver can prepare and finish all background threads quickly on
stateShutdownWait call.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
scripts/check-drivername.py | 2 ++
src/driver-state.h | 8 ++++++++
src/libvirt.c | 42 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_internal.h | 2 ++
4 files changed, 54 insertions(+)
diff --git a/scripts/check-drivername.py b/scripts/check-drivername.py
index 39eff83..19d1cd1 100644
--- a/scripts/check-drivername.py
+++ b/scripts/check-drivername.py
@@ -50,6 +50,8 @@ for drvfile in drvfiles:
"virDrvStateCleanup",
"virDrvStateReload",
"virDrvStateStop",
+ "virDrvStateShutdown",
+ "virDrvStateShutdownWait",
"virDrvConnectSupportsFeature",
"virDrvConnectURIProbe",
"virDrvDomainMigratePrepare",
diff --git a/src/driver-state.h b/src/driver-state.h
index 6b3f501..1f664f3 100644
--- a/src/driver-state.h
+++ b/src/driver-state.h
@@ -45,6 +45,12 @@ typedef int
typedef int
(*virDrvStateStop)(void);
+typedef int
+(*virDrvStateShutdown)(void);
+
+typedef int
+(*virDrvStateShutdownWait)(void);
+
typedef struct _virStateDriver virStateDriver;
typedef virStateDriver *virStateDriverPtr;
@@ -55,4 +61,6 @@ struct _virStateDriver {
virDrvStateCleanup stateCleanup;
virDrvStateReload stateReload;
virDrvStateStop stateStop;
+ virDrvStateShutdown stateShutdown;
+ virDrvStateShutdownWait stateShutdownWait;
};
diff --git a/src/libvirt.c b/src/libvirt.c
index b2d0ba3..28f9332 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -673,6 +673,48 @@ virStateInitialize(bool privileged,
/**
+ * virStateShutdown:
+ *
+ * Run each virtualization driver's shutdown method.
+ *
+ * Returns 0 if all succeed, -1 upon any failure.
+ */
+int
+virStateShutdown(void)
+{
+ size_t i;
+
+ for (i = 0; i < virStateDriverTabCount; i++) {
+ if (virStateDriverTab[i]->stateShutdown &&
+ virStateDriverTab[i]->stateShutdown() < 0)
+ return -1;
+ }
+ return 0;
+}
+
+
+/**
+ * virStateShutdownWait:
+ *
+ * Run each virtualization driver's shutdown wait method.
+ *
+ * Returns 0 if all succeed, -1 upon any failure.
+ */
+int
+virStateShutdownWait(void)
+{
+ size_t i;
+
+ for (i = 0; i < virStateDriverTabCount; i++) {
+ if (virStateDriverTab[i]->stateShutdownWait &&
+ virStateDriverTab[i]->stateShutdownWait() < 0)
+ return -1;
+ }
+ return 0;
+}
+
+
+/**
* virStateCleanup:
*
* Run each virtualization driver's cleanup method.
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 72c6127..5b6035f 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -34,6 +34,8 @@ int virStateInitialize(bool privileged,
const char *root,
virStateInhibitCallback inhibit,
void *opaque);
+int virStateShutdown(void);
+int virStateShutdownWait(void);
int virStateCleanup(void);
int virStateReload(void);
int virStateStop(void);
--
1.8.3.1