From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxDNL-0000p7-LL for qemu-devel@nongnu.org; Thu, 20 Oct 2016 09:27:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxDNH-0006PP-M9 for qemu-devel@nongnu.org; Thu, 20 Oct 2016 09:27:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46794) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxDNH-0006PL-HG for qemu-devel@nongnu.org; Thu, 20 Oct 2016 09:27:11 -0400 Date: Thu, 20 Oct 2016 14:27:06 +0100 From: "Daniel P. Berrange" Message-ID: <20161020132706.GR12145@redhat.com> Reply-To: "Daniel P. Berrange" References: <20161020061301.31372-1-haozhong.zhang@intel.com> <20161020143412.5ea6b564@nial.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20161020143412.5ea6b564@nial.brq.redhat.com> Subject: Re: [Qemu-devel] [PATCH] hostmem-file: add a property 'notrunc' to avoid data corruption List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: Haozhong Zhang , kwolf@redhat.com, Xiao Guangrong , Eduardo Habkost , Peter Crosthwaite , qemu-devel@nongnu.org, mreitz@redhat.com, Paolo Bonzini , Richard Henderson On Thu, Oct 20, 2016 at 02:34:12PM +0200, Igor Mammedov wrote: > On Thu, 20 Oct 2016 14:13:01 +0800 > Haozhong Zhang wrote: > > > If a file is used as the backend of memory-backend-file and its size is > > not identical to the property 'size', the file will be truncated. For a > > file used as the backend of vNVDIMM, its data is expected to be > > persistent and the truncation may corrupt the existing data. > I wonder if it's possible just skip 'size' property in your case instead > 'notrunc' property. That way if size is not present one'd get actual size > using get_file_size() and set 'size' to it? > And if 'size' is provided and 'size' != file_size then error out. That works if you always want to expose the entire file, but if you intentionally only want to expose a subset you would still want to set a size (and possibly offset too) and avoid the truncation Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|