From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bybSQ-0000tH-Q9 for qemu-devel@nongnu.org; Mon, 24 Oct 2016 05:22:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bybSN-0004pM-MO for qemu-devel@nongnu.org; Mon, 24 Oct 2016 05:22:14 -0400 Received: from mga09.intel.com ([134.134.136.24]:28229) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bybSN-0004oG-Db for qemu-devel@nongnu.org; Mon, 24 Oct 2016 05:22:11 -0400 From: Haozhong Zhang Date: Mon, 24 Oct 2016 17:21:49 +0800 Message-Id: <20161024092151.32386-1-haozhong.zhang@intel.com> Subject: [Qemu-devel] [PATCH 0/2] Improve truncation behavior of memory-backend-file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Eduardo Habkost , Igor Mammedov Cc: Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Xiao Guangrong , Haozhong Zhang The previous discussion thread can be found at http://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg04668.html For a mmeory backend file, e.g. -object memory-backend-file,mem-path=foo,size=SZ,... the size of the backend file 'foo' is specified by the 'size' option. If the specified size 'SZ' does not match the actual size of file 'foo', QEMU will truncate the backend file 'foo'. In certain usage scenarios (e.g. vNVDIMM), the truncation may corrupt the existing data in the file. Patch 1 in this series avoids such data corruption by disabling truncating non-empty backend files. If the backend file is not empty and the option 'size' does not match the actual file size, QEMU will error out. If the backend file is empty, QEMU will extend to the size specified by the option 'size'. Patch 2 makes the option 'size' optional. It's to avoid the misusing of 'size' option. If the user is uncertain about the backend file size, they can skip the 'size' option and let QEMU use the actual file size. For an empty file, the option 'size' must be specified. Haozhong Zhang (2): exec.c: do not truncate non-empty memory backend file hostmem-file: allow option 'size' optional backends/hostmem-file.c | 10 ++++++---- exec.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 5 deletions(-) -- 2.10.1