From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8vlN-0001JR-SD for qemu-devel@nongnu.org; Thu, 30 Jan 2014 12:50:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8vlH-0001OJ-D8 for qemu-devel@nongnu.org; Thu, 30 Jan 2014 12:50:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8vlH-0001Nx-5K for qemu-devel@nongnu.org; Thu, 30 Jan 2014 12:50:47 -0500 Message-ID: <52EA9115.6070104@redhat.com> Date: Thu, 30 Jan 2014 19:51:17 +0200 From: Orit Wasserman MIME-Version: 1.0 References: <1391066055-17024-1-git-send-email-owasserm@redhat.com> <1391066055-17024-6-git-send-email-owasserm@redhat.com> <20140130154809.GB2655@work-vm> In-Reply-To: <20140130154809.GB2655@work-vm> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/6] Don't abort on out of memory when creating page cache List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, anthony@codemonkey.ws, quintela@redhat.com On 01/30/2014 05:48 PM, Dr. David Alan Gilbert wrote: > * Orit Wasserman (owasserm@redhat.com) wrote: >> Signed-off-by: Orit Wasserman >> --- >> arch_init.c | 16 ++++++++++++++-- >> page_cache.c | 18 ++++++++++++++---- >> 2 files changed, 28 insertions(+), 6 deletions(-) >> >> diff --git a/arch_init.c b/arch_init.c >> index 5eff80b..806d096 100644 >> --- a/arch_init.c >> +++ b/arch_init.c >> @@ -664,8 +664,20 @@ static int ram_save_setup(QEMUFile *f, void *opaque) >> DPRINTF("Error creating cache\n"); >> return -1; >> } >> - XBZRLE.encoded_buf = g_malloc0(TARGET_PAGE_SIZE); >> - XBZRLE.current_buf = g_malloc(TARGET_PAGE_SIZE); >> + >> + /* We prefer not to abort if there is no memory */ >> + XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE); >> + if (!XBZRLE.encoded_buf) { >> + DPRINTF("Error allocating encoded_buf\n"); >> + return -1; >> + } >> + >> + XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE); >> + if (!XBZRLE.current_buf) { >> + DPRINTF("Error allocating current_buf\n"); >> + return -1; >> + } > > Would it be best to free encoded_buf in this second exit case? > It is freed in migration_end (that is called when migration fails or canceled). Orit > Dave > -- > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK >