From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFLb4-0001Tb-BC for qemu-devel@nongnu.org; Mon, 17 Feb 2014 05:38:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFLax-0002uW-NM for qemu-devel@nongnu.org; Mon, 17 Feb 2014 05:38:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFLax-0002uR-DE for qemu-devel@nongnu.org; Mon, 17 Feb 2014 05:38:39 -0500 Message-ID: <5301E6AA.7000809@redhat.com> Date: Mon, 17 Feb 2014 11:38:34 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <52FE3D0E.8070904@redhat.com> <52FE44DB.8030408@suse.de> <52FE4820.8050009@redhat.com> <5301D40F.2010506@redhat.com> <5301DC83.6030307@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Fwd: Trying to write a new device / virtio-i2c ? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex David , qemu-devel 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.