mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
libxl: use job functions when cleaning up a domain
When explicitly destroying a domain (libxlDomainDestroyFlags), or handling an out-of-band domain shutdown event, cleanup the domain in the context of a job. Introduce libxlVmCleanupJob to wrap libxlVmCleanup in a job block.
This commit is contained in:
parent
f5bc5bd4df
commit
e4a0e900d3
@ -316,6 +316,26 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
|
||||
virObjectUnref(cfg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup function for domain that has reached shutoff state.
|
||||
* Executed in the context of a job.
|
||||
*
|
||||
* virDomainObjPtr should be locked on invocation
|
||||
* Returns true if references remain on virDomainObjPtr, false otherwise.
|
||||
*/
|
||||
static bool
|
||||
libxlVmCleanupJob(libxlDriverPrivatePtr driver,
|
||||
virDomainObjPtr vm,
|
||||
virDomainShutoffReason reason)
|
||||
{
|
||||
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_DESTROY) < 0)
|
||||
return true;
|
||||
|
||||
libxlVmCleanup(driver, vm, reason);
|
||||
|
||||
return libxlDomainObjEndJob(driver, vm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle previously registered event notification from libxenlight.
|
||||
*
|
||||
@ -364,10 +384,11 @@ libxlDomainShutdownThread(void *opaque)
|
||||
reason = VIR_DOMAIN_SHUTOFF_SHUTDOWN;
|
||||
}
|
||||
libxl_domain_destroy(ctx, vm->def->id, NULL);
|
||||
libxlVmCleanup(driver, vm, reason);
|
||||
if (!vm->persistent) {
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
vm = NULL;
|
||||
if (libxlVmCleanupJob(driver, vm, reason)) {
|
||||
if (!vm->persistent) {
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
vm = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LIBXL_SHUTDOWN_REASON_REBOOT:
|
||||
@ -1561,10 +1582,11 @@ libxlDomainDestroyFlags(virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED);
|
||||
if (!vm->persistent) {
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
vm = NULL;
|
||||
if (libxlVmCleanupJob(driver, vm, VIR_DOMAIN_SHUTOFF_DESTROYED)) {
|
||||
if (!vm->persistent) {
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
vm = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user