From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxYR0-00045q-Ua for qemu-devel@nongnu.org; Fri, 21 Oct 2016 07:56:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxYQw-00011M-W4 for qemu-devel@nongnu.org; Fri, 21 Oct 2016 07:56:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxYQw-00010P-RW for qemu-devel@nongnu.org; Fri, 21 Oct 2016 07:56:22 -0400 Date: Fri, 21 Oct 2016 09:56:20 -0200 From: Eduardo Habkost Message-ID: <20161021115620.GN5057@thinpad.lan.raisama.net> References: <20161020061301.31372-1-haozhong.zhang@intel.com> <20161020143412.5ea6b564@nial.brq.redhat.com> <20161020131138.4gzxk5ekltkiqtq2@hz-desktop> <20161020154215.4b765284@nial.brq.redhat.com> <20161020135610.GY5057@thinpad.lan.raisama.net> <20161020161521.6e20ce2a@nial.brq.redhat.com> <20161020144734.GA5057@thinpad.lan.raisama.net> <20161020173538.1ee9a556@nial.brq.redhat.com> <20161021072210.sxfwixky4idlmzni@hz-desktop> <20161021130700.7beff8d3@nial.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161021130700.7beff8d3@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 , Peter Crosthwaite , qemu-devel@nongnu.org, mreitz@redhat.com, Paolo Bonzini , Richard Henderson On Fri, Oct 21, 2016 at 01:07:00PM +0200, Igor Mammedov wrote: [...] > How about following behavior: > > 1) memory-backend-file,mem-path=/some_dir,size=2G > - uses truncate to extend temporary file created in "mem-path" to 'size' > for this case to work 'size' is mandatory > > 2) memory-backend-file,mem-path=/existing_file,size=2G > - uses truncate to extend/shrink file "mem-path" to 'size' > for this case 'size' could be made optional, > if we take in account that backend could be used as persistent > storage then shrinking or extending "mem-path" would be corruption > as backend has no idea about internal layout if mapped file. > We can do something like this here: > > if (is_size_opt_provided and size_of(mem-path) != 0) { > error_out with "mem-path=foo size XXX doesn't match 'size=xxx' option" > } else if (is_size_opt_provided and size_of(mem-path) == 0) { > // may be we don't need this case and > // just fold this in above error case > truncate(mem-path) // extend/shrink > } else { > set_size_opt(size_of(mem-path)) > } Agreed. -- Eduardo