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

[libvirt] [PATCH 05/10] Introduce a 'stop' method to virDriverState



From: "Daniel P. Berrange" <berrange redhat com>

To allow actions to be performed in libvirtd when the host
shuts down, or user session exits, introduce a 'stop'
method to virDriverState. This will do things like saving
the VM state to a file.

Signed-off-by: Daniel P. Berrange <berrange redhat com>
---
 src/driver.h            |  2 ++
 src/libvirt.c           | 18 ++++++++++++++++++
 src/libvirt_daemon.syms |  1 +
 src/libvirt_internal.h  |  1 +
 4 files changed, 22 insertions(+)

diff --git a/src/driver.h b/src/driver.h
index 7ba66ad..7d5a367 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1491,6 +1491,7 @@ typedef int (*virDrvStateInitialize) (int privileged);
 typedef int (*virDrvStateCleanup) (void);
 typedef int (*virDrvStateReload) (void);
 typedef int (*virDrvStateActive) (void);
+typedef int (*virDrvStateStop) (void);
 
 typedef struct _virStateDriver virStateDriver;
 typedef virStateDriver *virStateDriverPtr;
@@ -1501,6 +1502,7 @@ struct _virStateDriver {
     virDrvStateCleanup     cleanup;
     virDrvStateReload      reload;
     virDrvStateActive      active;
+    virDrvStateStop        stop;
 };
 # endif
 
diff --git a/src/libvirt.c b/src/libvirt.c
index 4af6089..86c3deb 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -869,6 +869,24 @@ int virStateActive(void) {
     return ret;
 }
 
+/**
+ * virStateStop:
+ *
+ * Run each virtualization driver's "stop" method.
+ *
+ * Returns 0 if successful, -1 on failure
+ */
+int virStateStop(void) {
+    int i, ret = 0;
+
+    for (i = 0 ; i < virStateDriverTabCount ; i++) {
+        if (virStateDriverTab[i]->stop &&
+            virStateDriverTab[i]->stop())
+            ret = 1;
+    }
+    return ret;
+}
+
 #endif
 
 
diff --git a/src/libvirt_daemon.syms b/src/libvirt_daemon.syms
index 7c914fa..dde77a6 100644
--- a/src/libvirt_daemon.syms
+++ b/src/libvirt_daemon.syms
@@ -8,3 +8,4 @@ virStateActive;
 virStateCleanup;
 virStateInitialize;
 virStateReload;
+virStateStop;
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 71483e4..a39aaa4 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -32,6 +32,7 @@ int virStateInitialize(int privileged);
 int virStateCleanup(void);
 int virStateReload(void);
 int virStateActive(void);
+int virStateStop(void);
 # endif
 
 /* Feature detection.  This is a libvirt-private interface for determining
-- 
1.7.11.7


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