mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 23:07:44 +00:00
libxl: drop virDomainObj lock when destroying a domain
A destroy operation can take considerable time on large memory domains due to scrubbing the domain's memory. Unlock the virDomainObj while libxl_domain_destroy is executing. Implement libxlDomainDestroyInternal wrapper to handle unlocking, calling destroy, and locking. Change all callers of libxl_domain_destroy to use the wrapper. Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
894d2ff759
commit
6dfec1efba
@ -435,7 +435,7 @@ libxlDomainShutdownThread(void *opaque)
|
||||
libxlDomainEventQueue(driver, dom_event);
|
||||
dom_event = NULL;
|
||||
}
|
||||
libxl_domain_destroy(cfg->ctx, vm->def->id, NULL);
|
||||
libxlDomainDestroyInternal(driver, vm);
|
||||
libxlDomainCleanup(driver, vm, reason);
|
||||
if (!vm->persistent)
|
||||
virDomainObjListRemove(driver->domains, vm);
|
||||
@ -447,7 +447,7 @@ libxlDomainShutdownThread(void *opaque)
|
||||
libxlDomainEventQueue(driver, dom_event);
|
||||
dom_event = NULL;
|
||||
}
|
||||
libxl_domain_destroy(cfg->ctx, vm->def->id, NULL);
|
||||
libxlDomainDestroyInternal(driver, vm);
|
||||
libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
|
||||
if (libxlDomainStart(driver, vm, false, -1) < 0) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
@ -625,6 +625,29 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Internal domain destroy function.
|
||||
*
|
||||
* virDomainObjPtr must be locked on invocation
|
||||
*/
|
||||
int
|
||||
libxlDomainDestroyInternal(libxlDriverPrivatePtr driver,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
|
||||
int ret = -1;
|
||||
|
||||
/* Unlock virDomainObj during destroy, which can take considerable
|
||||
* time on large memory domains.
|
||||
*/
|
||||
virObjectUnlock(vm);
|
||||
ret = libxl_domain_destroy(cfg->ctx, vm->def->id, NULL);
|
||||
virObjectLock(vm);
|
||||
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup function for domain that has reached shutoff state.
|
||||
*
|
||||
@ -1022,7 +1045,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
||||
libxl_evdisable_domain_death(cfg->ctx, priv->deathW);
|
||||
priv->deathW = NULL;
|
||||
}
|
||||
libxl_domain_destroy(cfg->ctx, domid, NULL);
|
||||
libxlDomainDestroyInternal(driver, vm);
|
||||
vm->def->id = -1;
|
||||
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_FAILED);
|
||||
|
||||
|
@ -103,6 +103,10 @@ libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
|
||||
libxlSavefileHeaderPtr ret_hdr)
|
||||
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
||||
|
||||
int
|
||||
libxlDomainDestroyInternal(libxlDriverPrivatePtr driver,
|
||||
virDomainObjPtr vm);
|
||||
|
||||
void
|
||||
libxlDomainCleanup(libxlDriverPrivatePtr driver,
|
||||
virDomainObjPtr vm,
|
||||
|
@ -1252,7 +1252,7 @@ libxlDomainDestroyFlags(virDomainPtr dom,
|
||||
event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
|
||||
|
||||
if (libxl_domain_destroy(cfg->ctx, vm->def->id, NULL) < 0) {
|
||||
if (libxlDomainDestroyInternal(driver, vm) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to destroy domain '%d'"), vm->def->id);
|
||||
goto endjob;
|
||||
@ -1595,7 +1595,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
||||
event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_SAVED);
|
||||
|
||||
if (libxl_domain_destroy(cfg->ctx, vm->def->id, NULL) < 0) {
|
||||
if (libxlDomainDestroyInternal(driver, vm) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to destroy domain '%d'"), vm->def->id);
|
||||
goto cleanup;
|
||||
@ -1802,7 +1802,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
|
||||
}
|
||||
|
||||
if (flags & VIR_DUMP_CRASH) {
|
||||
if (libxl_domain_destroy(cfg->ctx, vm->def->id, NULL) < 0) {
|
||||
if (libxlDomainDestroyInternal(driver, vm) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Failed to destroy domain '%d'"), vm->def->id);
|
||||
goto unpause;
|
||||
|
@ -575,7 +575,7 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
|
||||
|
||||
cleanup:
|
||||
if (dom == NULL) {
|
||||
libxl_domain_destroy(cfg->ctx, vm->def->id, NULL);
|
||||
libxlDomainDestroyInternal(driver, vm);
|
||||
libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED);
|
||||
event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_FAILED);
|
||||
@ -614,7 +614,7 @@ libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
libxl_domain_destroy(cfg->ctx, vm->def->id, NULL);
|
||||
libxlDomainDestroyInternal(driver, vm);
|
||||
libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED);
|
||||
event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
|
||||
VIR_DOMAIN_EVENT_STOPPED_MIGRATED);
|
||||
|
Loading…
Reference in New Issue
Block a user