summaryrefslogtreecommitdiffstats
path: root/numa.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-05-14 17:43:20 +0800
committerMichael S. Tsirkin <mst@redhat.com>2014-06-19 18:44:20 +0300
commit7f56e740a68c9f4ccebf7ad7590e82fbb30ffc87 (patch)
treecb8e9a6884921dcf55caf139884f34d2f4f93424 /numa.c
parent0b183fc871e61f4a586fdef2c0f880b6a856e444 (diff)
downloadhqemu-7f56e740a68c9f4ccebf7ad7590e82fbb30ffc87.zip
hqemu-7f56e740a68c9f4ccebf7ad7590e82fbb30ffc87.tar.gz
memory: add error propagation to file-based RAM allocation
Right now, -mem-path will fall back to RAM-based allocation in some cases. This should never happen with "-object memory-file", prepare the code by adding correct error propagation. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> MST: drop \n at end of error messages
Diffstat (limited to 'numa.c')
-rw-r--r--numa.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/numa.c b/numa.c
index 7c36bb5..8af9c91 100644
--- a/numa.c
+++ b/numa.c
@@ -230,7 +230,18 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
{
if (mem_path) {
#ifdef __linux__
- memory_region_init_ram_from_file(mr, owner, name, ram_size, mem_path);
+ Error *err = NULL;
+ memory_region_init_ram_from_file(mr, owner, name, ram_size,
+ mem_path, &err);
+
+ /* Legacy behavior: if allocation failed, fall back to
+ * regular RAM allocation.
+ */
+ if (!memory_region_size(mr)) {
+ qerror_report_err(err);
+ error_free(err);
+ memory_region_init_ram(mr, owner, name, ram_size);
+ }
#else
fprintf(stderr, "-mem-path not supported on this host\n");
exit(1);
OpenPOWER on IntegriCloud