From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Gp7-0003Mo-Ro for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:56:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1Gp4-0000C2-5K for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:56:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1Gp4-0000Bm-0L for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:56:38 -0400 References: <20161027042300.5929-1-haozhong.zhang@intel.com> <20161027042300.5929-3-haozhong.zhang@intel.com> <20161031172314.GD2919@thinpad.lan.raisama.net> From: Paolo Bonzini Message-ID: Date: Mon, 31 Oct 2016 18:56:31 +0100 MIME-Version: 1.0 In-Reply-To: <20161031172314.GD2919@thinpad.lan.raisama.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/3] exec.c: check memory backend file size with 'size' option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost , Haozhong Zhang Cc: qemu-devel@nongnu.org, Igor Mammedov , Richard Henderson , Peter Crosthwaite On 31/10/2016 18:23, Eduardo Habkost wrote: > On Thu, Oct 27, 2016 at 12:22:59PM +0800, Haozhong Zhang wrote: >> If the memory backend file is not large enough to hold the required 'size', >> Qemu will report error and exit. >> >> Signed-off-by: Haozhong Zhang > > Applied to machine-next. Thanks! Also part of my pull request. :) Paolo >> --- >> exec.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/exec.c b/exec.c >> index a2b371a..264a25f 100644 >> --- a/exec.c >> +++ b/exec.c >> @@ -1316,6 +1316,13 @@ static void *file_ram_alloc(RAMBlock *block, >> goto error; >> } >> >> + if (file_size > 0 && file_size < memory) { >> + error_setg(errp, "backing store %s size %"PRId64 >> + " does not match 'size' option %"PRIu64, >> + path, file_size, memory); >> + goto error; >> + } >> + >> memory = ROUND_UP(memory, block->page_size); >> >> /* >> -- >> 2.10.1 >> >> >