|
|
9ae3a8 |
From faa6207ac40f548cb7f033e07717e98c9bfb1249 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 7 Nov 2014 17:17:52 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 05/41] dump: add API to write header of flatten format
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1415380693-16593-6-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 62191
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.1 qemu-kvm PATCH 05/26] dump: add API to write header of flatten format
|
|
|
9ae3a8 |
Bugzilla: 1157798
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: dgibson <dgibson@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: qiaonuohan <qiaonuohan@cn.fujitsu.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
flatten format will be used when writing kdump-compressed format. The format is
|
|
|
9ae3a8 |
also used by makedumpfile, you can refer to the following URL to get more
|
|
|
9ae3a8 |
detailed information about flatten format of kdump-compressed format:
|
|
|
9ae3a8 |
http://sourceforge.net/projects/makedumpfile/
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The two functions here are used to write start flat header and end flat header
|
|
|
9ae3a8 |
to vmcore, and they will be called later when flatten format is used.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct MakedumpfileHeader stored at the head of vmcore is used to indicate the
|
|
|
9ae3a8 |
vmcore is in flatten format.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct MakedumpfileHeader {
|
|
|
9ae3a8 |
char signature[16]; /* = "makedumpfile" */
|
|
|
9ae3a8 |
int64_t type; /* = 1 */
|
|
|
9ae3a8 |
int64_t version; /* = 1 */
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
And struct MakedumpfileDataHeader, with offset and buf_size set to -1, is used
|
|
|
9ae3a8 |
to indicate the end of vmcore in flatten format.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct MakedumpfileDataHeader {
|
|
|
9ae3a8 |
int64_t offset; /* = -1 */
|
|
|
9ae3a8 |
int64_t buf_size; /* = -1 */
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
|
|
|
9ae3a8 |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit fda053875e69120b2fde5fb34975ef5a49290f12)
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
dump.c | 42 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
9ae3a8 |
include/sysemu/dump.h | 17 +++++++++++++++++
|
|
|
9ae3a8 |
2 files changed, 59 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/dump.c b/dump.c
|
|
|
9ae3a8 |
index fed8bd6..6c902e5 100644
|
|
|
9ae3a8 |
--- a/dump.c
|
|
|
9ae3a8 |
+++ b/dump.c
|
|
|
9ae3a8 |
@@ -692,6 +692,48 @@ static int create_vmcore(DumpState *s)
|
|
|
9ae3a8 |
return 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static int write_start_flat_header(int fd)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ uint8_t *buf;
|
|
|
9ae3a8 |
+ MakedumpfileHeader mh;
|
|
|
9ae3a8 |
+ int ret = 0;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ memset(&mh, 0, sizeof(mh));
|
|
|
9ae3a8 |
+ strncpy(mh.signature, MAKEDUMPFILE_SIGNATURE,
|
|
|
9ae3a8 |
+ strlen(MAKEDUMPFILE_SIGNATURE));
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ mh.type = cpu_to_be64(TYPE_FLAT_HEADER);
|
|
|
9ae3a8 |
+ mh.version = cpu_to_be64(VERSION_FLAT_HEADER);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ buf = g_malloc0(MAX_SIZE_MDF_HEADER);
|
|
|
9ae3a8 |
+ memcpy(buf, &mh, sizeof(mh));
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ size_t written_size;
|
|
|
9ae3a8 |
+ written_size = qemu_write_full(fd, buf, MAX_SIZE_MDF_HEADER);
|
|
|
9ae3a8 |
+ if (written_size != MAX_SIZE_MDF_HEADER) {
|
|
|
9ae3a8 |
+ ret = -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ g_free(buf);
|
|
|
9ae3a8 |
+ return ret;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static int write_end_flat_header(int fd)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ MakedumpfileDataHeader mdh;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ mdh.offset = END_FLAG_FLAT_HEADER;
|
|
|
9ae3a8 |
+ mdh.buf_size = END_FLAG_FLAT_HEADER;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ size_t written_size;
|
|
|
9ae3a8 |
+ written_size = qemu_write_full(fd, &mdh, sizeof(mdh));
|
|
|
9ae3a8 |
+ if (written_size != sizeof(mdh)) {
|
|
|
9ae3a8 |
+ return -1;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static ram_addr_t get_start_block(DumpState *s)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
GuestPhysBlock *block;
|
|
|
9ae3a8 |
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
|
|
|
9ae3a8 |
index 19fafb2..b32b390 100644
|
|
|
9ae3a8 |
--- a/include/sysemu/dump.h
|
|
|
9ae3a8 |
+++ b/include/sysemu/dump.h
|
|
|
9ae3a8 |
@@ -14,12 +14,29 @@
|
|
|
9ae3a8 |
#ifndef DUMP_H
|
|
|
9ae3a8 |
#define DUMP_H
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+#define MAKEDUMPFILE_SIGNATURE "makedumpfile"
|
|
|
9ae3a8 |
+#define MAX_SIZE_MDF_HEADER (4096) /* max size of makedumpfile_header */
|
|
|
9ae3a8 |
+#define TYPE_FLAT_HEADER (1) /* type of flattened format */
|
|
|
9ae3a8 |
+#define VERSION_FLAT_HEADER (1) /* version of flattened format */
|
|
|
9ae3a8 |
+#define END_FLAG_FLAT_HEADER (-1)
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
typedef struct ArchDumpInfo {
|
|
|
9ae3a8 |
int d_machine; /* Architecture */
|
|
|
9ae3a8 |
int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */
|
|
|
9ae3a8 |
int d_class; /* ELFCLASS32 or ELFCLASS64 */
|
|
|
9ae3a8 |
} ArchDumpInfo;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+typedef struct QEMU_PACKED MakedumpfileHeader {
|
|
|
9ae3a8 |
+ char signature[16]; /* = "makedumpfile" */
|
|
|
9ae3a8 |
+ int64_t type;
|
|
|
9ae3a8 |
+ int64_t version;
|
|
|
9ae3a8 |
+} MakedumpfileHeader;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+typedef struct QEMU_PACKED MakedumpfileDataHeader {
|
|
|
9ae3a8 |
+ int64_t offset;
|
|
|
9ae3a8 |
+ int64_t buf_size;
|
|
|
9ae3a8 |
+} MakedumpfileDataHeader;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
struct GuestPhysBlockList; /* memory_mapping.h */
|
|
|
9ae3a8 |
int cpu_get_dump_info(ArchDumpInfo *info,
|
|
|
9ae3a8 |
const struct GuestPhysBlockList *guest_phys_blocks);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|