From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvrSf-00019b-0f for qemu-devel@nongnu.org; Sat, 14 Jun 2014 13:09:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WvrSZ-0000NS-VS for qemu-devel@nongnu.org; Sat, 14 Jun 2014 13:09:48 -0400 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]:39628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvrSZ-0000NM-OF for qemu-devel@nongnu.org; Sat, 14 Jun 2014 13:09:43 -0400 Received: by mail-wi0-f178.google.com with SMTP id n15so2240175wiw.5 for ; Sat, 14 Jun 2014 10:09:42 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <539C81D1.9010900@redhat.com> Date: Sat, 14 Jun 2014 19:09:37 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <5a1cdce658586b46e49ce906d56aeff502bc24bd.1402720673.git.hutao@cn.fujitsu.com> In-Reply-To: <5a1cdce658586b46e49ce906d56aeff502bc24bd.1402720673.git.hutao@cn.fujitsu.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 4/4] memory-backend-file: error out if failed to allocate memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao , qemu-devel@nongnu.org Cc: Yasunori Goto , "Michael S. Tsirkin" , Igor Mammedov Il 14/06/2014 06:48, Hu Tao ha scritto: > If user adds a memory-backend-file object using object_add command, > specifying a non-existing directory for property mem-path, qemu > will core dump with message: > > /nonexistingdir: No such file or directory > Bad ram offset fffffffffffff000 > Aborted (core dumped) > > This patch fixes this problem. > > Signed-off-by: Hu Tao > --- > backends/hostmem-file.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c > index 5179994..70172d1 100644 > --- a/backends/hostmem-file.c > +++ b/backends/hostmem-file.c > @@ -55,6 +55,9 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) > object_get_canonical_path(OBJECT(backend)), > backend->size, fb->share, > fb->mem_path, errp); > + if (backend->mr.ram_addr == -1) { > + error_setg(errp, "failed to allocate memory"); > + } qemu_ram_alloc_from_file is where this error_setg should be added instead. Paolo > } > #endif > } >