qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 6/7] qemu: Implement virtio-pstore device


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 6/7] qemu: Implement virtio-pstore device
Date: Thu, 28 Jul 2016 13:56:07 +0100
User-agent: Mutt/1.6.2 (2016-07-01)

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.

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]