@@ -24,34 +24,6 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin,
error_set(errp, QERR_UNSUPPORTED);
}
-int cpu_write_elf64_note(write_core_dump_function f,
- CPUArchState *env, int cpuid,
- void *opaque)
-{
- return -1;
-}
-
-int cpu_write_elf32_note(write_core_dump_function f,
- CPUArchState *env, int cpuid,
- void *opaque)
-{
- return -1;
-}
-
-int cpu_write_elf64_qemunote(write_core_dump_function f,
- CPUArchState *env,
- void *opaque)
-{
- return -1;
-}
-
-int cpu_write_elf32_qemunote(write_core_dump_function f,
- CPUArchState *env,
- void *opaque)
-{
- return -1;
-}
-
int cpu_get_dump_info(ArchDumpInfo *info)
{
return -1;
@@ -282,7 +282,7 @@ static int write_elf64_notes(DumpState *s)
for (env = first_cpu; env != NULL; env = env->next_cpu) {
cpu = ENV_GET_CPU(env);
id = cpu_index(cpu);
- ret = cpu_write_elf64_note(fd_write_vmcore, env, id, s);
+ ret = cpu_write_elf64_note(fd_write_vmcore, cpu, id, s);
if (ret < 0) {
dump_error(s, "dump: failed to write elf notes.\n");
return -1;
@@ -290,7 +290,7 @@ static int write_elf64_notes(DumpState *s)
}
for (env = first_cpu; env != NULL; env = env->next_cpu) {
- ret = cpu_write_elf64_qemunote(fd_write_vmcore, env, s);
+ ret = cpu_write_elf64_qemunote(fd_write_vmcore, cpu, s);
if (ret < 0) {
dump_error(s, "dump: failed to write CPU status.\n");
return -1;
@@ -334,7 +334,7 @@ static int write_elf32_notes(DumpState *s)
for (env = first_cpu; env != NULL; env = env->next_cpu) {
cpu = ENV_GET_CPU(env);
id = cpu_index(cpu);
- ret = cpu_write_elf32_note(fd_write_vmcore, env, id, s);
+ ret = cpu_write_elf32_note(fd_write_vmcore, cpu, id, s);
if (ret < 0) {
dump_error(s, "dump: failed to write elf notes.\n");
return -1;
@@ -342,7 +342,7 @@ static int write_elf32_notes(DumpState *s)
}
for (env = first_cpu; env != NULL; env = env->next_cpu) {
- ret = cpu_write_elf32_qemunote(fd_write_vmcore, env, s);
+ ret = cpu_write_elf32_qemunote(fd_write_vmcore, cpu, s);
if (ret < 0) {
dump_error(s, "dump: failed to write CPU status.\n");
return -1;
@@ -24,6 +24,8 @@
#include "hw/qdev-core.h"
#include "qemu/thread.h"
+typedef int (*WriteCoreDumpFunction)(void *buf, size_t size, void *opaque);
+
/**
* SECTION:cpu
* @section_id: QEMU-cpu
@@ -60,6 +62,14 @@ typedef struct CPUClass {
void (*do_interrupt)(CPUState *cpu);
const struct VMStateDescription *vmsd;
+ int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
+ int cpuid, void *opaque);
+ int (*write_elf64_qemunote)(WriteCoreDumpFunction f, CPUState *cpu,
+ void *opaque);
+ int (*write_elf32_note)(WriteCoreDumpFunction f, CPUState *cpu,
+ int cpuid, void *opaque);
+ int (*write_elf32_qemunote)(WriteCoreDumpFunction f, CPUState *cpu,
+ void *opaque);
} CPUClass;
struct KVMState;
@@ -125,6 +135,45 @@ struct CPUState {
uint32_t halted; /* used by alpha, cris, ppc TCG */
};
+/**
+ * cpu_write_elf64_note:
+ * @f: pointer to a function that writes memory to a file
+ * @cpu: The CPU whose memory is to be dumped
+ * @cpuid: ID number of the CPU
+ * @opaque: pointer to the CPUState struct
+ */
+int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
+ int cpuid, void *opaque);
+
+/**
+ * cpu_write_elf64_qemunote:
+ * @f: pointer to a function that writes memory to a file
+ * @cpu: The CPU whose memory is to be dumped
+ * @cpuid: ID number of the CPU
+ * @opaque: pointer to the CPUState struct
+ */
+int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
+ void *opaque);
+
+/**
+ * cpu_write_elf32_note:
+ * @f: pointer to a function that writes memory to a file
+ * @cpu: The CPU whose memory is to be dumped
+ * @cpuid: ID number of the CPU
+ * @opaque: pointer to the CPUState struct
+ */
+int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu,
+ int cpuid, void *opaque);
+
+/**
+ * cpu_write_elf32_qemunote:
+ * @f: pointer to a function that writes memory to a file
+ * @cpu: The CPU whose memory is to be dumped
+ * @cpuid: ID number of the CPU
+ * @opaque: pointer to the CPUState struct
+ */
+int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
+ void *opaque);
/**
* cpu_reset:
@@ -21,14 +21,6 @@ typedef struct ArchDumpInfo {
} ArchDumpInfo;
typedef int (*write_core_dump_function)(void *buf, size_t size, void *opaque);
-int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env,
- int cpuid, void *opaque);
-int cpu_write_elf32_note(write_core_dump_function f, CPUArchState *env,
- int cpuid, void *opaque);
-int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env,
- void *opaque);
-int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env,
- void *opaque);
int cpu_get_dump_info(ArchDumpInfo *info);
ssize_t cpu_get_note_size(int class, int machine, int nr_cpus);
@@ -26,6 +26,38 @@ void cpu_reset_interrupt(CPUState *cpu, int mask)
cpu->interrupt_request &= ~mask;
}
+int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
+ void *opaque)
+{
+ CPUClass *klass = CPU_GET_CLASS(cpu);
+
+ return (*klass->write_elf32_qemunote)(f, cpu, opaque);
+}
+
+int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu,
+ int cpuid, void *opaque)
+{
+ CPUClass *klass = CPU_GET_CLASS(cpu);
+
+ return (*klass->write_elf32_note)(f, cpu, cpuid, opaque);
+}
+
+int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
+ void *opaque)
+{
+ CPUClass *klass = CPU_GET_CLASS(cpu);
+
+ return (*klass->write_elf64_qemunote)(f, cpu, opaque);
+}
+
+int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
+ int cpuid, void *opaque)
+{
+ CPUClass *klass = CPU_GET_CLASS(cpu);
+
+ return (*klass->write_elf64_note)(f, cpu, cpuid, opaque);
+}
+
void cpu_reset(CPUState *cpu)
{
CPUClass *klass = CPU_GET_CLASS(cpu);
Convert cpu_write_elfXX_note functions to CPUClass methods and pass CPUState as argument Signed-off-by: "Jens Freimann <jfrei@linux.vnet.ibm.com" --- dump-stub.c | 28 ---------------------------- dump.c | 8 ++++---- include/qom/cpu.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ include/sysemu/dump.h | 8 -------- qom/cpu.c | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 40 deletions(-)