From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSl3V-0005cs-Gz for qemu-devel@nongnu.org; Thu, 28 Jul 2016 09:08:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSl3Q-0003pv-OE for qemu-devel@nongnu.org; Thu, 28 Jul 2016 09:08:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSl3Q-0003pr-GQ for qemu-devel@nongnu.org; Thu, 28 Jul 2016 09:08:48 -0400 Date: Thu, 28 Jul 2016 14:08:41 +0100 From: "Daniel P. Berrange" Message-ID: <20160728130841.GL22677@redhat.com> Reply-To: "Daniel P. Berrange" References: <1469632111-23260-1-git-send-email-namhyung@kernel.org> <1469632111-23260-7-git-send-email-namhyung@kernel.org> <20160728023254-mutt-send-email-mst@kernel.org> <20160728053953.GB4371@sejong> <20160728125607.GA31002@stefanha-x1.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160728125607.GA31002@stefanha-x1.localdomain> Subject: Re: [Qemu-devel] [PATCH 6/7] qemu: Implement virtio-pstore device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Namhyung Kim , Tony Luck , Kees Cook , kvm@vger.kernel.org, Radim =?utf-8?B?S3LEjW3DocWZ?= , Anton Vorontsov , LKML , Steven Rostedt , qemu-devel@nongnu.org, Minchan Kim , "Michael S. Tsirkin" , Anthony Liguori , Colin Cross , Paolo Bonzini , virtualization@lists.linux-foundation.org, Ingo Molnar On Thu, Jul 28, 2016 at 01:56:07PM +0100, Stefan Hajnoczi wrote: > On Thu, Jul 28, 2016 at 02:39:53PM +0900, Namhyung Kim wrote: > > On Thu, Jul 28, 2016 at 03:02:54AM +0300, Michael S. Tsirkin wrote: > > > On Thu, Jul 28, 2016 at 12:08:30AM +0900, Namhyung Kim wrote: > > > > +static ssize_t virtio_pstore_do_write(VirtIOPstore *s, struct iovec *out_sg, > > > > + unsigned int out_num, > > > > + struct virtio_pstore_req *req) > > > > +{ > > > > + char path[PATH_MAX]; > > > > + int fd; > > > > + ssize_t len; > > > > + unsigned short type; > > > > + int flags = O_WRONLY | O_CREAT; > > > > + > > > > + /* we already consume the req */ > > > > + iov_discard_front(&out_sg, &out_num, sizeof(*req)); > > > > + > > > > + virtio_pstore_to_filename(s, path, sizeof(path), req); > > > > + > > > > + type = le16_to_cpu(req->type); > > > > + > > > > + if (type == VIRTIO_PSTORE_TYPE_DMESG) { > > > > + flags |= O_TRUNC; > > > > + } else if (type == VIRTIO_PSTORE_TYPE_CONSOLE) { > > > > + flags |= O_APPEND; > > > > + } > > > > + > > > > + fd = open(path, flags, 0644); > > > > + if (fd < 0) { > > > > + error_report("cannot open %s", path); > > > > + return -1; > > > > + } > > > > + len = writev(fd, out_sg, out_num); > > > > + close(fd); > > > > + > > > > + return len; > > > > > > All this is blocking VM until host io completes. > > > > Hmm.. I don't know about the internals of qemu. So does it make guest > > stop? If so, that's what I want to do for _DMESG. :) As it's called > > only on kernel oops I think it's admittable. But for _CONSOLE, it > > needs to do asynchronously. Maybe I can add a thread to do the work. > > Please look at include/io/channel.h. QEMU is event-driven and tends to > use asynchronous I/O instead of spawning threads. The include/io/ APIs > allow you to do asynchronous I/O in the event loop. That is true, except for I/O to/from plain files - the QIOChannelFile impl doesn't do anything special (yet) to make that work correctly in non-blocking mode. Of course that could be fixed... 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 :|