From: "Daniel P. Berrange" <berrange@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>,
Kees Cook <keescook@chromium.org>,
kvm@vger.kernel.org, Radim Kr??m???? <rkrcmar@redhat.com>,
Anton Vorontsov <anton@enomsg.org>,
LKML <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
qemu-devel@nongnu.org, Minchan Kim <minchan@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Anthony Liguori <aliguori@amazon.com>,
Colin Cross <ccross@android.com>,
Paolo Bonzini <pbonzini@redhat.com>,
virtualization@lists.linux-foundation.org,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [Qemu-devel] [PATCH 6/7] qemu: Implement virtio-pstore device
Date: Mon, 1 Aug 2016 10:21:30 +0100 [thread overview]
Message-ID: <20160801092130.GE6455@redhat.com> (raw)
In-Reply-To: <20160730083827.GA26275@danjae.aot.lge.com>
On Sat, Jul 30, 2016 at 05:38:27PM +0900, Namhyung Kim wrote:
> Hello,
>
> On Thu, Jul 28, 2016 at 02:08:41PM +0100, Daniel P. Berrange wrote:
> > 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...
>
> Yep, I don't know how I can use the QIOChannelFile for async IO.
> AFAICS it's just a wrapper for normal readv/writev. Who is
> responsible to do these IO when I use the IO channel API? Also does
> it guarantee that all IOs are processed in order?
I'd suggest just using QIOChannelFile regardless - we need to fix the
blocking behaviour already for sake of the qemu chardev code, and your
code just adds more pressure to fix it. I/O will be done in the order
in which you make the calls, as with regular POSIX I/O funcs you're
currently using.
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 :|
WARNING: multiple messages have this Message-ID (diff)
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
Tony Luck <tony.luck@intel.com>,
Kees Cook <keescook@chromium.org>,
kvm@vger.kernel.org, Radim Kr??m???? <rkrcmar@redhat.com>,
Anton Vorontsov <anton@enomsg.org>,
LKML <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
qemu-devel@nongnu.org, Minchan Kim <minchan@kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Anthony Liguori <aliguori@amazon.com>,
Colin Cross <ccross@android.com>,
Paolo Bonzini <pbonzini@redhat.com>,
virtualization@lists.linux-foundation.org,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [Qemu-devel] [PATCH 6/7] qemu: Implement virtio-pstore device
Date: Mon, 1 Aug 2016 10:21:30 +0100 [thread overview]
Message-ID: <20160801092130.GE6455@redhat.com> (raw)
In-Reply-To: <20160730083827.GA26275@danjae.aot.lge.com>
On Sat, Jul 30, 2016 at 05:38:27PM +0900, Namhyung Kim wrote:
> Hello,
>
> On Thu, Jul 28, 2016 at 02:08:41PM +0100, Daniel P. Berrange wrote:
> > 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...
>
> Yep, I don't know how I can use the QIOChannelFile for async IO.
> AFAICS it's just a wrapper for normal readv/writev. Who is
> responsible to do these IO when I use the IO channel API? Also does
> it guarantee that all IOs are processed in order?
I'd suggest just using QIOChannelFile regardless - we need to fix the
blocking behaviour already for sake of the qemu chardev code, and your
code just adds more pressure to fix it. I/O will be done in the order
in which you make the calls, as with regular POSIX I/O funcs you're
currently using.
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 :|
next prev parent reply other threads:[~2016-08-01 9:21 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-27 15:08 [RFC/PATCHSET 0/7] virtio: Implement virtio pstore device (v2) Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-27 15:08 ` [PATCH 1/7] pstore: Split pstore fragile flags Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-27 15:08 ` Namhyung Kim
2016-07-27 15:08 ` [PATCH 2/7] pstore/ram: Set pstore flags dynamically Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-27 15:08 ` Namhyung Kim
2016-07-27 15:08 ` [PATCH 3/7] pstore: Manage buffer position for async write Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-27 15:08 ` Namhyung Kim
2016-07-27 15:08 ` [PATCH 4/7] virtio: Basic implementation of virtio pstore driver Namhyung Kim
2016-07-27 15:08 ` Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-27 15:08 ` [PATCH 5/7] virtio-pstore: Support PSTORE_TYPE_CONSOLE Namhyung Kim
2016-07-27 15:08 ` Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-27 15:08 ` [PATCH 6/7] qemu: Implement virtio-pstore device Namhyung Kim
2016-07-27 15:08 ` Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-28 0:02 ` Michael S. Tsirkin
2016-07-28 0:02 ` [Qemu-devel] " Michael S. Tsirkin
2016-07-28 0:02 ` Michael S. Tsirkin
2016-07-28 5:39 ` Namhyung Kim
2016-07-28 5:39 ` [Qemu-devel] " Namhyung Kim
2016-07-28 5:39 ` Namhyung Kim
2016-07-28 12:56 ` Stefan Hajnoczi
2016-07-28 12:56 ` Stefan Hajnoczi
2016-07-28 12:56 ` [Qemu-devel] " Stefan Hajnoczi
2016-07-28 13:08 ` Daniel P. Berrange
2016-07-28 13:08 ` Daniel P. Berrange
2016-07-30 8:38 ` Namhyung Kim
2016-07-30 8:38 ` Namhyung Kim
2016-08-01 9:21 ` Daniel P. Berrange [this message]
2016-08-01 9:21 ` Daniel P. Berrange
2016-08-01 15:34 ` Namhyung Kim
2016-08-01 15:34 ` Namhyung Kim
2016-07-28 14:38 ` Steven Rostedt
2016-07-28 14:38 ` Steven Rostedt
2016-07-28 14:38 ` [Qemu-devel] " Steven Rostedt
2016-07-28 13:22 ` Daniel P. Berrange
2016-07-28 13:22 ` Daniel P. Berrange
2016-07-30 8:57 ` Namhyung Kim
2016-07-30 8:57 ` Namhyung Kim
2016-08-01 9:24 ` Daniel P. Berrange
2016-08-01 9:24 ` Daniel P. Berrange
2016-08-01 15:52 ` Namhyung Kim
2016-08-01 15:52 ` Namhyung Kim
2016-07-27 15:08 ` [PATCH 7/7] kvmtool: " Namhyung Kim
2016-07-27 15:08 ` [Qemu-devel] " Namhyung Kim
2016-07-27 15:08 ` Namhyung Kim
2016-07-27 22:18 ` [RFC/PATCHSET 0/7] virtio: Implement virtio pstore device (v2) Michael S. Tsirkin
2016-07-27 22:18 ` [Qemu-devel] " Michael S. Tsirkin
2016-07-27 22:18 ` Michael S. Tsirkin
2016-07-28 2:46 ` Namhyung Kim
2016-07-28 2:46 ` [Qemu-devel] " Namhyung Kim
2016-07-28 2:46 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160801092130.GE6455@redhat.com \
--to=berrange@redhat.com \
--cc=aliguori@amazon.com \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=mingo@kernel.org \
--cc=mst@redhat.com \
--cc=namhyung@kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tony.luck@intel.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.