Move libxlDomainAutoCoreDump from libxl_driver to libxl_domain
for use by other libxl modules.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_domain.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_domain.h | 4 ++++
src/libxl/libxl_driver.c | 44 --------------------------------------------
3 files changed, 48 insertions(+), 44 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 5ffa9dd..6816a96 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -742,3 +742,47 @@ error:
}
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;
+}
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 1ac9174..a50efd3 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -119,4 +119,8 @@ libxlDomainCleanupJob(libxlDriverPrivatePtr driver,
int
libxlDomainEventsRegister(virDomainObjPtr vm);
+int
+libxlDomainAutoCoreDump(libxlDriverPrivatePtr driver,
+ virDomainObjPtr vm);
+
#endif /* LIBXL_DOMAIN_H */
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 7451726..663577f 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -163,50 +163,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.
*
* Note: Xen 4.3 removed the const from the event handler signature.
--
1.8.1.4