qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Trying to write a new device / virtio-i2c ?


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] Trying to write a new device / virtio-i2c ?
Date: Fri, 14 Feb 2014 16:26:42 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Feb 13, 2014 at 02:26:16PM +0100, Alex David wrote:
> I'm new to QEMU and kinda new to driver & QEMU programming in general, so
> please excuse my questions...
> 
> I want to develop a new QEMU i2c device (qemu x86), that would get/send
> data to an application running on the guest. Thing is : I need these data
> onto the host, as a daemon will send/get the same kind of data to the guest.
> 
> After reading code, documentation and available things, I've been trying to
> write something like a "virtio-i2c" : I wrote a virtio-i2c module for my
> kernel (I used some examples from virtio-pci and virtio-console), it seems
> that it created a "i2c-1" device in /dev,
> 
> My device that I launch with QEMU (-chardev
> socket,path=/tmp/test0,server,nowait,id=bob -device virtio-i2c,chardev=bob)
> doesn't seem to be recognized by the kernel driver : my probe function
> doesn't run.
> 
> I might have missed something : how does a kernel driver uses the "probe"
> function with a QEMU device ?

Virtio devices have a device ID which the Linux guest virtio bus code
uses to probe the right driver.

For example:
$ grep virt /lib/modules/3.12.9-301.fc20.x86_64/modules.alias
alias virtio:d00000004v* virtio_rng
alias virtio:d00000003v* virtio_console
alias virtio:d00000002v* virtio_blk
alias virtio:d00000008v* virtio_scsi
alias virtio:d00000001v* virtio_net

This is how udev knows to load the right kernel modules.  If you
compiled and installed your kernel modules correctly then it should be
automatically loaded.

If you want to dig deeper into how Linux driver loading works, see
drivers/virtio/virtio.c:virtio_bus.

> Hoping that it doesn't look too confused...

I'm confused about what you're trying to achieve.  If you want
host<->guest communication then the starting point is virtio-serial.
Maybe even the QEMU Guest Agent which can use virtio-serial.

If you want "real" I2C you should probably not use virtio.

Stefan



reply via email to

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