Re: [Qemu-devel] Help writing a trivial device

2011-09-27 Thread Lluís Vilanova
Zhi Yong Wu writes: > 2011/9/26 Lluís Vilanova : >> The testing system is a Linux 2.6.32, with this: >> >> int fd = open("/sys/devices/pci:00/00:00:004.00/resource0", O_RDWR); >> void *addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); >> printf("-> %ld\n", *(uint64_t*)ad

Re: [Qemu-devel] Help writing a trivial device

2011-09-27 Thread Lluís Vilanova
Stefan Hajnoczi writes: > On Mon, Sep 26, 2011 at 08:03:12PM +0200, Lluís Vilanova wrote: >> #if 1 /* KVM doesn't like it */ >> s-> data_ptr = g_malloc(s->size); >> memory_region_init_ram_ptr(&s->data, &s->dev.qdev, "backdoor.data", >>s

Re: [Qemu-devel] Help writing a trivial device

2011-09-27 Thread Stefan Hajnoczi
On Mon, Sep 26, 2011 at 08:03:12PM +0200, Lluís Vilanova wrote: > #if 1 /* KVM doesn't like it */ > s->data_ptr = g_malloc(s->size); > memory_region_init_ram_ptr(&s->data, &s->dev.qdev, "backdoor.data", >s->size, s->data_ptr)

Re: [Qemu-devel] Help writing a trivial device

2011-09-26 Thread Avi Kivity
On 09/26/2011 03:54 PM, Lluís Vilanova wrote: It is the second bar that generates the problems with KVM: s->data_ptr = g_malloc(s->size); memory_region_init_ram_ptr(&s->data,&s->dev.qdev, "backdoor.data", s->size, s->data_ptr); pci_register_bar(&s->

Re: [Qemu-devel] Help writing a trivial device

2011-09-26 Thread Zhi Yong Wu
2011/9/26 Lluís Vilanova : > Hi. I started writing a trivial device on QEMU that should get called on every > read and write on the memory it provides. > > The problems are that: > > 1) Cannot start QEMU with KVM when the device is enabled: >       kvm_set_phys_mem: error registering slot: Invalid

Re: [Qemu-devel] Help writing a trivial device

2011-09-26 Thread Zhi Yong Wu
2011/9/26 Lluís Vilanova : > Stefan Hajnoczi writes: > >> On Mon, Sep 26, 2011 at 12:23:21AM +0200, Lluís Vilanova wrote: >>> 1) Cannot start QEMU with KVM when the device is enabled: >>> kvm_set_phys_mem: error registering slot: Invalid argument >>> >>> 2) The driver never gets called on a read/wr

Re: [Qemu-devel] Help writing a trivial device

2011-09-26 Thread Lluís Vilanova
Lluís Vilanova writes: > Stefan Hajnoczi writes: >> On Mon, Sep 26, 2011 at 12:23:21AM +0200, Lluís Vilanova wrote: >>> 1) Cannot start QEMU with KVM when the device is enabled: >>> kvm_set_phys_mem: error registering slot: Invalid argument >>> >>> 2) The driver never gets called on a read/write

Re: [Qemu-devel] Help writing a trivial device

2011-09-26 Thread Lluís Vilanova
Stefan Hajnoczi writes: > On Mon, Sep 26, 2011 at 12:23:21AM +0200, Lluís Vilanova wrote: >> 1) Cannot start QEMU with KVM when the device is enabled: >> kvm_set_phys_mem: error registering slot: Invalid argument >> >> 2) The driver never gets called on a read/write to its memory > If I add #inc

Re: [Qemu-devel] Help writing a trivial device

2011-09-26 Thread Stefan Hajnoczi
On Mon, Sep 26, 2011 at 12:23:21AM +0200, Lluís Vilanova wrote: > 1) Cannot start QEMU with KVM when the device is enabled: >kvm_set_phys_mem: error registering slot: Invalid argument > > 2) The driver never gets called on a read/write to its memory If I add #include "pci.h" at the top of

[Qemu-devel] Help writing a trivial device

2011-09-25 Thread Lluís Vilanova
Hi. I started writing a trivial device on QEMU that should get called on every read and write on the memory it provides. The problems are that: 1) Cannot start QEMU with KVM when the device is enabled: kvm_set_phys_mem: error registering slot: Invalid argument 2) The driver never gets cal