提交 f9e6b702 编写于 作者: J Jim Fehlig

libxl: use job functions in libxlDomainCoreDump

Dumping a domain's core can take considerable time.  Use the
recently added job functions and unlock the virDomainObj while
dumping core.
Signed-off-by: NJim Fehlig <jfehlig@suse.com>
上级 341870b1
...@@ -2063,6 +2063,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags) ...@@ -2063,6 +2063,7 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
libxlDomainObjPrivatePtr priv; libxlDomainObjPrivatePtr priv;
virDomainObjPtr vm; virDomainObjPtr vm;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
bool remove_dom = false;
bool paused = false; bool paused = false;
int ret = -1; int ret = -1;
...@@ -2074,9 +2075,12 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags) ...@@ -2074,9 +2075,12 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0) if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0)
goto cleanup; goto cleanup;
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) { if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running")); virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
goto cleanup; goto endjob;
} }
priv = vm->privateData; priv = vm->privateData;
...@@ -2088,39 +2092,42 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags) ...@@ -2088,39 +2092,42 @@ libxlDomainCoreDump(virDomainPtr dom, const char *to, unsigned int flags)
_("Before dumping core, failed to suspend domain '%d'" _("Before dumping core, failed to suspend domain '%d'"
" with libxenlight"), " with libxenlight"),
dom->id); dom->id);
goto cleanup; goto endjob;
} }
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_DUMP); virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_DUMP);
paused = true; paused = true;
} }
if (libxl_domain_core_dump(priv->ctx, dom->id, to, NULL) != 0) { /* Unlock virDomainObj while dumping core */
virObjectUnlock(vm);
ret = libxl_domain_core_dump(priv->ctx, dom->id, to, NULL);
virObjectLock(vm);
if (ret != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to dump core of domain '%d' with libxenlight"), _("Failed to dump core of domain '%d' with libxenlight"),
dom->id); dom->id);
goto cleanup_unpause; ret = -1;
goto unpause;
} }
if (flags & VIR_DUMP_CRASH) { if (flags & VIR_DUMP_CRASH) {
if (libxl_domain_destroy(priv->ctx, dom->id, NULL) < 0) { if (libxl_domain_destroy(priv->ctx, dom->id, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to destroy domain '%d'"), dom->id); _("Failed to destroy domain '%d'"), dom->id);
goto cleanup_unpause; goto unpause;
} }
libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED); libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_CRASHED);
event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_CRASHED); VIR_DOMAIN_EVENT_STOPPED_CRASHED);
if (!vm->persistent) { if (!vm->persistent)
virDomainObjListRemove(driver->domains, vm); remove_dom = true;
vm = NULL;
}
} }
ret = 0; ret = 0;
cleanup_unpause: unpause:
if (vm && virDomainObjIsActive(vm) && paused) { if (virDomainObjIsActive(vm) && paused) {
if (libxl_domain_unpause(priv->ctx, dom->id) != 0) { if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("After dumping core, failed to resume domain '%d' with" _("After dumping core, failed to resume domain '%d' with"
...@@ -2130,7 +2137,16 @@ cleanup_unpause: ...@@ -2130,7 +2137,16 @@ cleanup_unpause:
VIR_DOMAIN_RUNNING_UNPAUSED); VIR_DOMAIN_RUNNING_UNPAUSED);
} }
} }
endjob:
if (!libxlDomainObjEndJob(driver, vm))
vm = NULL;
cleanup: cleanup:
if (remove_dom && vm) {
virDomainObjListRemove(driver->domains, vm);
vm = NULL;
}
if (vm) if (vm)
virObjectUnlock(vm); virObjectUnlock(vm);
if (event) if (event)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册