qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Alex David <alex.daerf@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Trying to write a new device / virtio-i2c ?
Date: Fri, 14 Feb 2014 16:26:42 +0100	[thread overview]
Message-ID: <20140214152642.GS17391@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <CAA17Vo98dsydzB=c=rPnL0FJ=5FzKhUYYTzRwZjww6kCbS828Q@mail.gmail.com>

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	other threads:[~2014-02-14 15:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-13 13:26 [Qemu-devel] Trying to write a new device / virtio-i2c ? Alex David
2014-02-14 15:26 ` Stefan Hajnoczi [this message]
2014-02-14 15:58 ` Paolo Bonzini
2014-02-14 16:31   ` Andreas Färber
2014-02-14 16:45     ` Paolo Bonzini
2014-02-17  8:35       ` Alex David
2014-02-17  9:19         ` Paolo Bonzini
     [not found]           ` <CAA17Vo9E9D-jPa3gwhsui3i=APz1FM-41jbK+zpOm2tWf7swdw@mail.gmail.com>
2014-02-17  9:38             ` [Qemu-devel] Fwd: " Alex David
2014-02-17  9:55               ` Paolo Bonzini
     [not found]                 ` <CAA17Vo_cBCbKkqDu2zQ0DW2FoAyVqxVXGtNGArJ1tnk6N9AUqA@mail.gmail.com>
2014-02-17 10:38                   ` Paolo Bonzini
2014-02-17 12:23                     ` Alex David
2014-02-17 13:11                       ` Alex David
2014-02-17 13:19                         ` Paolo Bonzini
2014-02-17 13:32                           ` Alex David
2014-02-17 14:30                             ` Paolo Bonzini
2014-02-17 15:33                               ` Alex David
2014-02-17 16:11                                 ` Paolo Bonzini
2014-02-18 12:48                                   ` Alex David
2014-02-18 13:05                                     ` Paolo Bonzini
2014-02-18 13:44                                       ` Alex David
2014-02-18 13:47                                         ` Paolo Bonzini

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=20140214152642.GS17391@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=alex.daerf@gmail.com \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).