From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8fP0-0002Xt-8o for qemu-devel@nongnu.org; Thu, 02 Jun 2016 23:04:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8fOx-0005zd-26 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 23:04:02 -0400 Received: from [59.151.112.132] (port=28695 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8fOw-0005xy-AH for qemu-devel@nongnu.org; Thu, 02 Jun 2016 23:03:58 -0400 Message-ID: <5750F48D.90509@cn.fujitsu.com> Date: Fri, 3 Jun 2016 11:07:57 +0800 From: Changlong Xie MIME-Version: 1.0 References: <1464863806-1984-1-git-send-email-xiecl.fnst@cn.fujitsu.com> <1464863806-1984-2-git-send-email-xiecl.fnst@cn.fujitsu.com> <20160602151418.GJ1184@perard.uk.xensource.com> <5750DCB5.7060600@cn.fujitsu.com> <5750E143.6020904@redhat.com> <5750E7AC.7040207@cn.fujitsu.com> In-Reply-To: <5750E7AC.7040207@cn.fujitsu.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 1/1] Introduce "xen-load-devices-state" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , Anthony PERARD Cc: Stefano Stabellini , zhanghailiang , Juan Quintela , Markus Armbruster , qemu devel , Amit Shah , "Dr. David Alan Gilbert" On 06/03/2016 10:13 AM, Changlong Xie wrote: > On 06/03/2016 09:45 AM, Eric Blake wrote: >> On 06/02/2016 07:26 PM, Changlong Xie wrote: >> >>>>> + >>>>> + ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, >>>>> 0660, errp); >>>> >>>> This does not look right, it looks like it's going to open the file >>>> to write to it. You probably want O_RDONLY, also I don't think the >>>> O_CREAT flag is needed. (and without O_WRONLY, mode can be 0 instead of >>>> 0660.) >>>> >>> >>> Yes, as you said. We should use 0_RDONLY for open(2), so mode should >>> be 0. >> >> Huh? mode doesn't affect the current fd, but DOES affect the next >> person to open the file. If you are truly creating the file, then a >> mode of 0 means you won't be able to reopen it without chmod. And if >> you are doing O_RDONLY | O_CREAT, all you will be able to create is an >> empty file, which is a pretty boring read. So drop the O_CREAT, and >> then you don't need a mode argument at all. >> > > Yes, i just mean qio_channel_file_new_path(filename, O_RDONLY, 0, errp) I just notice that, qemu specifies flag 'O_BINARY' to allow system to differentiate between a text file and a binary file( I guess so?). For backward compatibility, refer to function test_io_channel_file(), i will use qio_channel_file_new_path(filename, O_RDONLY | O_BINARY, 0, errp) here. > here. Maybe my poor english make you confused :( > > Thanks > -Xie > > > >