All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Hu Tao <hutao@cn.fujitsu.com>, qemu-devel@nongnu.org
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>,
	Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
	Yasuaki Isimatu <isimatu.yasuaki@jp.fujitsu.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v7 RESEND 3/8] memory: add parameter errp to memory_region_init_ram_ptr
Date: Tue, 09 Sep 2014 13:18:32 +0200	[thread overview]
Message-ID: <540EE208.7040607@redhat.com> (raw)
In-Reply-To: <b4dce936e5c209c797fec95a12b2d44da3a74487.1410240131.git.hutao@cn.fujitsu.com>

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 --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);

  reply	other threads:[~2014-09-09 11:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09  5:27 [Qemu-devel] [PATCH v7 RESEND 0/8] memory API improvements and bug fixes for memory backends Hu Tao
2014-09-09  5:27 ` [Qemu-devel] [PATCH v7 RESEND 1/8] exec: add parameter errp to qemu_ram_alloc and qemu_ram_alloc_from_ptr Hu Tao
2014-09-09  5:27 ` [Qemu-devel] [PATCH v7 RESEND 2/8] memory: add parameter errp to memory_region_init_ram Hu Tao
2014-09-09 11:28   ` Paolo Bonzini
2014-09-09  5:27 ` [Qemu-devel] [PATCH v7 RESEND 3/8] memory: add parameter errp to memory_region_init_ram_ptr Hu Tao
2014-09-09 11:18   ` Paolo Bonzini [this message]
2014-09-09  5:27 ` [Qemu-devel] [PATCH v7 RESEND 4/8] memory: add parameter errp to memory_region_init_rom_device Hu Tao
2014-09-09 11:20   ` Paolo Bonzini
2014-09-10  2:05     ` Hu Tao
2014-09-10  9:11       ` Paolo Bonzini
2014-09-09  5:27 ` [Qemu-devel] [PATCH v7 RESEND 5/8] hostmem-ram: don't exit qemu if size of memory-backend-ram is way too big Hu Tao
2014-09-09  5:27 ` [Qemu-devel] [PATCH v7 RESEND 6/8] exec: file_ram_alloc: don't exit if failed to preallocate memory Hu Tao
2014-09-09 11:23   ` Paolo Bonzini
2014-09-09  5:28 ` [Qemu-devel] [PATCH v7 RESEND 7/8] exec: report error when memory < hpagesize Hu Tao
2014-09-09  5:28 ` [Qemu-devel] [PATCH v7 RESEND 8/8] exec: add parameter errp to gethugepagesize Hu Tao
2014-09-09 11:29 ` [Qemu-devel] [PATCH v7 RESEND 0/8] memory API improvements and bug fixes for memory backends Paolo Bonzini
2014-09-10  2:09   ` Hu Tao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=540EE208.7040607@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=isimatu.yasuaki@jp.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    --cc=y-goto@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.