mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-12-18 05:28:36 -07:00
fix qemu exit on memory hotplug when allocation fails at prealloc time
When adding hostmem backend at runtime, QEMU might exit with error: "os_mem_prealloc: Insufficient free host memory pages available to allocate guest RAM" It happens due to os_mem_prealloc() not handling errors gracefully. Fix it by passing errp argument so that os_mem_prealloc() could report error to callers and undo performed allocation when os_mem_prealloc() fails. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <1469008443-72059-1-git-send-email-imammedo@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
0b21757124
commit
056b68af77
5 changed files with 38 additions and 22 deletions
10
exec.c
10
exec.c
|
|
@ -1226,7 +1226,7 @@ static void *file_ram_alloc(RAMBlock *block,
|
|||
char *filename;
|
||||
char *sanitized_name;
|
||||
char *c;
|
||||
void *area;
|
||||
void *area = MAP_FAILED;
|
||||
int fd = -1;
|
||||
int64_t page_size;
|
||||
|
||||
|
|
@ -1314,13 +1314,19 @@ static void *file_ram_alloc(RAMBlock *block,
|
|||
}
|
||||
|
||||
if (mem_prealloc) {
|
||||
os_mem_prealloc(fd, area, memory);
|
||||
os_mem_prealloc(fd, area, memory, errp);
|
||||
if (errp && *errp) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
block->fd = fd;
|
||||
return area;
|
||||
|
||||
error:
|
||||
if (area != MAP_FAILED) {
|
||||
qemu_ram_munmap(area, memory);
|
||||
}
|
||||
if (unlink_on_error) {
|
||||
unlink(path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue