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

libxl: move libxlDomainAutoCoreDump to libxl_domain

Move libxlDomainAutoCoreDump from libxl_driver to libxl_domain
for use by other libxl modules.
Signed-off-by: NJim Fehlig <jfehlig@suse.com>
上级 ea88cc76
...@@ -756,3 +756,47 @@ error: ...@@ -756,3 +756,47 @@ error:
} }
return -1; return -1;
} }
/*
* Core dump domain to default dump path.
*
* virDomainObjPtr must be locked on invocation
*/
int
libxlDomainAutoCoreDump(libxlDriverPrivatePtr driver,
virDomainObjPtr vm)
{
libxlDomainObjPrivatePtr priv = vm->privateData;
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
time_t curtime = time(NULL);
char timestr[100];
struct tm time_info;
char *dumpfile = NULL;
int ret = -1;
localtime_r(&curtime, &time_info);
strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
if (virAsprintf(&dumpfile, "%s/%s-%s",
cfg->autoDumpDir,
vm->def->name,
timestr) < 0)
goto cleanup;
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup;
/* Unlock virDomainObj while dumping core */
virObjectUnlock(vm);
libxl_domain_core_dump(priv->ctx, vm->def->id, dumpfile, NULL);
virObjectLock(vm);
ignore_value(libxlDomainObjEndJob(driver, vm));
ret = 0;
cleanup:
VIR_FREE(dumpfile);
virObjectUnref(cfg);
return ret;
}
...@@ -119,4 +119,8 @@ libxlDomainCleanupJob(libxlDriverPrivatePtr driver, ...@@ -119,4 +119,8 @@ libxlDomainCleanupJob(libxlDriverPrivatePtr driver,
int int
libxlDomainEventsRegister(virDomainObjPtr vm); libxlDomainEventsRegister(virDomainObjPtr vm);
int
libxlDomainAutoCoreDump(libxlDriverPrivatePtr driver,
virDomainObjPtr vm);
#endif /* LIBXL_DOMAIN_H */ #endif /* LIBXL_DOMAIN_H */
...@@ -169,50 +169,6 @@ cleanup: ...@@ -169,50 +169,6 @@ cleanup:
} }
/*
* Core dump domain to default dump path.
*
* virDomainObjPtr must be locked on invocation
*/
static int
libxlDomainAutoCoreDump(libxlDriverPrivatePtr driver,
virDomainObjPtr vm)
{
libxlDomainObjPrivatePtr priv = vm->privateData;
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
time_t curtime = time(NULL);
char timestr[100];
struct tm time_info;
char *dumpfile = NULL;
int ret = -1;
localtime_r(&curtime, &time_info);
strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
if (virAsprintf(&dumpfile, "%s/%s-%s",
cfg->autoDumpDir,
vm->def->name,
timestr) < 0)
goto cleanup;
if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
goto cleanup;
/* Unlock virDomainObj while dumping core */
virObjectUnlock(vm);
libxl_domain_core_dump(priv->ctx, vm->def->id, dumpfile, NULL);
virObjectLock(vm);
ignore_value(libxlDomainObjEndJob(driver, vm));
ret = 0;
cleanup:
VIR_FREE(dumpfile);
virObjectUnref(cfg);
return ret;
}
/* /*
* Handle previously registered event notification from libxenlight. * Handle previously registered event notification from libxenlight.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册