From: Jens Freimann <jfrei@linux.vnet.ibm.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Rabin Vincent <rabin@rab.in>,
Peter Maydell <peter.maydell@linaro.org>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH 1/2] qom: Convert cpu_write_elfXX_note functions to CPUState
Date: Fri, 19 Apr 2013 16:45:06 +0200 [thread overview]
Message-ID: <1366382707-64886-2-git-send-email-jfrei@linux.vnet.ibm.com> (raw)
In-Reply-To: <1366382707-64886-1-git-send-email-jfrei@linux.vnet.ibm.com>
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(-)
diff --git a/dump-stub.c b/dump-stub.c
index a9d0b3c..b3f42cb 100644
--- a/dump-stub.c
+++ b/dump-stub.c
@@ -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;
diff --git a/dump.c b/dump.c
index b34f143..c0d3da5 100644
--- a/dump.c
+++ b/dump.c
@@ -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;
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 3664a1b..f23dc22 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -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:
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
index e25b7cf..75823e5 100644
--- a/include/sysemu/dump.h
+++ b/include/sysemu/dump.h
@@ -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);
diff --git a/qom/cpu.c b/qom/cpu.c
index e242dcb..aacc057 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -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);
--
1.7.12.4
next prev parent reply other threads:[~2013-04-19 14:45 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-24 17:27 [Qemu-devel] [PATCHv2 0/6] ARM dump-guest-memory support Rabin Vincent
2013-03-24 17:27 ` [Qemu-devel] [PATCHv2 1/6] dump: create writable files Rabin Vincent
2013-04-04 9:42 ` Paolo Bonzini
2013-03-24 17:27 ` [Qemu-devel] [PATCHv2 2/6] dump: extract out note helper Rabin Vincent
2013-03-24 17:27 ` [Qemu-devel] [PATCHv2 3/6] dump: extract out get note size function Rabin Vincent
2013-03-24 17:27 ` [Qemu-devel] [PATCHv2 4/6] dump: fix up memory mapping dependencies / stub Rabin Vincent
2013-04-04 9:43 ` Paolo Bonzini
2013-03-24 17:27 ` [Qemu-devel] [PATCHv2 5/6] target-arm: add dump-guest-memory support Rabin Vincent
2013-03-24 18:34 ` Peter Maydell
2013-03-24 19:26 ` Rabin Vincent
2013-03-24 20:39 ` Peter Maydell
2013-04-04 9:47 ` Paolo Bonzini
2013-04-04 9:49 ` Peter Maydell
2013-03-24 17:27 ` [Qemu-devel] [PATCHv2 6/6] dump: fix memory region handling Rabin Vincent
2013-03-24 18:36 ` Peter Maydell
2013-03-24 19:35 ` Rabin Vincent
2013-03-24 20:18 ` Peter Maydell
2013-03-25 11:49 ` [Qemu-devel] [PATCHv2 0/6] ARM dump-guest-memory support Andreas Färber
2013-03-29 8:36 ` Rabin Vincent
2013-04-04 8:52 ` Andreas Färber
2013-04-09 12:09 ` [Qemu-devel] [RFC] make write_elf_xx functions part of CPUClass, use CPUState Jens Freimann
2013-04-09 13:15 ` Andreas Färber
2013-04-19 14:45 ` [Qemu-devel] [PATCH 0/2] qom: make cpu_write_elfXX_ functions part of CPUClass Jens Freimann
2013-04-19 14:45 ` Jens Freimann [this message]
2013-04-19 14:45 ` [Qemu-devel] [PATCH 2/2] i386: use CPUClass->write_elf* functions Jens Freimann
2013-04-29 14:21 ` [Qemu-devel] [PATCH 0/2] qom: make cpu_write_elfXX_ functions part of CPUClass Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366382707-64886-2-git-send-email-jfrei@linux.vnet.ibm.com \
--to=jfrei@linux.vnet.ibm.com \
--cc=afaerber@suse.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rabin@rab.in \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).