elf2dmp: use Linux mmap with MAP_NORESERVE when possible

Glib's g_mapped_file_new maps file with PROT_READ|PROT_WRITE and
MAP_PRIVATE. This leads to premature physical memory allocation of dump
file size on Linux hosts and may fail. On Linux, mapping the file with
MAP_NORESERVE limits the allocation by available memory.

Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-id: 20230915170153.10959-5-viktor@daynix.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Viktor Prutyanov 2023-09-15 20:01:52 +03:00 committed by Peter Maydell
parent 9b7dcd8ff4
commit df7a75564e
2 changed files with 58 additions and 12 deletions

View file

@ -32,7 +32,9 @@ typedef struct QEMUCPUState {
int is_system(QEMUCPUState *s);
typedef struct QEMU_Elf {
#ifndef CONFIG_LINUX
GMappedFile *gmf;
#endif
size_t size;
void *map;
QEMUCPUState **state;