From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTCZ2-0002H6-Qc for qemu-devel@nongnu.org; Fri, 19 Apr 2013 10:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UTCZ1-0003Pi-0r for qemu-devel@nongnu.org; Fri, 19 Apr 2013 10:45:24 -0400 Received: from e06smtp12.uk.ibm.com ([195.75.94.108]:45754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTCZ0-0003PU-MJ for qemu-devel@nongnu.org; Fri, 19 Apr 2013 10:45:22 -0400 Received: from /spool/local by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Apr 2013 15:42:03 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id C84E71B08067 for ; Fri, 19 Apr 2013 15:45:18 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3JEj8Zl49086564 for ; Fri, 19 Apr 2013 14:45:08 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3JEjI1W004991 for ; Fri, 19 Apr 2013 08:45:18 -0600 From: Jens Freimann Date: Fri, 19 Apr 2013 16:45:06 +0200 Message-Id: <1366382707-64886-2-git-send-email-jfrei@linux.vnet.ibm.com> In-Reply-To: <1366382707-64886-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <5164147B.1020707@suse.de> <1366382707-64886-1-git-send-email-jfrei@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 1/2] qom: Convert cpu_write_elfXX_note functions to CPUState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?q?Andreas=20F=C3=A4rber?= Cc: Rabin Vincent , Peter Maydell , Jens Freimann , qemu-devel Convert cpu_write_elfXX_note functions to CPUClass methods and pass CPUState as argument Signed-off-by: "Jens Freimann 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