From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bzljA-0000Mo-MH for qemu-devel@nongnu.org; Thu, 27 Oct 2016 10:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bzlj5-0001LJ-58 for qemu-devel@nongnu.org; Thu, 27 Oct 2016 10:32:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60968) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bzlj5-0001KI-02 for qemu-devel@nongnu.org; Thu, 27 Oct 2016 10:32:15 -0400 Date: Thu, 27 Oct 2016 12:32:12 -0200 From: Eduardo Habkost Message-ID: <20161027143212.GJ5057@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 , Peter Crosthwaite , Richard Henderson 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 Reviewed-by: Eduardo Habkost > --- > 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