From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byvRg-0003DC-M0 for qemu-devel@nongnu.org; Tue, 25 Oct 2016 02:42:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byvRd-0007WJ-Iv for qemu-devel@nongnu.org; Tue, 25 Oct 2016 02:42:48 -0400 Received: from mga11.intel.com ([192.55.52.93]:37820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byvRd-0007Vf-9U for qemu-devel@nongnu.org; Tue, 25 Oct 2016 02:42:45 -0400 Date: Tue, 25 Oct 2016 14:42:41 +0800 From: Haozhong Zhang Message-ID: <20161025064241.wzajmjjdf44vfnwk@hz-desktop> References: <20161020061301.31372-1-haozhong.zhang@intel.com> <20161020143412.5ea6b564@nial.brq.redhat.com> <20161020135522.GC5211@noname.redhat.com> <20161024131047.GP5057@thinpad.lan.raisama.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20161024131047.GP5057@thinpad.lan.raisama.net> 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: Eduardo Habkost Cc: Kevin Wolf , Igor Mammedov , Xiao Guangrong , Peter Crosthwaite , qemu-devel@nongnu.org, mreitz@redhat.com, Paolo Bonzini , Richard Henderson On 10/24/16 11:10 -0200, Eduardo Habkost wrote: >On Thu, Oct 20, 2016 at 03:55:22PM +0200, Kevin Wolf wrote: >> Am 20.10.2016 um 14:34 hat Igor Mammedov geschrieben: >> > > #ifdef __linux__ >> > > +static uint64_t get_file_size(const char *path, Error **errp) >> > Maybe QEMU laredy has an utility to do it that could be shared, >> > CCing block maintainers. >> >> We have quite a bit of code for determining the right size of a file >> (including block devices) on different platforms and devices. See the >> .bdrv_getlength implementations in raw-posix.c and raw-win32.c. >> >> However, none of them are made for consumption outside the block layer. > >There's a patch on qemu-devel archives from 2015: > Subject [PATCH v7 11/35] util: introduce qemu_file_getlength() >it could be reused here. > My new version patches (https://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg05519.html) use the same approach to get the file size except that I didn't make it a common function. I'll move it to a common function in the next version. Thanks, Haozhong