From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFO6u-00052A-Tf for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:19:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFO6l-0000qy-V8 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:19:48 -0500 Received: from mail-qa0-x233.google.com ([2607:f8b0:400d:c00::233]:54576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFO6l-0000qt-Q8 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 08:19:39 -0500 Received: by mail-qa0-f51.google.com with SMTP id f11so21475351qae.24 for ; Mon, 17 Feb 2014 05:19:39 -0800 (PST) Sender: Paolo Bonzini Message-ID: <53020C67.5040603@redhat.com> Date: Mon, 17 Feb 2014 14:19:35 +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> <5301E6AA.7000809@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 Cc: qemu-devel Il 17/02/2014 14:11, Alex David ha scritto: > I've tried using tmp105. As my linux isn't 64bits, i'm using > qemu-system-i386... It crashes my computer when I use it with my linux > image (it's a debian .qcow2..., easy to do some tests...). You mean crashes your host? > I will most probably need a chardev anyways, I will need to read/write > data when I want to. Depends on how much data. If it's just one or two ints, like tmp105, QOM would work too. qmp-shell talks to QEMU via a simple JSON protocol, and it has simple Python bindings too. > static const TypeInfo mydevice_i2c_type_info = { > .name = TYPE_MYDEVICE_I2C, > .parent = TYPE_I2C_SLAVE, > .instance_size = sizeof(MYDEVICEI2CState), > .instance_init = MYDEVICE_i2c_init, > .class_init = mydevice_i2c_class_init, > }; > > I will be able to add a chardev using the properties, right ? Yes, using dc->props. > Does this seems ok for you ? So far, I understood the "props" are needed > for when I'm gonna declare the device at QEMU launch. > I am not sure if it's needed (my i2c-0 should be created anyways), but > in that case, how do I "plug" it on my socket on the host ? Your device is not i2c-0. i2c-0 is provided by the PC board. Your device will get one address, e.g. 0x42, on the i2c bus. You'll be able to access it with i2cget and i2cset using "0" as the bus address (for i2c-0) and 0x42 as the device address on bus 0. So you'll indeed have to do something like "-chardev socket,id=foo -device myi2c,address=0x42,chr=foo" if you go for sockets, or just "-device myi2c,address=0x42" if you go for QOM. The "chr" property should go into dc->props, while "address" is provided by the abstract class TYPE_I2C_SLAVE. Paolo