From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1GIs-0004Ws-24 for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:23:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1GIn-0007ik-5J for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:23:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51538) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1GIn-0007iZ-0I for qemu-devel@nongnu.org; Mon, 31 Oct 2016 13:23:17 -0400 Date: Mon, 31 Oct 2016 15:23:14 -0200 From: Eduardo Habkost Message-ID: <20161031172314.GD2919@thinpad.lan.raisama.net> References: <20161027042300.5929-1-haozhong.zhang@intel.com> <20161027042300.5929-3-haozhong.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161027042300.5929-3-haozhong.zhang@intel.com> 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: Haozhong Zhang Cc: qemu-devel@nongnu.org, Igor Mammedov , Paolo Bonzini , Richard Henderson , Peter Crosthwaite 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! > --- > 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 > > -- Eduardo