mirror of https://gitee.com/openkylin/libvirt.git
libvirt: add stateShutdownPrepare/stateShutdownWait to drivers
stateShutdownPrepare 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@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
fc7d53edf4
commit
c5bf40bfa6
|
@ -50,6 +50,8 @@ for drvfile in drvfiles:
|
|||
"virDrvStateCleanup",
|
||||
"virDrvStateReload",
|
||||
"virDrvStateStop",
|
||||
"virDrvStateShutdownPrepare",
|
||||
"virDrvStateShutdownWait",
|
||||
"virDrvConnectSupportsFeature",
|
||||
"virDrvConnectURIProbe",
|
||||
"virDrvDomainMigratePrepare",
|
||||
|
|
|
@ -45,6 +45,12 @@ typedef int
|
|||
typedef int
|
||||
(*virDrvStateStop)(void);
|
||||
|
||||
typedef int
|
||||
(*virDrvStateShutdownPrepare)(void);
|
||||
|
||||
typedef int
|
||||
(*virDrvStateShutdownWait)(void);
|
||||
|
||||
typedef struct _virStateDriver virStateDriver;
|
||||
typedef virStateDriver *virStateDriverPtr;
|
||||
|
||||
|
@ -55,4 +61,6 @@ struct _virStateDriver {
|
|||
virDrvStateCleanup stateCleanup;
|
||||
virDrvStateReload stateReload;
|
||||
virDrvStateStop stateStop;
|
||||
virDrvStateShutdownPrepare stateShutdownPrepare;
|
||||
virDrvStateShutdownWait stateShutdownWait;
|
||||
};
|
||||
|
|
|
@ -672,6 +672,48 @@ virStateInitialize(bool privileged,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* virStateShutdownPrepare:
|
||||
*
|
||||
* Run each virtualization driver's shutdown prepare method.
|
||||
*
|
||||
* Returns 0 if all succeed, -1 upon any failure.
|
||||
*/
|
||||
int
|
||||
virStateShutdownPrepare(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < virStateDriverTabCount; i++) {
|
||||
if (virStateDriverTab[i]->stateShutdownPrepare &&
|
||||
virStateDriverTab[i]->stateShutdownPrepare() < 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:
|
||||
*
|
||||
|
|
|
@ -34,6 +34,8 @@ int virStateInitialize(bool privileged,
|
|||
const char *root,
|
||||
virStateInhibitCallback inhibit,
|
||||
void *opaque);
|
||||
int virStateShutdownPrepare(void);
|
||||
int virStateShutdownWait(void);
|
||||
int virStateCleanup(void);
|
||||
int virStateReload(void);
|
||||
int virStateStop(void);
|
||||
|
|
|
@ -1509,6 +1509,8 @@ virSetSharedStorageDriver;
|
|||
virStateCleanup;
|
||||
virStateInitialize;
|
||||
virStateReload;
|
||||
virStateShutdownPrepare;
|
||||
virStateShutdownWait;
|
||||
virStateStop;
|
||||
virStreamInData;
|
||||
|
||||
|
|
Loading…
Reference in New Issue