[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/4] dump: Make DumpState and endian conversion rout
From: |
Greg Kurz |
Subject: |
[Qemu-devel] [PATCH 1/4] dump: Make DumpState and endian conversion routines available for arch-specific dump code |
Date: |
Mon, 28 Apr 2014 13:29:37 +0200 |
User-agent: |
StGit/0.16 |
From: Bharata B Rao <address@hidden>
Make DumpState and endian conversion routines available for arch-specific dump
code by moving into dump.h. DumpState will be needed by arch-specific dump
code to access target endian information from DumpState->ArchDumpInfo. Also
break the dependency of dump.h from stubs/dump.c by creating a separate
dump-arch.h.
This patch doesn't change any functionality.
Signed-off-by: Bharata B Rao <address@hidden>
[ rebased on top of current master branch,
Greg Kurz <address@hidden> ]
Signed-off-by: Greg Kurz <address@hidden>
---
dump.c | 39 +++---------------------------------
include/sysemu/dump-arch.h | 28 ++++++++++++++++++++++++++
include/sysemu/dump.h | 48 +++++++++++++++++++++++++++++++++++---------
stubs/dump.c | 2 +-
4 files changed, 70 insertions(+), 47 deletions(-)
create mode 100644 include/sysemu/dump-arch.h
diff --git a/dump.c b/dump.c
index 14b3d1d..13c9bf2 100644
--- a/dump.c
+++ b/dump.c
@@ -36,7 +36,7 @@
#define ELF_MACHINE_UNAME "Unknown"
#endif
-static uint16_t cpu_convert_to_target16(uint16_t val, int endian)
+uint16_t cpu_convert_to_target16(uint16_t val, int endian)
{
if (endian == ELFDATA2LSB) {
val = cpu_to_le16(val);
@@ -47,7 +47,7 @@ static uint16_t cpu_convert_to_target16(uint16_t val, int
endian)
return val;
}
-static uint32_t cpu_convert_to_target32(uint32_t val, int endian)
+uint32_t cpu_convert_to_target32(uint32_t val, int endian)
{
if (endian == ELFDATA2LSB) {
val = cpu_to_le32(val);
@@ -58,7 +58,7 @@ static uint32_t cpu_convert_to_target32(uint32_t val, int
endian)
return val;
}
-static uint64_t cpu_convert_to_target64(uint64_t val, int endian)
+uint64_t cpu_convert_to_target64(uint64_t val, int endian)
{
if (endian == ELFDATA2LSB) {
val = cpu_to_le64(val);
@@ -69,39 +69,6 @@ static uint64_t cpu_convert_to_target64(uint64_t val, int
endian)
return val;
}
-typedef struct DumpState {
- GuestPhysBlockList guest_phys_blocks;
- ArchDumpInfo dump_info;
- MemoryMappingList list;
- uint16_t phdr_num;
- uint32_t sh_info;
- bool have_section;
- bool resume;
- ssize_t note_size;
- hwaddr memory_offset;
- int fd;
-
- GuestPhysBlock *next_block;
- ram_addr_t start;
- bool has_filter;
- int64_t begin;
- int64_t length;
- Error **errp;
-
- 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 */
- size_t page_size; /* guest's page size */
- uint32_t page_shift; /* guest's page shift */
- 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 */
-} DumpState;
-
static int dump_cleanup(DumpState *s)
{
int ret = 0;
diff --git a/include/sysemu/dump-arch.h b/include/sysemu/dump-arch.h
new file mode 100644
index 0000000..9c95ced
--- /dev/null
+++ b/include/sysemu/dump-arch.h
@@ -0,0 +1,28 @@
+/*
+ * QEMU dump
+ *
+ * Copyright Fujitsu, Corp. 2011, 2012
+ *
+ * Authors:
+ * Wen Congyang <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef DUMP_ARCH_H
+#define DUMP_ARCH_H
+
+typedef struct ArchDumpInfo {
+ int d_machine; /* Architecture */
+ int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */
+ int d_class; /* ELFCLASS32 or ELFCLASS64 */
+} ArchDumpInfo;
+
+struct GuestPhysBlockList; /* memory_mapping.h */
+int cpu_get_dump_info(ArchDumpInfo *info,
+ const struct GuestPhysBlockList *guest_phys_blocks);
+ssize_t cpu_get_note_size(int class, int machine, int nr_cpus);
+
+#endif
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
index efab7a3..f01eb86 100644
--- a/include/sysemu/dump.h
+++ b/include/sysemu/dump.h
@@ -43,11 +43,8 @@
#define PFN_BUFBITMAP (CHAR_BIT * BUFSIZE_BITMAP)
#define BUFSIZE_DATA_CACHE (TARGET_PAGE_SIZE * 4)
-typedef struct ArchDumpInfo {
- int d_machine; /* Architecture */
- int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */
- int d_class; /* ELFCLASS32 or ELFCLASS64 */
-} ArchDumpInfo;
+#include "sysemu/dump-arch.h"
+#include "sysemu/memory_mapping.h"
typedef struct QEMU_PACKED MakedumpfileHeader {
char signature[16]; /* = "makedumpfile" */
@@ -158,9 +155,40 @@ typedef struct QEMU_PACKED PageDescriptor {
uint64_t page_flags; /* page flags */
} PageDescriptor;
-struct GuestPhysBlockList; /* memory_mapping.h */
-int cpu_get_dump_info(ArchDumpInfo *info,
- const struct GuestPhysBlockList *guest_phys_blocks);
-ssize_t cpu_get_note_size(int class, int machine, int nr_cpus);
-
+typedef struct DumpState {
+ GuestPhysBlockList guest_phys_blocks;
+ ArchDumpInfo dump_info;
+ MemoryMappingList list;
+ uint16_t phdr_num;
+ uint32_t sh_info;
+ bool have_section;
+ bool resume;
+ ssize_t note_size;
+ hwaddr memory_offset;
+ int fd;
+
+ GuestPhysBlock *next_block;
+ ram_addr_t start;
+ bool has_filter;
+ int64_t begin;
+ int64_t length;
+ Error **errp;
+
+ 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 */
+ size_t page_size; /* guest's page size */
+ uint32_t page_shift; /* guest's page shift */
+ 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 */
+} DumpState;
+
+uint16_t cpu_convert_to_target16(uint16_t val, int endian);
+uint32_t cpu_convert_to_target32(uint32_t val, int endian);
+uint64_t cpu_convert_to_target64(uint64_t val, int endian);
#endif
diff --git a/stubs/dump.c b/stubs/dump.c
index 370cd96..fac7019 100644
--- a/stubs/dump.c
+++ b/stubs/dump.c
@@ -12,7 +12,7 @@
*/
#include "qemu-common.h"
-#include "sysemu/dump.h"
+#include "sysemu/dump-arch.h"
#include "qapi/qmp/qerror.h"
#include "qmp-commands.h"
[Qemu-devel] [PATCH 2/4] ppc64-dump: Support dump for little endian ppc64, Greg Kurz, 2014/04/28