From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1bwk-0001NP-Rc for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1bwj-0006U0-Vg for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35470) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1bwj-0006Tv-Pi for qemu-devel@nongnu.org; Tue, 01 Nov 2016 12:29:57 -0400 From: Paolo Bonzini Date: Tue, 1 Nov 2016 17:29:20 +0100 Message-Id: <1478017783-7703-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> References: <1478017783-7703-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 07/30] exec.c: check memory backend file size with 'size' option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Haozhong Zhang From: Haozhong Zhang 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 Message-Id: <20161027042300.5929-3-haozhong.zhang@intel.com> Signed-off-by: Paolo Bonzini --- exec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/exec.c b/exec.c index f471e73..a3f9d8b 100644 --- a/exec.c +++ b/exec.c @@ -1321,6 +1321,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.7.4