From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Diq-0005ZW-9s for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1Dim-0003pF-JO for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:38:00 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:36122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1Dim-0003or-D3 for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:37:56 -0400 Received: by mail-wm0-x241.google.com with SMTP id c17so18713525wmc.3 for ; Mon, 31 Oct 2016 07:37:56 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 31 Oct 2016 15:37:23 +0100 Message-Id: <1477924663-30950-8-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> References: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 07/27] 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 cc11b6b..3723431 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.7.4