Re: [PATCH v2 05/13] rpc: add virNetDaemonSetShutdownCallbacks

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

 





On 7/23/20 7:14 AM, Nikolay Shirokovskiy wrote:
The function is used to set shutdown prepare and wait callbacks. Prepare
callback is used to inform other threads of the daemon that the daemon will be
closed soon so that they can start to shutdown. Wait callback is used to wait
for other threads to actually finish.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---

Reviewed-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>

  src/libvirt_remote.syms |  1 +
  src/rpc/virnetdaemon.c  | 15 +++++++++++++++
  src/rpc/virnetdaemon.h  |  6 ++++++
  3 files changed, 22 insertions(+)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index 0018a0c..335e431 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -87,6 +87,7 @@ virNetDaemonPreExecRestart;
  virNetDaemonQuit;
  virNetDaemonRemoveShutdownInhibition;
  virNetDaemonRun;
+virNetDaemonSetShutdownCallbacks;
  virNetDaemonUpdateServices;
diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index bb81a43..5a5643c 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -69,6 +69,8 @@ struct _virNetDaemon {
      virHashTablePtr servers;
      virJSONValuePtr srvObject;
+ virNetDaemonShutdownCallback shutdownPrepareCb;
+    virNetDaemonShutdownCallback shutdownWaitCb;
      bool quit;
unsigned int autoShutdownTimeout;
@@ -922,3 +924,16 @@ virNetDaemonHasClients(virNetDaemonPtr dmn)
return ret;
  }
+
+void
+virNetDaemonSetShutdownCallbacks(virNetDaemonPtr dmn,
+                                 virNetDaemonShutdownCallback prepareCb,
+                                 virNetDaemonShutdownCallback waitCb)
+{
+    virObjectLock(dmn);
+
+    dmn->shutdownPrepareCb = prepareCb;
+    dmn->shutdownWaitCb = waitCb;
+
+    virObjectUnlock(dmn);
+}
diff --git a/src/rpc/virnetdaemon.h b/src/rpc/virnetdaemon.h
index c2c7767..9f7a282 100644
--- a/src/rpc/virnetdaemon.h
+++ b/src/rpc/virnetdaemon.h
@@ -82,3 +82,9 @@ virNetServerPtr virNetDaemonGetServer(virNetDaemonPtr dmn,
  ssize_t virNetDaemonGetServers(virNetDaemonPtr dmn, virNetServerPtr **servers);
  bool virNetDaemonHasServer(virNetDaemonPtr dmn,
                             const char *serverName);
+
+typedef int (*virNetDaemonShutdownCallback)(void);
+
+void virNetDaemonSetShutdownCallbacks(virNetDaemonPtr dmn,
+                                      virNetDaemonShutdownCallback prepareCb,
+                                      virNetDaemonShutdownCallback waitCb);





[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