2012-05-07 06:08:56 +02:00
|
|
|
/*
|
|
|
|
* QEMU dump
|
|
|
|
*
|
|
|
|
* Copyright Fujitsu, Corp. 2011, 2012
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Wen Congyang <wency@cn.fujitsu.com>
|
|
|
|
*
|
2012-06-10 21:34:04 +02:00
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
2012-05-07 06:08:56 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DUMP_H
|
|
|
|
#define DUMP_H
|
|
|
|
|
2019-06-19 22:10:47 +02:00
|
|
|
#include "qapi/qapi-types-dump.h"
|
2022-12-22 13:08:11 +01:00
|
|
|
#include "qemu/thread.h"
|
2018-02-11 10:36:01 +01:00
|
|
|
|
2014-02-18 07:11:27 +01:00
|
|
|
#define MAKEDUMPFILE_SIGNATURE "makedumpfile"
|
|
|
|
#define MAX_SIZE_MDF_HEADER (4096) /* max size of makedumpfile_header */
|
|
|
|
#define TYPE_FLAT_HEADER (1) /* type of flattened format */
|
|
|
|
#define VERSION_FLAT_HEADER (1) /* version of flattened format */
|
|
|
|
#define END_FLAG_FLAT_HEADER (-1)
|
|
|
|
|
2016-01-11 20:56:20 +01:00
|
|
|
#ifndef ARCH_PFN_OFFSET
|
2014-02-18 07:11:31 +01:00
|
|
|
#define ARCH_PFN_OFFSET (0)
|
2016-01-11 20:56:20 +01:00
|
|
|
#endif
|
2014-02-18 07:11:31 +01:00
|
|
|
|
2014-02-18 07:11:32 +01:00
|
|
|
/*
|
|
|
|
* flag for compressed format
|
|
|
|
*/
|
|
|
|
#define DUMP_DH_COMPRESSED_ZLIB (0x1)
|
|
|
|
#define DUMP_DH_COMPRESSED_LZO (0x2)
|
|
|
|
#define DUMP_DH_COMPRESSED_SNAPPY (0x4)
|
|
|
|
|
|
|
|
#define KDUMP_SIGNATURE "KDUMP "
|
|
|
|
#define SIG_LEN (sizeof(KDUMP_SIGNATURE) - 1)
|
|
|
|
#define DUMP_LEVEL (1)
|
|
|
|
#define DISKDUMP_HEADER_BLOCKS (1)
|
|
|
|
|
2014-05-19 19:57:44 +02:00
|
|
|
#include "sysemu/dump-arch.h"
|
|
|
|
#include "sysemu/memory_mapping.h"
|
2012-05-07 06:08:56 +02:00
|
|
|
|
2014-02-18 07:11:27 +01:00
|
|
|
typedef struct QEMU_PACKED MakedumpfileHeader {
|
|
|
|
char signature[16]; /* = "makedumpfile" */
|
|
|
|
int64_t type;
|
|
|
|
int64_t version;
|
|
|
|
} MakedumpfileHeader;
|
|
|
|
|
|
|
|
typedef struct QEMU_PACKED MakedumpfileDataHeader {
|
|
|
|
int64_t offset;
|
|
|
|
int64_t buf_size;
|
|
|
|
} MakedumpfileDataHeader;
|
|
|
|
|
2014-02-18 07:11:32 +01:00
|
|
|
typedef struct QEMU_PACKED NewUtsname {
|
|
|
|
char sysname[65];
|
|
|
|
char nodename[65];
|
|
|
|
char release[65];
|
|
|
|
char version[65];
|
|
|
|
char machine[65];
|
|
|
|
char domainname[65];
|
|
|
|
} NewUtsname;
|
|
|
|
|
|
|
|
typedef struct QEMU_PACKED DiskDumpHeader32 {
|
|
|
|
char signature[SIG_LEN]; /* = "KDUMP " */
|
|
|
|
uint32_t header_version; /* Dump header version */
|
|
|
|
NewUtsname utsname; /* copy of system_utsname */
|
|
|
|
char timestamp[10]; /* Time stamp */
|
|
|
|
uint32_t status; /* Above flags */
|
|
|
|
uint32_t block_size; /* Size of a block in byte */
|
|
|
|
uint32_t sub_hdr_size; /* Size of arch dependent header in block */
|
|
|
|
uint32_t bitmap_blocks; /* Size of Memory bitmap in block */
|
|
|
|
uint32_t max_mapnr; /* = max_mapnr ,
|
|
|
|
obsoleted in header_version 6 */
|
|
|
|
uint32_t total_ram_blocks; /* Number of blocks should be written */
|
|
|
|
uint32_t device_blocks; /* Number of total blocks in dump device */
|
|
|
|
uint32_t written_blocks; /* Number of written blocks */
|
|
|
|
uint32_t current_cpu; /* CPU# which handles dump */
|
|
|
|
uint32_t nr_cpus; /* Number of CPUs */
|
|
|
|
} DiskDumpHeader32;
|
|
|
|
|
|
|
|
typedef struct QEMU_PACKED DiskDumpHeader64 {
|
|
|
|
char signature[SIG_LEN]; /* = "KDUMP " */
|
|
|
|
uint32_t header_version; /* Dump header version */
|
|
|
|
NewUtsname utsname; /* copy of system_utsname */
|
|
|
|
char timestamp[22]; /* Time stamp */
|
|
|
|
uint32_t status; /* Above flags */
|
|
|
|
uint32_t block_size; /* Size of a block in byte */
|
|
|
|
uint32_t sub_hdr_size; /* Size of arch dependent header in block */
|
|
|
|
uint32_t bitmap_blocks; /* Size of Memory bitmap in block */
|
|
|
|
uint32_t max_mapnr; /* = max_mapnr,
|
|
|
|
obsoleted in header_version 6 */
|
|
|
|
uint32_t total_ram_blocks; /* Number of blocks should be written */
|
|
|
|
uint32_t device_blocks; /* Number of total blocks in dump device */
|
|
|
|
uint32_t written_blocks; /* Number of written blocks */
|
|
|
|
uint32_t current_cpu; /* CPU# which handles dump */
|
|
|
|
uint32_t nr_cpus; /* Number of CPUs */
|
|
|
|
} DiskDumpHeader64;
|
|
|
|
|
|
|
|
typedef struct QEMU_PACKED KdumpSubHeader32 {
|
|
|
|
uint32_t phys_base;
|
|
|
|
uint32_t dump_level; /* header_version 1 and later */
|
|
|
|
uint32_t split; /* header_version 2 and later */
|
|
|
|
uint32_t start_pfn; /* header_version 2 and later,
|
|
|
|
obsoleted in header_version 6 */
|
|
|
|
uint32_t end_pfn; /* header_version 2 and later,
|
|
|
|
obsoleted in header_version 6 */
|
|
|
|
uint64_t offset_vmcoreinfo; /* header_version 3 and later */
|
|
|
|
uint32_t size_vmcoreinfo; /* header_version 3 and later */
|
|
|
|
uint64_t offset_note; /* header_version 4 and later */
|
|
|
|
uint32_t note_size; /* header_version 4 and later */
|
|
|
|
uint64_t offset_eraseinfo; /* header_version 5 and later */
|
|
|
|
uint32_t size_eraseinfo; /* header_version 5 and later */
|
|
|
|
uint64_t start_pfn_64; /* header_version 6 and later */
|
|
|
|
uint64_t end_pfn_64; /* header_version 6 and later */
|
|
|
|
uint64_t max_mapnr_64; /* header_version 6 and later */
|
|
|
|
} KdumpSubHeader32;
|
|
|
|
|
|
|
|
typedef struct QEMU_PACKED KdumpSubHeader64 {
|
|
|
|
uint64_t phys_base;
|
|
|
|
uint32_t dump_level; /* header_version 1 and later */
|
|
|
|
uint32_t split; /* header_version 2 and later */
|
|
|
|
uint64_t start_pfn; /* header_version 2 and later,
|
|
|
|
obsoleted in header_version 6 */
|
|
|
|
uint64_t end_pfn; /* header_version 2 and later,
|
|
|
|
obsoleted in header_version 6 */
|
|
|
|
uint64_t offset_vmcoreinfo; /* header_version 3 and later */
|
|
|
|
uint64_t size_vmcoreinfo; /* header_version 3 and later */
|
|
|
|
uint64_t offset_note; /* header_version 4 and later */
|
|
|
|
uint64_t note_size; /* header_version 4 and later */
|
|
|
|
uint64_t offset_eraseinfo; /* header_version 5 and later */
|
|
|
|
uint64_t size_eraseinfo; /* header_version 5 and later */
|
|
|
|
uint64_t start_pfn_64; /* header_version 6 and later */
|
|
|
|
uint64_t end_pfn_64; /* header_version 6 and later */
|
|
|
|
uint64_t max_mapnr_64; /* header_version 6 and later */
|
|
|
|
} KdumpSubHeader64;
|
|
|
|
|
2014-02-18 07:11:34 +01:00
|
|
|
typedef struct DataCache {
|
2023-09-19 01:32:31 +02:00
|
|
|
DumpState *state; /* dump state related to this data */
|
2014-02-18 07:11:34 +01:00
|
|
|
uint8_t *buf; /* buffer for cached data */
|
|
|
|
size_t buf_size; /* size of the buf */
|
|
|
|
size_t data_size; /* size of cached data in buf */
|
|
|
|
off_t offset; /* offset of the file */
|
|
|
|
} DataCache;
|
|
|
|
|
2014-02-18 07:11:35 +01:00
|
|
|
typedef struct QEMU_PACKED PageDescriptor {
|
|
|
|
uint64_t offset; /* the offset of the page data*/
|
|
|
|
uint32_t size; /* the size of this dump page */
|
|
|
|
uint32_t flags; /* flags */
|
|
|
|
uint64_t page_flags; /* page flags */
|
|
|
|
} PageDescriptor;
|
|
|
|
|
2014-05-19 19:57:44 +02:00
|
|
|
typedef struct DumpState {
|
|
|
|
GuestPhysBlockList guest_phys_blocks;
|
|
|
|
ArchDumpInfo dump_info;
|
|
|
|
MemoryMappingList list;
|
|
|
|
bool resume;
|
2017-05-03 09:28:19 +02:00
|
|
|
bool detached;
|
2023-09-19 01:32:32 +02:00
|
|
|
bool kdump_raw;
|
2014-05-19 19:57:44 +02:00
|
|
|
hwaddr memory_offset;
|
|
|
|
int fd;
|
|
|
|
|
2022-08-11 14:10:58 +02:00
|
|
|
/*
|
|
|
|
* Dump filter area variables
|
|
|
|
*
|
|
|
|
* A filtered dump only contains the guest memory designated by
|
|
|
|
* the start address and length variables defined below.
|
|
|
|
*
|
|
|
|
* If length is 0, no filtering is applied.
|
|
|
|
*/
|
|
|
|
int64_t filter_area_begin; /* Start address of partial guest memory area */
|
|
|
|
int64_t filter_area_length; /* Length of partial guest memory area */
|
2014-05-19 19:57:44 +02:00
|
|
|
|
2022-10-17 10:38:15 +02:00
|
|
|
/* Elf dump related data */
|
|
|
|
uint32_t phdr_num;
|
|
|
|
uint32_t shdr_num;
|
|
|
|
ssize_t note_size;
|
|
|
|
hwaddr shdr_offset;
|
|
|
|
hwaddr phdr_offset;
|
|
|
|
hwaddr section_offset;
|
|
|
|
hwaddr note_offset;
|
|
|
|
|
2022-10-17 10:38:13 +02:00
|
|
|
void *elf_section_hdrs; /* Pointer to section header buffer */
|
2022-10-17 13:32:10 +02:00
|
|
|
void *elf_section_data; /* Pointer to section data buffer */
|
|
|
|
uint64_t elf_section_data_size; /* Size of section data */
|
|
|
|
GArray *string_table_buf; /* String table data buffer */
|
2022-10-17 10:38:13 +02:00
|
|
|
|
2014-05-19 19:57:44 +02:00
|
|
|
uint8_t *note_buf; /* buffer for notes */
|
|
|
|
size_t note_buf_offset; /* the writing place in note_buf */
|
|
|
|
uint32_t nr_cpus; /* number of guest's cpu */
|
|
|
|
uint64_t max_mapnr; /* the biggest guest's phys-mem's number */
|
|
|
|
size_t len_dump_bitmap; /* the size of the place used to store
|
|
|
|
dump_bitmap in vmcore */
|
|
|
|
off_t offset_dump_bitmap; /* offset of dump_bitmap part in vmcore */
|
|
|
|
off_t offset_page; /* offset of page part in vmcore */
|
|
|
|
size_t num_dumpable; /* number of page that can be dumped */
|
|
|
|
uint32_t flag_compress; /* indicate the compression format */
|
2016-02-18 06:16:48 +01:00
|
|
|
DumpStatus status; /* current dump status */
|
2016-02-18 06:16:50 +01:00
|
|
|
|
|
|
|
bool has_format; /* whether format is provided */
|
|
|
|
DumpGuestMemoryFormat format; /* valid only if has_format == true */
|
2016-02-18 06:16:52 +01:00
|
|
|
QemuThread dump_thread; /* thread for detached dump */
|
2016-02-18 06:16:53 +01:00
|
|
|
|
|
|
|
int64_t total_size; /* total memory size (in bytes) to
|
|
|
|
* be dumped. When filter is
|
|
|
|
* enabled, this will only count
|
|
|
|
* those to be written. */
|
|
|
|
int64_t written_size; /* written memory size (in bytes),
|
|
|
|
* this could be used to calculate
|
|
|
|
* how much work we have
|
|
|
|
* finished. */
|
2017-09-11 18:59:25 +02:00
|
|
|
uint8_t *guest_note; /* ELF note content */
|
|
|
|
size_t guest_note_size;
|
2014-05-19 19:57:44 +02:00
|
|
|
} DumpState;
|
|
|
|
|
|
|
|
uint16_t cpu_to_dump16(DumpState *s, uint16_t val);
|
|
|
|
uint32_t cpu_to_dump32(DumpState *s, uint32_t val);
|
|
|
|
uint64_t cpu_to_dump64(DumpState *s, uint64_t val);
|
2022-10-17 10:38:22 +02:00
|
|
|
|
|
|
|
int64_t dump_filtered_memblock_size(GuestPhysBlock *block, int64_t filter_area_start,
|
|
|
|
int64_t filter_area_length);
|
|
|
|
int64_t dump_filtered_memblock_start(GuestPhysBlock *block, int64_t filter_area_start,
|
|
|
|
int64_t filter_area_length);
|
2012-05-07 06:08:56 +02:00
|
|
|
#endif
|