From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Hu Tao <hutao@cn.fujitsu.com>,
Igor Mammedov <imammedo@redhat.com>,
qemu-devel@nongnu.org, Yasunori Goto <y-goto@jp.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory
Date: Sun, 15 Jun 2014 12:58:47 +0300 [thread overview]
Message-ID: <20140615095847.GA11294@redhat.com> (raw)
In-Reply-To: <539C815B.3000203@redhat.com>
On Sat, Jun 14, 2014 at 07:07:39PM +0200, Paolo Bonzini wrote:
> Il 14/06/2014 06:48, Hu Tao ha scritto:
> >return -1 instead.
> >
> >Now user can add objects memory-backend-ram on-the-fly, fail it if
> >cannot allocate memory rather than quit qemu.
> >
> >Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
>
> This needs an audit of all callers or, alternatively, we need to add
> memory_region_init_ram_nofail. Better leave it for after the merge.
>
> Paolo
Specifically memory_region_init_ram_from_file does not seem to
handle failures.
qemu_ram_free chunk also looks weird. Can we not avoid calling
free on invalid addresses?
> >---
> > backends/hostmem-ram.c | 3 +++
> > exec.c | 6 +++++-
> > 2 files changed, 8 insertions(+), 1 deletion(-)
> >
> >diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c
> >index d9a8290..afb305d 100644
> >--- a/backends/hostmem-ram.c
> >+++ b/backends/hostmem-ram.c
> >@@ -28,6 +28,9 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> > path = object_get_canonical_path_component(OBJECT(backend));
> > memory_region_init_ram(&backend->mr, OBJECT(backend), path,
> > backend->size);
> >+ if (backend->mr.ram_addr == -1) {
> >+ error_setg(errp, "can't allocate memory");
> >+ }
> > g_free(path);
> > }
> >
> >diff --git a/exec.c b/exec.c
> >index 8705cc5..74560e5 100644
> >--- a/exec.c
> >+++ b/exec.c
> >@@ -1228,7 +1228,7 @@ static ram_addr_t ram_block_add(RAMBlock *new_block)
> > if (!new_block->host) {
> > fprintf(stderr, "Cannot set up guest memory '%s': %s\n",
> > new_block->mr->name, strerror(errno));
> >- exit(1);
> >+ return -1;
> > }
> > memory_try_enable_merging(new_block->host, new_block->length);
> > }
> >@@ -1356,6 +1356,10 @@ void qemu_ram_free(ram_addr_t addr)
> > {
> > RAMBlock *block;
> >
> >+ if (addr == -1) {
> >+ return;
> >+ }
> >+
> > /* This assumes the iothread lock is taken here too. */
> > qemu_mutex_lock_ramlist();
> > QTAILQ_FOREACH(block, &ram_list.blocks, next) {
> >
next prev parent reply other threads:[~2014-06-15 9:58 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 11:15 [Qemu-devel] [PATCH v5 00/16] NUMA series v5 Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 01/16] fixup! NUMA: check if the total numa memory size is equal to ram_size Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 02/16] vl: redo -object parsing Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 03/16] fixup! qmp: improve error reporting for -object and object-add Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 04/16] pc: pass MachineState to pc_memory_init Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 05/16] backend:hostmem: replace hostmemory with host_memory Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 06/16] hostmem: separate allocation from UserCreatable complete method Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 07/16] fixup! numa: add -numa node, memdev= option Hu Tao
2014-06-10 11:27 ` Michael S. Tsirkin
2014-06-10 11:30 ` Michael S. Tsirkin
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 08/16] hostmem: add file-based HostMemoryBackend Hu Tao
2014-06-11 8:03 ` Michael S. Tsirkin
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 09/16] hostmem: add merge and dump properties Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 10/16] hostmem: allow preallocation of any memory region Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 11/16] hostmem: add property to map memory with MAP_SHARED Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 12/16] hostmem: add properties for NUMA memory policy Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 13/16] tests: fix memory leak in test of string input visitor Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 14/16] qapi: make string input visitor parse int list Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 15/16] qapi: make string output " Hu Tao
2014-06-10 11:15 ` [Qemu-devel] [PATCH v5 16/16] qmp: add query-memdev Hu Tao
2014-06-12 7:41 ` [Qemu-devel] [PATCH v5 00/16] NUMA series v5 Michael S. Tsirkin
2014-06-12 7:53 ` Hu Tao
2014-06-13 8:03 ` Michael S. Tsirkin
2014-06-13 8:18 ` Paolo Bonzini
2014-06-13 8:46 ` Michael S. Tsirkin
2014-06-13 8:49 ` Hu Tao
2014-06-13 8:54 ` Michael S. Tsirkin
2014-06-14 4:48 ` [Qemu-devel] [PATCH RFC 0/4] fixes for pci tree Hu Tao
2014-06-14 4:48 ` [Qemu-devel] [PATCH RFC 1/4] get rid of signed range Hu Tao
2014-06-15 9:00 ` Michael S. Tsirkin
2014-06-16 9:47 ` Hu Tao
2014-06-16 15:06 ` Michael S. Tsirkin
2014-06-14 4:48 ` [Qemu-devel] [PATCH RFC 2/4] check if we have space left for hotplugged memory Hu Tao
2014-06-15 8:53 ` Michael S. Tsirkin
2014-06-16 9:47 ` Hu Tao
2014-06-14 4:48 ` [Qemu-devel] [PATCH RFC 3/4] exec: don't exit unconditionally if failed to allocate memory Hu Tao
2014-06-14 17:07 ` Paolo Bonzini
2014-06-15 9:58 ` Michael S. Tsirkin [this message]
2014-06-16 9:54 ` Hu Tao
2014-06-16 10:07 ` Paolo Bonzini
2014-06-14 4:48 ` [Qemu-devel] [PATCH RFC 4/4] memory-backend-file: error out " Hu Tao
2014-06-14 17:09 ` Paolo Bonzini
2014-06-16 6:30 ` Hu Tao
2014-06-15 10:00 ` [Qemu-devel] [PATCH RFC 0/4] fixes for pci tree Michael S. Tsirkin
2014-06-16 6:29 ` Hu Tao
2014-06-16 7:04 ` Michael S. Tsirkin
2014-06-16 8:28 ` 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=20140615095847.GA11294@redhat.com \
--to=mst@redhat.com \
--cc=hutao@cn.fujitsu.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.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.