VIR_DUMP_MEMORY_ONLY = (1 << 4), /* use dump-guest-memory */
} virDomainCoreDumpFlags;
+/**
+ * virDomainCoreDumpFormat:
+ *
+ * Values for specifying different formats of domain core dumps.
+ */
+typedef enum {
+ VIR_DOMAIN_CORE_DUMP_FORMAT_RAW, /* dump guest memory in raw format */
+ VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_ZLIB, /* kdump-compressed format, with
+ * zlib compression */
+ VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_LZO, /* kdump-compressed format, with
+ * lzo compression */
+ VIR_DOMAIN_CORE_DUMP_FORMAT_KDUMP_SNAPPY, /* kdump-compressed format, with
+ * snappy compression */
+#ifdef VIR_ENUM_SENTINELS
+ VIR_DOMAIN_CORE_DUMP_FORMAT_LAST
+ /*
+ * NB: this enum value will increase over time as new events are
+ * added to the libvirt API. It reflects the last state supported
+ * by this version of the libvirt API.
+ */
+#endif
+} virDomainCoreDumpFormat;
+
/* Domain migration flags. */
typedef enum {
VIR_MIGRATE_LIVE = (1 << 0), /* live migration */
const char *to,
unsigned int flags);
+/*
+ * Domain core dump with format specified
+ */
+int virDomainCoreDumpWithFormat (virDomainPtr domain,
+ const char *to,
+ unsigned int dumpformat,
+ unsigned int flags);
+
/*
* Screenshot of current domain console
*/
const char *to,
unsigned int flags);
+typedef int
+(*virDrvDomainCoreDumpWithFormat)(virDomainPtr domain,
+ const char *to,
+ unsigned int dumpformat,
+ unsigned int flags);
+
typedef char *
(*virDrvDomainScreenshot)(virDomainPtr domain,
virStreamPtr stream,
virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc;
virDrvDomainSaveImageDefineXML domainSaveImageDefineXML;
virDrvDomainCoreDump domainCoreDump;
+ virDrvDomainCoreDumpWithFormat domainCoreDumpWithFormat;
virDrvDomainScreenshot domainScreenshot;
virDrvDomainSetVcpus domainSetVcpus;
virDrvDomainSetVcpusFlags domainSetVcpusFlags;
* or fail if it cannot do so for the given system; this can allow less
* pressure on file system cache, but also risks slowing saves to NFS.
*
+ * For more control over the output format, see virDomainCoreDumpWithFormat().
+ *
* Returns 0 in case of success and -1 in case of failure.
*/
int
return -1;
}
+/**
+ * virDomainCoreDumpWithFormat:
+ * @domain: a domain object
+ * @to: path for the core file
+ * @dumpformat: format of domain memory's dump
+ * @flags: bitwise-OR of virDomainCoreDumpFlags
+ *
+ * This method will dump the core of a domain on a given file for analysis.
+ * Note that for remote Xen Daemon the file path will be interpreted in
+ * the remote host. Hypervisors may require the user to manually ensure
+ * proper permissions on the file named by @to.
+ *
+ * @dumpformat controls which format the dump will have; use of
+ * VIR_DOMAIN_CORE_DUMP_FORMAT_RAW mirrors what virDomainCoreDump() will
+ * perform. Not all hypervisors are able to support all formats.
+ *
+ * If @flags includes VIR_DUMP_CRASH, then leave the guest shut off with
+ * a crashed state after the dump completes. If @flags includes
+ * VIR_DUMP_LIVE, then make the core dump while continuing to allow
+ * the guest to run; otherwise, the guest is suspended during the dump.
+ * VIR_DUMP_RESET flag forces reset of the quest after dump.
+ * The above three flags are mutually exclusive.
+ *
+ * Additionally, if @flags includes VIR_DUMP_BYPASS_CACHE, then libvirt
+ * will attempt to bypass the file system cache while creating the file,
+ * or fail if it cannot do so for the given system; this can allow less
+ * pressure on file system cache, but also risks slowing saves to NFS.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainCoreDumpWithFormat(virDomainPtr domain, const char *to,
+ unsigned int dumpformat, unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain, "to=%s, dumpformat=%u, flags=%x",
+ to, dumpformat, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(domain, -1);
+ conn = domain->conn;
+
+ virCheckReadOnlyGoto(conn->flags, error);
+ virCheckNonNullArgGoto(to, error);
+
+ if (dumpformat >= VIR_DOMAIN_CORE_DUMP_FORMAT_LAST) {
+ virReportInvalidArg(flags, _("dumpformat '%d' is not supported"),
+ dumpformat);
+ goto error;
+ }
+
+ if ((flags & VIR_DUMP_CRASH) && (flags & VIR_DUMP_LIVE)) {
+ virReportInvalidArg(flags, "%s",
+ _("crash and live flags are mutually exclusive"));
+ goto error;
+ }
+
+ if ((flags & VIR_DUMP_CRASH) && (flags & VIR_DUMP_RESET)) {
+ virReportInvalidArg(flags, "%s",
+ _("crash and reset flags are mutually exclusive"));
+ goto error;
+ }
+
+ if ((flags & VIR_DUMP_LIVE) && (flags & VIR_DUMP_RESET)) {
+ virReportInvalidArg(flags, "%s",
+ _("live and reset flags are mutually exclusive"));
+ goto error;
+ }
+
+ if (conn->driver->domainCoreDumpWithFormat) {
+ int ret;
+ char *absolute_to;
+
+ /* We must absolutize the file path as the save is done out of process */
+ if (virFileAbsPath(to, &absolute_to) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not build absolute core file path"));
+ goto error;
+ }
+
+ ret = conn->driver->domainCoreDumpWithFormat(domain, absolute_to,
+ dumpformat, flags);
+
+ VIR_FREE(absolute_to);
+
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virReportUnsupportedError();
+
+error:
+ virDispatchError(domain->conn);
+ return -1;
+}
+
/**
* virDomainScreenshot:
virConnectNetworkEventDeregisterAny;
} LIBVIRT_1.1.3;
+LIBVIRT_1.2.3 {
+ global:
+ virDomainCoreDumpWithFormat;
+} LIBVIRT_1.2.1;
+
# .... define new API here using predicted next version number ....
.domainSaveImageGetXMLDesc = remoteDomainSaveImageGetXMLDesc, /* 0.9.4 */
.domainSaveImageDefineXML = remoteDomainSaveImageDefineXML, /* 0.9.4 */
.domainCoreDump = remoteDomainCoreDump, /* 0.3.0 */
+ .domainCoreDumpWithFormat = remoteDomainCoreDumpWithFormat, /* 1.2.3 */
.domainScreenshot = remoteDomainScreenshot, /* 0.9.2 */
.domainSetVcpus = remoteDomainSetVcpus, /* 0.3.0 */
.domainSetVcpusFlags = remoteDomainSetVcpusFlags, /* 0.8.5 */
unsigned int flags;
};
+struct remote_domain_core_dump_with_format_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string to;
+ unsigned int dumpformat;
+ unsigned int flags;
+};
+
struct remote_domain_screenshot_args {
remote_nonnull_domain dom;
unsigned int screen;
* @generate: both
* @acl: none
*/
- REMOTE_PROC_DOMAIN_EVENT_CALLBACK_DEVICE_REMOVED = 333
+ REMOTE_PROC_DOMAIN_EVENT_CALLBACK_DEVICE_REMOVED = 333,
+
+ /**
+ * @generate: both
+ * @acl: domain:core_dump
+ */
+ REMOTE_PROC_DOMAIN_CORE_DUMP_WITH_FORMAT = 334
};
remote_nonnull_string to;
u_int flags;
};
+struct remote_domain_core_dump_with_format_args {
+ remote_nonnull_domain dom;
+ remote_nonnull_string to;
+ u_int dumpformat;
+ u_int flags;
+};
struct remote_domain_screenshot_args {
remote_nonnull_domain dom;
u_int screen;
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_BALLOON_CHANGE = 331,
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_PMSUSPEND_DISK = 332,
REMOTE_PROC_DOMAIN_EVENT_CALLBACK_DEVICE_REMOVED = 333,
+ REMOTE_PROC_DOMAIN_CORE_DUMP_WITH_FORMAT = 334,
};
return testDomainRestoreFlags(conn, path, NULL, 0);
}
-static int testDomainCoreDump(virDomainPtr domain,
- const char *to,
- unsigned int flags)
+static int testDomainCoreDumpWithFormat(virDomainPtr domain,
+ const char *to,
+ unsigned int dumpformat,
+ unsigned int flags)
{
testConnPtr privconn = domain->conn->privateData;
int fd = -1;
goto cleanup;
}
+ /* we don't support non-raw formats in test driver */
+ if (dumpformat != VIR_DOMAIN_CORE_DUMP_FORMAT_RAW) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("kdump-compressed format is not supported here"));
+ goto cleanup;
+ }
+
if (flags & VIR_DUMP_CRASH) {
testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_CRASHED);
event = virDomainEventLifecycleNewFromObj(privdom,
return ret;
}
-static char *testDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) {
+
+static int
+testDomainCoreDump(virDomainPtr domain,
+ const char *to,
+ unsigned int flags)
+{
+ return testDomainCoreDumpWithFormat(domain, to,
+ VIR_DOMAIN_CORE_DUMP_FORMAT_RAW, flags);
+}
+
+
+static char *
+testDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED)
+{
char *ret;
ignore_value(VIR_STRDUP(ret, "linux"));
return ret;
}
-static unsigned long long testDomainGetMaxMemory(virDomainPtr domain)
+
+static unsigned long long
+testDomainGetMaxMemory(virDomainPtr domain)
{
testConnPtr privconn = domain->conn->privateData;
virDomainObjPtr privdom;
.domainRestore = testDomainRestore, /* 0.3.2 */
.domainRestoreFlags = testDomainRestoreFlags, /* 0.9.4 */
.domainCoreDump = testDomainCoreDump, /* 0.3.2 */
+ .domainCoreDumpWithFormat = testDomainCoreDumpWithFormat, /* 1.2.3 */
.domainSetVcpus = testDomainSetVcpus, /* 0.1.4 */
.domainSetVcpusFlags = testDomainSetVcpusFlags, /* 0.8.5 */
.domainGetVcpusFlags = testDomainGetVcpusFlags, /* 0.8.5 */