From: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> This function is called by daemon before shutting down netdaemon threads that serves client requests to make sure all these threads will be able to shutdown. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- daemon/libvirtd.c | 3 +++ src/driver-state.h | 4 ++++ src/libvirt.c | 18 ++++++++++++++++++ src/libvirt_internal.h | 1 + src/libvirt_private.syms | 1 + 5 files changed, 27 insertions(+) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index b47f875d9..37d66b3e9 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1529,6 +1529,9 @@ int main(int argc, char **argv) { cleanup: /* Keep cleanup order in inverse order of startup */ + if (driversInitialized) + virStateShutdown(); + virNetDaemonClose(dmn); virNetlinkEventServiceStopAll(); diff --git a/src/driver-state.h b/src/driver-state.h index 1cb3e4faf..ea549a7db 100644 --- a/src/driver-state.h +++ b/src/driver-state.h @@ -42,6 +42,9 @@ typedef int typedef int (*virDrvStateStop)(void); +typedef void +(*virDrvStateShutdown)(void); + typedef struct _virStateDriver virStateDriver; typedef virStateDriver *virStateDriverPtr; @@ -52,6 +55,7 @@ struct _virStateDriver { virDrvStateCleanup stateCleanup; virDrvStateReload stateReload; virDrvStateStop stateStop; + virDrvStateShutdown stateShutdown; }; diff --git a/src/libvirt.c b/src/libvirt.c index 536d56f0a..330c5ce8c 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -812,6 +812,24 @@ virStateCleanup(void) /** + * virStateShutdown: + * + * Run each virtualization driver's shutdown method. + * + */ +void +virStateShutdown(void) +{ + int r; + + for (r = virStateDriverTabCount - 1; r >= 0; r--) { + if (virStateDriverTab[r]->stateShutdown) + virStateDriverTab[r]->stateShutdown(); + } +} + + +/** * virStateReload: * * Run each virtualization driver's reload method. diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 62f490a7d..9863b0781 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -36,6 +36,7 @@ int virStateInitialize(bool privileged, int virStateCleanup(void); int virStateReload(void); int virStateStop(void); +void virStateShutdown(void); /* Feature detection. This is a libvirt-private interface for determining * what features are supported by the driver. diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f1e31ffcb..48223f8ed 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1211,6 +1211,7 @@ virSetSharedStorageDriver; virStateCleanup; virStateInitialize; virStateReload; +virStateShutdown; virStateStop; virStreamInData; -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list