From: Paolo Bonzini <pbonzini@redhat.com>
To: Alex David <alex.daerf@gmail.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Fwd: Trying to write a new device / virtio-i2c ?
Date: Mon, 17 Feb 2014 11:38:34 +0100 [thread overview]
Message-ID: <5301E6AA.7000809@redhat.com> (raw)
In-Reply-To: <CAA17Vo_cBCbKkqDu2zQ0DW2FoAyVqxVXGtNGArJ1tnk6N9AUqA@mail.gmail.com>
Il 17/02/2014 11:01, Alex David ha scritto:
> I indeed don't use paravirtualization.
Virtio _is_ paravirtualization. :)
> I'm emulating a bunch of sensors/actuators.
>
> If I virtualize my sensors and attach them to the i2c-dev with -device,
> how do I get those data on the host then ?
It depends on your use case.
It could be that you can make them return a constant value.
Otherwise, you may want to use a chardev for that purpose, or finally a
QOM (QEMU Object Model) property. For example, add
CONFIG_TMP105=y
to default-configs/x86_64-softmmu.mak before building QEMU, then do the
following (indented = in the guest):
$ x86_64-softmmu/qemu-system-x86_64 --enable-kvm ~/test2.img -m 256 \
-device tmp105,id=sensor,address=0x50 \
-qmp unix:$HOME/qmp.sock,server,nowait
$ qmp/qom-list -s ~/qmp.sock /machine/peripheral/sensor
temperature
@parent_bus/
address
hotpluggable
realized
type
$ scripts/qmp/qmp-shell ~/qmp.sock
(QEMU) qom-get path=/machine/peripheral/sensor property=temperature
{u'return': 0}
(QEMU) qom-get path=sensor property=address
{u'return': 80}
# modprobe i2c-dev
# i2cget -y 0 0x50 0 w
0x0000
(QEMU) qom-set path=sensor property=temperature value=20000
{u'return': {}}
# i2cget -y 0 0x50 0 w
0x0014
For this particular sensor, you have to swap the two bytes and the
result is 8.8 fixed-point.
Paolo
> Thanks for your help. As you may see, I'm not that experienced in
> QEMU/Linux kernel.
next prev parent reply other threads:[~2014-02-17 10:38 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
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 [this message]
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=5301E6AA.7000809@redhat.com \
--to=pbonzini@redhat.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).