[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/21] exec: report error when memory < hpagesize
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 10/21] exec: report error when memory < hpagesize |
Date: |
Fri, 12 Sep 2014 15:58:47 +0200 |
From: Hu Tao <address@hidden>
Report an error when memory < hpagesize in file_ram_alloc() so callers
can handle the error.
If user adds a memory-backend-file object using object_add command,
specifying a size that is less than huge page size, qemu will core dump
with message:
Bad ram offset fffffffffffff000
Aborted (core dumped)
This patch fixes the problem. With this patch, qemu reports error
message like:
qemu-system-x86_64: -object
memory-backend-file,mem-path=/hugepages,id=mem-file0,size=1M: memory
size 0x100000 must be equal to or larger than huge page size 0x200000
Signed-off-by: Hu Tao <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
exec.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/exec.c b/exec.c
index 2b9c4c5..1100208 100644
--- a/exec.c
+++ b/exec.c
@@ -1059,9 +1059,9 @@ static void *file_ram_alloc(RAMBlock *block,
char *filename;
char *sanitized_name;
char *c;
- void *area;
+ void *area = NULL;
int fd;
- unsigned long hpagesize;
+ uint64_t hpagesize;
hpagesize = gethugepagesize(path);
if (!hpagesize) {
@@ -1069,7 +1069,10 @@ static void *file_ram_alloc(RAMBlock *block,
}
if (memory < hpagesize) {
- return NULL;
+ error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to "
+ "or larger than huge page size 0x%" PRIx64,
+ memory, hpagesize);
+ goto error;
}
if (kvm_enabled() && !kvm_has_sync_mmu()) {
--
2.1.0
- [Qemu-devel] [PULL 00/21] KVM, memory, build, migration changes for 2014-09-11, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 02/21] trace: Only link generated-tracers.o with "simple" backend, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 04/21] util: Don't link host-utils.o if it's empty, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 01/21] kvm: do not abort if KVM_RUN fails, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 03/21] util: Move general qemu_getauxval to util/getauxval.c, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 06/21] exec: add parameter errp to qemu_ram_alloc and qemu_ram_alloc_from_ptr, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 08/21] memory: add parameter errp to memory_region_init_rom_device, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 09/21] hostmem-ram: don't exit qemu if size of memory-backend-ram is way too big, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 07/21] memory: add parameter errp to memory_region_init_ram, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 11/21] exec: add parameter errp to gethugepagesize, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 10/21] exec: report error when memory < hpagesize,
Paolo Bonzini <=
- [Qemu-devel] [PULL 05/21] rules.mak: Fix DSO build by pulling in archive symbols, Paolo Bonzini, 2014/09/12
- [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Paolo Bonzini, 2014/09/12
- Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Pavel Dovgaluk, 2014/09/19
- Message not available
- Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Paolo Bonzini, 2014/09/19
- Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Pavel Dovgaluk, 2014/09/19
- Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Paolo Bonzini, 2014/09/19
- Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Pavel Dovgaluk, 2014/09/22
- Message not available
- Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Paolo Bonzini, 2014/09/22
- Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix, Pavel Dovgaluk, 2014/09/26