From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2tQG-0003Hp-EB for qemu-devel@nongnu.org; Mon, 13 Jan 2014 21:08:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2tQB-0003Fi-V3 for qemu-devel@nongnu.org; Mon, 13 Jan 2014 21:08:08 -0500 Received: from [222.73.24.84] (port=15517 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2tQB-0003F9-JT for qemu-devel@nongnu.org; Mon, 13 Jan 2014 21:08:03 -0500 Message-ID: <52D49BD5.2070903@cn.fujitsu.com> Date: Tue, 14 Jan 2014 10:07:17 +0800 From: Qiao Nuohan MIME-Version: 1.0 References: <1388906864-1083-1-git-send-email-qiaonuohan@cn.fujitsu.com> <1388906864-1083-7-git-send-email-qiaonuohan@cn.fujitsu.com> <52CBE72E.9070805@redhat.com> <52D3B9F6.3070804@cn.fujitsu.com> <52D3C27A.8040403@redhat.com> In-Reply-To: <52D3C27A.8040403@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 06/11] dump: add API to write dump header List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: stefanha@gmail.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, anderson@redhat.com, kumagai-atsushi@mxc.nes.nec.co.jp, akong@redhat.com, afaerber@suse.de On 01/13/2014 06:39 PM, Laszlo Ersek wrote: >>> >> >>> >> - When this write=5Fbuffer() is directed to a regular file in non-f= lat >>> >> mode, then the file might become sparse (you jump over a range of >>> >> offsets with lseek() in write=5Fbuffer()). If the output has been o= pened >>> >> by qemu itself (ie."file:....", in qmp=5Fdump=5Fguest=5Fmemory()), = then due >>> >> to the O=5FTRUNC we can't seek over preexistent data (and keep garb= age in >>> >> the file). When libvirt pre-opens the file (to send over the fd lat= er), >>> >> in doCoreDump(), it also passes O=5FTRUNC. OK. >>> >> >> > >> > Do you mean because of O=5FTRUNC=EF=BC=8Cseek will exceed the end of = the file >> > that may cause some problem? > I meant that lseek() would seek over an unwritten portion of the file. > If that portion had any kind of data written into it earlier, then that > data would now likely turn into garbage (lose meaning, become truncated > etc.) It wouldn't be corrupted or anything like that, it would just > become a leftover with potential to cause misinterpretation. > > But, since we have O=5FTRUNC at open() time, we're seeking past the end of > the file, and this sought-over portion will read back as zeroes (and the > file might become "sparse", dependent on the filesystem and the size of > the range sought-over). > > Seeking past the end of the file is explicitly allowed by POSIX: > > The lseek() function shall allow the file offset to be set beyond > the end of the existing data in the file. If data is later written > at this point, subsequent reads of data in the gap shall return > bytes with the value 0 until data is actually written into the gap. > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html > > So this is fine. Thanks for your explanation. I think it would be better to abandon the non-= flat mode to avoid potential risk. --=20 Regards Qiao Nuohan =