From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8doW-000168-U9 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 21:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8doT-0007xs-No for qemu-devel@nongnu.org; Thu, 02 Jun 2016 21:22:16 -0400 Received: from [59.151.112.132] (port=18124 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8doT-0007xe-1F for qemu-devel@nongnu.org; Thu, 02 Jun 2016 21:22:13 -0400 Message-ID: <5750DCB5.7060600@cn.fujitsu.com> Date: Fri, 3 Jun 2016 09:26:13 +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> In-Reply-To: <20160602151418.GJ1184@perard.uk.xensource.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: Anthony PERARD Cc: qemu devel , Stefano Stabellini , Juan Quintela , Amit Shah , Eric Blake , Markus Armbruster , "Dr. David Alan Gilbert" , Wen Congyang , zhanghailiang On 06/02/2016 11:14 PM, Anthony PERARD wrote: > On Thu, Jun 02, 2016 at 06:36:46PM +0800, Changlong Xie wrote: >> +void qmp_xen_load_devices_state(const char *filename, Error **errp) >> +{ >> + QEMUFile *f; >> + QIOChannelFile *ioc; >> + int ret; >> + >> + /* Guest must be paused before loading the device state; the RAM state >> + * will already have been loaded by xc >> + */ >> + if (runstate_is_running()) { >> + error_setg(errp, "Cannot update device state while vm is running"); >> + return; >> + } >> + vm_stop(RUN_STATE_RESTORE_VM); >> + >> + 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. Thanks -Xie >> + if (!ioc) { >> + return; >> + } >> + f = qemu_fopen_channel_output(QIO_CHANNEL(ioc)); > > I'm not sure, but I guess here you want qemu_fopen_channel_input here. > > Thanks, >