aboutsummaryrefslogtreecommitdiff
path: root/dump.c
AgeCommit message (Collapse)AuthorFilesLines
2016-03-22util: move declarations out of qemu-common.hVeronia Bahaa1-1/+1
Move declarations out of qemu-common.h for functions declared in utils/ files: e.g. include/qemu/path.h for utils/path.c. Move inline functions out of qemu-common.h and into new files (e.g. include/qemu/bcd.h) Signed-off-by: Veronia Bahaa <veroniabahaa@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: add qmp event DUMP_COMPLETEDPeter Xu1-6/+12
One new QMP event DUMP_COMPLETED is added. When a dump finishes, one DUMP_COMPLETED event will occur to notify the user. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-12-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22Dump: add qmp command "query-dump"Peter Xu1-4/+19
When dump-guest-memory is requested with detach flag, after its return, user could query its status using "query-dump" command (with no argument). The result contains: - status: current dump status - completed: bytes written in the latest dump - total: bytes to write in the latest dump From completed and total, we could know how much work finished by calculating: 100.0 * completed / total (%) Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <1455772616-8668-10-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22DumpState: adding total_size and written_size fieldsPeter Xu1-0/+32
Here, total_size is the size in bytes to be dumped (raw data, which means before compression), while written_size are bytes handled (raw size too). Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <1455772616-8668-9-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: add "detach" supportPeter Xu1-1/+26
If "detach" is provided, one thread is created to do the dump work, while main thread will return immediately. For each GuestPhysBlock, adding one more field "mr" to points to MemoryRegion that it belongs, also ref the mr before use. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-8-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: disable dump when in INMIGRATE statePeter Xu1-0/+5
Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-7-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: introduce dump_process() helper function.Peter Xu1-10/+21
No functional change. Cleanup only. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-6-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: add dump_in_progress() helper functionPeter Xu1-0/+13
For now, it has no effect. It will be used in dump detach support. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-5-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: using static DumpState, add DumpStatusPeter Xu1-5/+16
Instead of malloc/free each time for DumpState, make it static. Added DumpStatus to show status for dump. This is to be used for detached dump. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-4-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: add "detach" flag for QMP/HMP interfaces.Peter Xu1-2/+3
This patch only adds the interfaces, but does not implement them. "detach" parameter is made optional, to make sure that all the old dump-guest-memory requests will still be able to work. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-3-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-22dump-guest-memory: cleanup: removing dump_{error|cleanup}().Peter Xu1-46/+32
It might be a little bit confusing and error prone to do dump_cleanup() in these two functions. A better way is to do dump_cleanup() before dump finish, no matter whether dump has succeeded or not. Signed-off-by: Peter Xu <peterx@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-Id: <1455772616-8668-2-git-send-email-peterx@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-02-04all: Clean up includesPeter Maydell1-1/+1
Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
2016-01-15dump: allow target to set the physical baseAndrew Jones1-2/+2
crash assumes the physical base in the kdump subheader of makedumpfile formatted dumps is correct. Zero is not correct for all architectures, so allow it to be changed. (No functional change.) Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1452542185-10914-5-git-send-email-drjones@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-01-15dump: allow target to set the page sizeAndrew Jones1-49/+78
This is necessary for targets that don't have TARGET_PAGE_SIZE == real-target-page-size. The target should set the page size to the correct one, if known, or, if not known, to the maximum page size it supports. (No functional change.) Signed-off-by: Andrew Jones <drjones@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1452542185-10914-4-git-send-email-drjones@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-06-22Include qapi/qmp/qerror.h exactly where neededMarkus Armbruster1-0/+1
In particular, don't include it into headers. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2015-06-22qerror: Clean up QERR_ macros to expand into a single stringMarkus Armbruster1-6/+6
These macros expand into error class enumeration constant, comma, string. Unclean. Has been that way since commit 13f59ae. The error class is always ERROR_CLASS_GENERIC_ERROR since the previous commit. Clean up as follows: * Prepend every use of a QERR_ macro by ERROR_CLASS_GENERIC_ERROR, and delete it from the QERR_ macro. No change after preprocessing. * Rewrite error_set(ERROR_CLASS_GENERIC_ERROR, ...) into error_setg(...). Again, no change after preprocessing. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-11-02dump: Fix dump-guest-memory termination and use-after-closeGonglei1-7/+4
dump_iterate() dumps blocks in a loop. Eventually, get_next_block() returns "no more". We then call dump_completed(). But we neglect to break the loop! Broken in commit 4c7e251a. Because of that, we dump the last block again. This attempts to write to s->fd, which fails if we're lucky. The error makes dump_iterate() return failure. It's the only way it can ever return. Theoretical: if we're not so lucky, something else has opened something for writing and got the same fd. dump_iterate() then keeps looping, messing up the something else's output, until a write fails, or the process mercifully terminates. The obvious fix is to restore the return lost in commit 4c7e251a. But the root cause of the bug is needlessly opaque loop control. Replace it by a clean do ... while loop. This makes the badly chosen return values of get_next_block() more visible. Cleaning that up is outside the scope of this bug fix. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-10-23dump: Turn some functions to void to make code cleanerzhanghailiang1-170/+142
Functions shouldn't return an error code and an Error object at the same time. Turn all these functions that returning Error object to void. We also judge if a function success or fail by reference to the local_err. Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-10-23dump: Propagate errors into qmp_dump_guest_memory()zhanghailiang1-83/+82
The code calls dump_error() on error, and even passes it a suitable message. However, the message is thrown away, and its callers pass up only success/failure. All qmp_dump_guest_memory() can do is set a generic error. Propagate the errors properly, so qmp_dump_guest_memory() can return a more useful error. Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-08-18dump.c: Fix memory leak issue in cleanup processing for dump_init()Chen Gang1-13/+5
In dump_init(), when failure occurs, need notice about 'fd' and memory mapping. So call dump_cleanup() for it (need let all initializations at front). Also simplify dump_cleanup(): remove redundant 'ret' and redundant 'fd' checking. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-06-16dump: Make DumpState and endian conversion routines available for ↵Bharata B Rao1-141/+90
arch-specific dump code 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 <bharata@linux.ibm.com> [ rebased on top of current master branch, renamed endian helpers to cpu_to_dump{16,32,64}, pass a DumpState * argument to endian helpers, Greg Kurz <gkurz@linux.vnet.ibm.com> ] Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> [agraf: fix to apply] Signed-off-by: Alexander Graf <agraf@suse.de>
2014-06-11dump: simplify get_len_buf_out()Laszlo Ersek1-30/+16
We can (and should) rely on the fact that s->flag_compress is exactly one of DUMP_DH_COMPRESSED_ZLIB, DUMP_DH_COMPRESSED_LZO, and DUMP_DH_COMPRESSED_SNAPPY. This is ensured by the QMP schema and dump_init() in combination. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-06-11dump: hoist lzo_init() from get_len_buf_out() to dump_init()Laszlo Ersek1-7/+6
qmp_dump_guest_memory() dump_init() lzo_init() <---------+ create_kdump_vmcore() | write_dump_pages() | get_len_buf_out() | lzo_init() ------+ This patch doesn't change the fact that lzo_init() is called for every LZO-compressed dump, but it makes get_len_buf_out() more focused (single responsibility). Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-06-11dump: select header bitness based on ELF class, not ELF architectureLaszlo Ersek1-1/+1
The specific ELF architecture (d_machine) carries Too Much Information (TM) for deciding between create_header32() and create_header64(), use "d_class" instead (ELFCLASS32 vs. ELFCLASS64). This change adapts write_dump_header() to write_elf_loads(), dump_begin() etc. that also rely on the ELF class of the target for bitness selection. Considering the current targets that support dumping, cpu_get_dump_info() works as follows: - target-s390x/arch_dump.c: (EM_S390, ELFCLASS64) only - target-ppc/arch_dump.c (EM_PPC64, ELFCLASS64) only - target-i386/arch_dump.c: sets (EM_X86_64, ELFCLASS64) vs. (EM_386, ELFCLASS32) keying off the same Long Mode Active flag. Hence no observable change. Approximately-suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-06-11dump: eliminate DumpState.page_size ("guest's page size")Laszlo Ersek1-26/+25
Use TARGET_PAGE_SIZE and ~TARGET_PAGE_MASK instead. "DumpState.page_size" has type "size_t", whereas TARGET_PAGE_SIZE has type "int". TARGET_PAGE_MASK is of type "int" and has negative value. The patch affects the implicit type conversions as follows: - create_header32() and create_header64(): assigned to "block_size", which has type "uint32_t". No change. - get_next_page(): "block->target_start", "block->target_end" and "addr" have type "hwaddr" (uint64_t). Before the patch, - if "size_t" was "uint64_t", then no additional conversion was done as part of the usual arithmetic conversions, - If "size_t" was "uint32_t", then it was widened to uint64_t as part of the usual arithmetic conversions, for the remainder and addition operators. After the patch, - "~TARGET_PAGE_MASK" expands to ~~((1 << TARGET_PAGE_BITS) - 1). It has type "int" and positive value (only least significant bits set). That's converted (widened) to "uint64_t" for the bit-ands. No visible change. - The same holds for the (addr + TARGET_PAGE_SIZE) addition. - write_dump_pages(): - TARGET_PAGE_SIZE passed as argument to a bunch of functions that all have prototypes. No change. - When incrementing "offset_data" (of type "off_t"): given that we never build for ILP32_OFF32 (see "-D_FILE_OFFSET_BITS=64" in configure), "off_t" is always "int64_t", and we only need to consider: - ILP32_OFFBIG: "size_t" is "uint32_t". - before: int64_t += uint32_t. Page size converted to int64_t for the addition. - after: int64_t += int32_t. No change. - LP64_OFF64: "size_t" is "uint64_t". - before: int64_t += uint64_t. Offset converted to uint64_t for the addition, then the uint64_t result is converted to int64_t for storage. - after: int64_t += int32_t. Same as the ILP32_OFFBIG/after case. No visible change. - (size_out < s->page_size) comparisons, and (size_out = s->page_size) assignment: - before: "size_out" is of type "size_t", no implicit conversion for either operator. - after: TARGET_PAGE_SIZE (of type "int" and positive value) is converted to "size_t" (for the relop because the latter is one of "uint32_t" and "uint64_t"). No visible change. - dump_init(): - DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), s->page_size): The innermost "DumpState.max_mapnr" field has type uint64_t, which propagates through all implicit conversions at hand: #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) regardless of the page size macro argument's type. In the outer macro replacement, the page size is converted from uint32_t and int32_t alike to uint64_t. - (tmp * s->page_size) multiplication: "tmp" has size "uint64_t"; the RHS is converted to that type from uint32_t and int32_t just the same if it's not uint64_t to begin with. Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-06-11dump: eliminate DumpState.page_shift ("guest's page shift")Laszlo Ersek1-6/+4
Just use TARGET_PAGE_BITS. "DumpState.page_shift" used to have type "uint32_t", while the replacement TARGET_PAGE_BITS has type "int". Since "DumpState.page_shift" was only used as bit shift counts in the paddr_to_pfn() and pfn_to_paddr() macros, this is safe. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-06-11dump: simplify write_start_flat_header()Laszlo Ersek1-11/+9
Currently, the function - defines and populates an auto variable of type MakedumpfileHeader - allocates and zeroes a buffer of size MAX_SIZE_MDF_HEADER (4096) - copies the former into the latter (covering an initial portion of the latter) Fill in the MakedumpfileHeader structure in its final place (the alignment is OK because the structure lives at the address returned by g_malloc0()). Approximately-suggested-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-06-11dump: fill in the flat header signature more pleasingly to the eyeLaszlo Ersek1-2/+2
The "mh.signature" array field has size 16, and is zeroed by the preceding memset(). MAKEDUMPFILE_SIGNATURE expands to a string literal with string length 12 (size 13). There's no need to measure the length of MAKEDUMPFILE_SIGNATURE at runtime, nor for the extra zero-filling of "mh.signature" with strncpy(). Use memcpy() with MIN(sizeof, sizeof) for robustness (which is an integer constant expression, evaluable at compile time.) Approximately-suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-05-09dump: Drop pointless error_is_set(), DumpState member errpMarkus Armbruster1-4/+2
In qmp_dump_guest_memory(), the error must be clear on entry, and we always bail out after setting it, directly or via dump_init(). Therefore, both error_is_set() are always false. Drop them. DumpState member errp is now write-only. Drop it, too. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add 'query-dump-guest-memory-capability' commandqiaonuohan1-0/+33
'query-dump-guest-memory-capability' is used to query the available formats for 'dump-guest-memory'. The output of the command will be like: -> { "execute": "query-dump-guest-memory-capability" } <- { "return": { "formats": ["elf", "kdump-zlib", "kdump-lzo", "kdump-snappy"] } Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28Define the architecture for compressed dump formatqiaonuohan1-2/+5
Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: make kdump-compressed format available for 'dump-guest-memory'qiaonuohan1-6/+125
Make monitor command 'dump-guest-memory' be able to dump in kdump-compressed format. The command's usage: dump [-p] protocol [begin] [length] [format] 'format' is used to specified the format of vmcore and can be: 1. 'elf': ELF format, without compression 2. 'kdump-zlib': kdump-compressed format, with zlib-compressed 3. 'kdump-lzo': kdump-compressed format, with lzo-compressed 4. 'kdump-snappy': kdump-compressed format, with snappy-compressed Without 'format' being set, it is same as 'elf'. And if non-elf format is specified, paging and filter is not allowed. Note: 1. The kdump-compressed format is readable only with the crash utility and makedumpfile, and it can be smaller than the ELF format because of the compression support. 2. The kdump-compressed format is the 6th edition. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add API to write dump pagesqiaonuohan1-0/+231
functions are used to write page to vmcore. vmcore is written page by page. page desc is used to store the information of a page, including a page's size, offset, compression format, etc. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add APIs to operate DataCacheqiaonuohan1-0/+47
DataCache is used to store data temporarily, then the data will be written to vmcore. These functions will be called later when writing data of page to vmcore. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add API to write dump_bitmapqiaonuohan1-0/+164
functions are used to write 1st and 2nd dump_bitmap of kdump-compressed format, which is used to indicate whether the corresponded page is existed in vmcore. 1st and 2nd dump_bitmap are same, because dump level is specified to 1 here. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add API to write dump headerqiaonuohan1-0/+223
the functions are used to write header of kdump-compressed format to vmcore. Header of kdump-compressed format includes: 1. common header: DiskDumpHeader32 / DiskDumpHeader64 2. sub header: KdumpSubHeader32 / KdumpSubHeader64 3. extra information: only elf notes here Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add members to DumpState and init some of themqiaonuohan1-0/+28
add some members to DumpState that will be used in writing vmcore in kdump-compressed format. some of them, like page_size, will be initialized in the patch. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add API to write elf notes to bufferqiaonuohan1-0/+19
the function can be used by write_elf32_notes/write_elf64_notes to write notes to a buffer. If fd_write_vmcore is used, write_elf32_notes/write_elf64_notes will write elf notes to vmcore directly. Instead, if buf_write_note is used, elf notes will be written to opaque->note_buf at first. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add API to write vmcoreqiaonuohan1-0/+21
Function is used to write vmcore in flatten format. In flatten format, data is written block by block, and in front of each block, a struct MakedumpfileDataHeader is stored there to indicate the offset and size of the data block. struct MakedumpfileDataHeader { int64_t offset; int64_t buf_size; }; Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add API to write header of flatten formatqiaonuohan1-0/+42
flatten format will be used when writing kdump-compressed format. The format is also used by makedumpfile, you can refer to the following URL to get more detailed information about flatten format of kdump-compressed format: http://sourceforge.net/projects/makedumpfile/ The two functions here are used to write start flat header and end flat header to vmcore, and they will be called later when flatten format is used. struct MakedumpfileHeader stored at the head of vmcore is used to indicate the vmcore is in flatten format. struct MakedumpfileHeader { char signature[16]; /* = "makedumpfile" */ int64_t type; /* = 1 */ int64_t version; /* = 1 */ }; And struct MakedumpfileDataHeader, with offset and buf_size set to -1, is used to indicate the end of vmcore in flatten format. struct MakedumpfileDataHeader { int64_t offset; /* = -1 */ int64_t buf_size; /* = -1 */ }; Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: add argument to write_elfxx_notesqiaonuohan1-8/+8
write_elf32_notes/wirte_elf64_notes use fd_write_vmcore to write elf notes to vmcore. Adding parameter "WriteCoreDumpFunction f" makes it available to choose the method of writing elf notes Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2014-02-28dump: const-qualify the buf of WriteCoreDumpFunctionqiaonuohan1-1/+1
WriteCoreDumpFunction is a function pointer that points to the function used to write content in "buf" into core file, so "buf" should be const-qualify. Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-10-25dump-guest-memory: Check for the correct return valueAneesh Kumar K.V1-2/+2
We should check for error with s->note_size Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Alexander Graf <agraf@suse.de>
2013-09-03cpu: Use QTAILQ for CPU listAndreas Färber1-5/+5
Introduce CPU_FOREACH(), CPU_FOREACH_SAFE() and CPU_NEXT() shorthand macros. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-08-08dump: rebase from host-private RAMBlock offsets to guest-physical addressesLaszlo Ersek1-39/+38
RAMBlock.offset --> GuestPhysBlock.target_start RAMBlock.offset + RAMBlock.length --> GuestPhysBlock.target_end RAMBlock.length --> GuestPhysBlock.target_end - GuestPhysBlock.target_start "GuestPhysBlock.host_addr" is only used when writing the dump contents. This patch enables "crash" to work with the vmcore by rebasing the vmcore from the left side of the following diagram to the right side: host-private offset relative to ram_addr RAMBlock guest-visible paddrs 0 +-------------------+.....+-------------------+ 0 | ^ | | ^ | | 640 KB | | 640 KB | | v | | v | 0x0000a0000 +-------------------+.....+-------------------+ 0x0000a0000 | ^ | |XXXXXXXXXXXXXXXXXXX| | 384 KB | |XXXXXXXXXXXXXXXXXXX| | v | |XXXXXXXXXXXXXXXXXXX| 0x000100000 +-------------------+.....+-------------------+ 0x000100000 | ^ | | ^ | | 3583 MB | | 3583 MB | | v | | v | 0x0e0000000 +-------------------+.....+-------------------+ 0x0e0000000 | ^ |. |XXXXXXXXXXXXXXXXXXX| | above_4g_mem_size | . |XXXX PCI hole XXXXX| | v | . |XXXX XXXXX| ram_size +-------------------+ . |XXXX 512 MB XXXXX| . .|XXXXXXXXXXXXXXXXXXX| . +-------------------+ 0x100000000 . | ^ | . | above_4g_mem_size | .| v | +-------------------+ ram_size + 512 MB Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=981582 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-08-08dump: populate guest_phys_blocksLaszlo Ersek1-1/+1
While the machine is paused, in guest_phys_blocks_append() we register a one-shot MemoryListener, solely for the initial collection of the valid guest-physical memory ranges that happens at listener registration time. For each range that is reported to guest_phys_blocks_region_add(), we attempt to merge the range with the preceding one. Ranges can only be joined if they are contiguous in both guest-physical address space, and contiguous in host virtual address space. The "maximal" ranges that remain in the end constitute the guest-physical memory map that the dump will be based on. Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=981582 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-08-08dump: introduce GuestPhysBlockListLaszlo Ersek1-12/+19
The vmcore must use physical addresses that are visible to the guest, not addresses that point into linear RAMBlocks. As first step, introduce the list type into which we'll collect the physical mappings in effect at the time of the dump. Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=981582 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-08-08dump: clamp guest-provided mapping lengths to ramblock sizesLaszlo Ersek1-25/+40
Even a trusted & clean-state guest can map more memory than what it was given. Since the vmcore contains RAMBlocks, mapping sizes should be clamped to RAMBlock sizes. Otherwise such oversized mappings can exceed the entire file size, and ELF parsers might refuse even the valid portion of the PT_LOAD entry. Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=981582 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-07-09cpu: Make first_cpu and next_cpu CPUStateAndreas Färber1-10/+6
Move next_cpu from CPU_COMMON to CPUState. Move first_cpu variable to qom/cpu.h. gdbstub needs to use CPUState::env_ptr for now. cpu_copy() no longer needs to save and restore cpu_next. Acked-by: Paolo Bonzini <pbonzini@redhat.com> [AF: Rebased, simplified cpu_copy()] Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-06-17dump: qmp_dump_guest_memory(): use error_setg_file_open()Luiz Capitulino1-1/+1
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>