mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
rpc: add virNetDaemonSetShutdownCallbacks
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@virtuozzo.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
1eae52b9f1
commit
0f38dedd89
@ -87,6 +87,7 @@ virNetDaemonPreExecRestart;
|
||||
virNetDaemonQuit;
|
||||
virNetDaemonRemoveShutdownInhibition;
|
||||
virNetDaemonRun;
|
||||
virNetDaemonSetShutdownCallbacks;
|
||||
virNetDaemonUpdateServices;
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user