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.