qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> g


From: Amit Shah
Subject: Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication
Date: Thu, 11 Jun 2009 10:01:30 +0530
User-agent: Mutt/1.5.18 (2008-05-17)

On (Wed) Jun 10 2009 [19:00:27], Jamie Lokier wrote:
> Amit Shah wrote:
> > > Plus, having a virtio serial device and a virtio console seems  
> > > unfortunate to me.  Anyway we can unify the two?  Maybe make virtio  
> > > serial support hvc with a feature flag or something instead of ttyS?
> > 
> > Yes, it's possible. I'll look into that once I reach a point where
> > virtio-serial is ready to be merged. I'll also have to look at making
> > sure existing guest kernels work with the new, unified device.
> 
> One of the most useful things about a serial port is that it's so easy
> for basic OS components like debuggers and bootloaders and BIOSes to
> use it, with very little code, and without having to do very complex
> things like initialise and enumerate PCI buses etc., and without
> interference by an OS so they are useful for things like kernel
> debugging and reliable debugging output.
> 
> For this reason, virtually every real machine has a simple serial
> port, even if it isn't exposed on an external connector.
> 
> Are virtio-serial/virtio-console very simple to drive from guest code,
> without PCI enumeration, or do they require complex initialisation and
> OS cooperation?

OK, great question. I'll post my Linux driver that'll answer your
question precisely, but this is what a guest userspace app will have to
do to use it:

        fd = open("/dev/vmser0", O_RDWR);
        if (fd == -1) {
                perror("open");
                return -errno;
        }

        ret = read(fd, buf, 100);
        if (ret < 0) {
                perror("read");
        }

        ret = ioctl(fd, VIRTIO_SERIAL_IOCTL_GET_PORT_NAME, &port_name);
        if (ret) perror("ioctl");
        printf("string is %s\n", port_name.name);

So the guest driver exposes a simple char device to userspace.

The driver itself hooks up with the virtio code which abstracts away all
the pci stuff. It just has to manage the rings and the queues.

                Amit




reply via email to

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