From patchwork Thu Jun 7 07:39:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 163519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7173AB6FD3 for ; Thu, 7 Jun 2012 18:28:17 +1000 (EST) Received: from localhost ([::1]:55738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScY4l-0000dH-B4 for incoming@patchwork.ozlabs.org; Thu, 07 Jun 2012 04:28:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScXLO-0006aZ-RB for qemu-devel@nongnu.org; Thu, 07 Jun 2012 03:41:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScXLJ-0005xC-69 for qemu-devel@nongnu.org; Thu, 07 Jun 2012 03:41:22 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:56182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScXLI-0005d9-TO for qemu-devel@nongnu.org; Thu, 07 Jun 2012 03:41:17 -0400 Received: by mail-pb0-f45.google.com with SMTP id ro12so749296pbb.4 for ; Thu, 07 Jun 2012 00:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=lx8MgIejKuE4Wn0qFmuSfh2MRJK4kqbM0oOxCEU6+6c=; b=F3BpZ+FAVfQ2hmTIrMyhvAy5k2xpj1HP2jnrDZJT3a0Y7FpZtZcuSBUAgBpmizZZ+k dSMeitHYSel2XOxFsrA200dmESHpRJKsT9oexBfnLZEczSpr0E8qix0IGHf5wBKIQp2v LM/gEGrM2EBfF74EBWRlrIPrT8FhJ4CIx58wMt3Toea/ufAYWoUjEs1GHyC4qshDMUrq NvankNx7OUxwhKmioOyQjls9eFH6J14QELdGdmMOiQSOEd+1iMiEWlY+CCSakg4tbTwe RTF1cXJwDqp8myJ3kPDGSEOSEylDkroFhpjikD7Zkmztct/x6L5/C99ono7CIc487+IV gLQw== Received: by 10.68.221.74 with SMTP id qc10mr6479046pbc.31.1339054875743; Thu, 07 Jun 2012 00:41:15 -0700 (PDT) Received: from yakj.usersys.redhat.com.usersys.redhat.com (p40081-ipngn402hodogaya.kanagawa.ocn.ne.jp. [180.23.161.81]) by mx.google.com with ESMTPS id oo6sm3232781pbc.22.2012.06.07.00.41.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 07 Jun 2012 00:41:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Jun 2012 09:39:54 +0200 Message-Id: <1339054814-20939-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1339054814-20939-1-git-send-email-pbonzini@redhat.com> References: <1339054814-20939-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH v3 09/29] dump: remove dumping stuff from cpu-all.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This simplifies things, because they will only be included for softmmu targets and because the stubs are taken out-of-line in separate files, which in the future could even be compiled only once. Cc: Wen Congyang Signed-off-by: Paolo Bonzini --- Makefile.target | 10 +++-- cpu-all.h | 70 --------------------------------- dump-stub.c | 77 +++++++++++++++++++++++++++++++++++++ dump.c | 11 ------ dump.h | 12 ++++++ memory_mapping-stub.c | 33 ++++++++++++++++ memory_mapping.c | 3 -- memory_mapping.h | 16 ++------ target-i386/arch_memory_mapping.c | 1 + 9 files changed, 132 insertions(+), 101 deletions(-) create mode 100644 dump-stub.c create mode 100644 memory_mapping-stub.c diff --git a/Makefile.target b/Makefile.target index f1ec554..4c81171 100644 --- a/Makefile.target +++ b/Makefile.target @@ -3,6 +3,8 @@ CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y) CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y) CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y) +CONFIG_NO_GET_MEMORY_MAPPING = $(if $(subst n,,$(CONFIG_HAVE_GET_MEMORY_MAPPING)),n,y) +CONFIG_NO_CORE_DUMP = $(if $(subst n,,$(CONFIG_HAVE_CORE_DUMP)),n,y) include ../config-host.mak include config-devices.mak @@ -144,10 +146,10 @@ obj-$(CONFIG_KVM) += kvm.o kvm-all.o obj-$(CONFIG_NO_KVM) += kvm-stub.o obj-$(CONFIG_VGA) += vga.o obj-y += memory.o savevm.o cputlb.o -obj-y += memory_mapping.o -obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += arch_memory_mapping.o -obj-$(CONFIG_HAVE_CORE_DUMP) += arch_dump.o -obj-y += dump.o +obj-$(CONFIG_HAVE_GET_MEMORY_MAPPING) += memory_mapping.o arch_memory_mapping.o +obj-$(CONFIG_HAVE_CORE_DUMP) += dump.o arch_dump.o +obj-$(CONFIG_NO_GET_MEMORY_MAPPING) += memory_mapping-stub.o +obj-$(CONFIG_NO_CORE_DUMP) += dump-stub.o LIBS+=-lz QEMU_CFLAGS += $(VNC_TLS_CFLAGS) diff --git a/cpu-all.h b/cpu-all.h index 624030d..3a93c0c 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -22,8 +22,6 @@ #include "qemu-common.h" #include "qemu-tls.h" #include "cpu-common.h" -#include "memory_mapping.h" -#include "dump.h" /* some important defines: * @@ -525,72 +523,4 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, uint8_t *buf, int len, int is_write); -#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) -int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); -bool cpu_paging_enabled(CPUArchState *env); -#else -static inline int cpu_get_memory_mapping(MemoryMappingList *list, - CPUArchState *env) -{ - return -1; -} - -static inline bool cpu_paging_enabled(CPUArchState *env) -{ - return true; -} -#endif - -typedef int (*write_core_dump_function)(void *buf, size_t size, void *opaque); -#if defined(CONFIG_HAVE_CORE_DUMP) -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); -#else -static inline int cpu_write_elf64_note(write_core_dump_function f, - CPUArchState *env, int cpuid, - void *opaque) -{ - return -1; -} - -static inline int cpu_write_elf32_note(write_core_dump_function f, - CPUArchState *env, int cpuid, - void *opaque) -{ - return -1; -} - -static inline int cpu_write_elf64_qemunote(write_core_dump_function f, - CPUArchState *env, - void *opaque) -{ - return -1; -} - -static inline int cpu_write_elf32_qemunote(write_core_dump_function f, - CPUArchState *env, - void *opaque) -{ - return -1; -} - -static inline int cpu_get_dump_info(ArchDumpInfo *info) -{ - return -1; -} - -static inline ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) -{ - return -1; -} -#endif - #endif /* CPU_ALL_H */ diff --git a/dump-stub.c b/dump-stub.c new file mode 100644 index 0000000..4c8bedb --- /dev/null +++ b/dump-stub.c @@ -0,0 +1,77 @@ +/* + * QEMU dump + * + * Copyright Fujitsu, Corp. 2011, 2012 + * + * Authors: + * Wen Congyang + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "qemu-common.h" +#include +#include "elf.h" +#include +#include +#include "cpu.h" +#include "cpu-all.h" +#include "targphys.h" +#include "monitor.h" +#include "kvm.h" +#include "dump.h" +#include "sysemu.h" +#include "bswap.h" +#include "memory_mapping.h" +#include "error.h" +#include "qmp-commands.h" +#include "gdbstub.h" + +/* we need this function in hmp.c */ +void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, + int64_t begin, bool has_length, int64_t length, + Error **errp) +{ + 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; +} + +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus) +{ + return -1; +} + diff --git a/dump.c b/dump.c index b24d4be..f5c7283 100644 --- a/dump.c +++ b/dump.c @@ -29,7 +29,6 @@ #include "qmp-commands.h" #include "gdbstub.h" -#if defined(CONFIG_HAVE_CORE_DUMP) static uint16_t cpu_convert_to_target16(uint16_t val, int endian) { if (endian == ELFDATA2LSB) { @@ -876,13 +875,3 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, g_free(s); } - -#else -/* we need this function in hmp.c */ -void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, - int64_t begin, bool has_length, int64_t length, - Error **errp) -{ - error_set(errp, QERR_UNSUPPORTED); -} -#endif diff --git a/dump.h b/dump.h index 28340cf..4dea3bb 100644 --- a/dump.h +++ b/dump.h @@ -20,4 +20,16 @@ typedef struct ArchDumpInfo { int d_class; /* ELFCLASS32 or ELFCLASS64 */ } 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); + #endif diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c new file mode 100644 index 0000000..104281d --- /dev/null +++ b/memory_mapping-stub.c @@ -0,0 +1,33 @@ +/* + * QEMU memory mapping + * + * Copyright Fujitsu, Corp. 2011, 2012 + * + * Authors: + * Wen Congyang + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "cpu.h" +#include "cpu-all.h" +#include "memory_mapping.h" + +int qemu_get_guest_memory_mapping(MemoryMappingList *list) +{ + return -2; +} + +int cpu_get_memory_mapping(MemoryMappingList *list, + CPUArchState *env) +{ + return -1; +} + +bool cpu_paging_enabled(CPUArchState *env) +{ + return true; +} + diff --git a/memory_mapping.c b/memory_mapping.c index 8810bb0..1125e3f 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -165,8 +165,6 @@ void memory_mapping_list_init(MemoryMappingList *list) QTAILQ_INIT(&list->head); } -#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) - static CPUArchState *find_paging_enabled_cpu(CPUArchState *start_cpu) { CPUArchState *env; @@ -210,7 +208,6 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list) return 0; } -#endif void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list) { diff --git a/memory_mapping.h b/memory_mapping.h index a1aa64f..3f00358 100644 --- a/memory_mapping.h +++ b/memory_mapping.h @@ -16,7 +16,6 @@ #include "qemu-queue.h" -#ifndef CONFIG_USER_ONLY /* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping { target_phys_addr_t phys_addr; @@ -31,6 +30,9 @@ typedef struct MemoryMappingList { QTAILQ_HEAD(, MemoryMapping) head; } MemoryMappingList; +int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); +bool cpu_paging_enabled(CPUArchState *env); + /* * add or merge the memory region [phys_addr, phys_addr + length) into the * memory mapping's list. The region's virtual address starts with virt_addr, @@ -51,14 +53,7 @@ void memory_mapping_list_init(MemoryMappingList *list); * -1: failed * -2: unsupported */ -#if defined(CONFIG_HAVE_GET_MEMORY_MAPPING) int qemu_get_guest_memory_mapping(MemoryMappingList *list); -#else -static inline int qemu_get_guest_memory_mapping(MemoryMappingList *list) -{ - return -2; -} -#endif /* get guest's memory mapping without do paging(virtual address is 0). */ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); @@ -66,9 +61,4 @@ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); void memory_mapping_filter(MemoryMappingList *list, int64_t begin, int64_t length); -#else - -/* We use MemoryMappingList* in cpu-all.h */ -typedef struct MemoryMappingList MemoryMappingList; -#endif #endif diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c index bd50e11..efb0211 100644 --- a/target-i386/arch_memory_mapping.c +++ b/target-i386/arch_memory_mapping.c @@ -13,6 +13,7 @@ #include "cpu.h" #include "cpu-all.h" +#include "memory_mapping.h" /* PAE Paging or IA-32e Paging */ static void walk_pte(MemoryMappingList *list, target_phys_addr_t pte_start_addr,