diff mbox

[v7,RESEND,3/8] memory: add parameter errp to memory_region_init_ram_ptr

Message ID 540EE208.7040607@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Sept. 9, 2014, 11:18 a.m. UTC
Il 09/09/2014 07:27, Hu Tao ha scritto:
> Add parameter errp to memory_region_init_ram_ptr and update all call
> sites to pass in &error_abort.
> 
> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>

Aborting in VFIO would be wrong, since VFIO devices can be hotplugged.  
But actually, ram_block_add can never fail when called from 
qemu_ram_alloc_from_ptr, so let's instead do:
diff mbox

Patch

diff --git a/exec.c b/exec.c
index 2b9c4c5..0ca73c8 100644
--- a/exec.c
+++ b/exec.c
@@ -1373,7 +1373,7 @@  ram_addr_t qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
 #endif
 
 ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
-                                   MemoryRegion *mr, Error **errp)
+                                   MemoryRegion *mr)
 {
     RAMBlock *new_block;
     ram_addr_t addr;
@@ -1388,13 +1388,7 @@  ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
     if (host) {
         new_block->flags |= RAM_PREALLOC;
     }
-    addr = ram_block_add(new_block, &local_err);
-    if (local_err) {
-        g_free(new_block);
-        error_propagate(errp, local_err);
-        return -1;
-    }
-    return addr;
+    return ram_block_add(new_block, &error_abort);
 }
 
 ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr, Error **errp)
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
index cf1d4c7..7c6f80e 100644
--- a/include/exec/ram_addr.h
+++ b/include/exec/ram_addr.h
@@ -26,7 +26,7 @@  ram_addr_t qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr,
                                     bool share, const char *mem_path,
                                     Error **errp);
 ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
-                                   MemoryRegion *mr, Error **errp);
+                                   MemoryRegion *mr);
 ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr, Error **errp);
 int qemu_get_ram_fd(ram_addr_t addr);
 void *qemu_get_ram_block_host_ptr(ram_addr_t addr);