From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752786AbcHZM1n (ORCPT ); Fri, 26 Aug 2016 08:27:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44698 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbcHZM1l (ORCPT ); Fri, 26 Aug 2016 08:27:41 -0400 Date: Fri, 26 Aug 2016 08:27:23 -0400 From: "Daniel P. Berrange" To: Namhyung Kim Cc: virtio-dev@lists.oasis-open.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org, LKML , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , "Michael S. Tsirkin" , Anthony Liguori , Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck , Steven Rostedt , Ingo Molnar , Minchan Kim Subject: Re: [PATCH 2/3] qemu: Implement virtio-pstore device Message-ID: <20160826122723.GA12514@redhat.com> Reply-To: "Daniel P. Berrange" References: <20160820080744.10344-1-namhyung@kernel.org> <20160820080744.10344-3-namhyung@kernel.org> <20160824220051.GC18614@redhat.com> <20160826044840.GA8218@danjae.aot.lge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160826044840.GA8218@danjae.aot.lge.com> User-Agent: Mutt/1.6.2 (2016-07-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 26 Aug 2016 12:27:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 26, 2016 at 01:48:40PM +0900, Namhyung Kim wrote: > Hi Daniel, > > On Wed, Aug 24, 2016 at 06:00:51PM -0400, Daniel P. Berrange wrote: > > > + fd = open(filename, O_RDONLY); > > > + if (fd < 0) { > > > + error_report("cannot open %s", filename); > > > + goto out; > > > + } > > > + > > > + if (fstat(fd, &stbuf) < 0) { > > > + goto out; > > > + } > > > + > > > + rarg->vps = s; > > > + rarg->elem = elem; > > > + rarg->info.id = cpu_to_le64(rarg->info.id); > > > + rarg->info.type = cpu_to_le16(rarg->info.type); > > > + rarg->info.flags = cpu_to_le32(rarg->info.flags); > > > + rarg->info.time_sec = cpu_to_le64(stbuf.st_ctim.tv_sec); > > > + rarg->info.time_nsec = cpu_to_le32(stbuf.st_ctim.tv_nsec); > > > + > > > + rarg->ioc = qio_channel_new_fd(fd, &err); > > > > You should just use qio_channel_open_path() and avoid the earlier > > call to open() > > I did it because to call fstat() using the fd and wanted to keep the > generic ioc pointer. I'd suggest just using a cast inline, eg fstat(QIO_CHANNEL_FILE(ioc)->fd, &stbuf) Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|