kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* registering ioeventfd in qemu/kvm
@ 2012-08-23  3:35 Shesha Sreenivasamurthy
  2012-08-27  8:51 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Shesha Sreenivasamurthy @ 2012-08-23  3:35 UTC (permalink / raw)
  To: kvm

Hi,
I am trying to generate eventfd upon a IO write from the guest, say it
is at offset IO_NOTIFY_REG (0x10). When the guest writes to this
register, I get control to QEMU's to the write function associated in
mypci_iomem_ops. However, instead of this I would like to register an
eventfd.

To achieve that, first I tried:
       memory_region_add_eventfd(&mypci->bar_iomem, IO_NOTIFY_REG, 4,
true, 1, fd);

When this failed to generate events, I tried:

 int rc = kvm_set_ioeventfd_mmio(fd, IO_NOTIFY_REG, 1, 1, 4);

The RC value is 0, however event is not generated.

In the write function associated in mypci_iomem_ops, if I do a manual
write(fd, &val, (sizeof(uint64_t)); an event gets generated.

I have created a PCI device with iomem configured as follows:

        /* region for IOMEM */
        memory_region_init_io(&mypci->bar_iomem, &mypci_iomem_ops, mypci,
            "mypci-iomem", IOMEM_SIZE);

        pci_register_bar(&mypci->pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO,
            &mypci->bar_iomem);

What am I missing?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: registering ioeventfd in qemu/kvm
  2012-08-23  3:35 registering ioeventfd in qemu/kvm Shesha Sreenivasamurthy
@ 2012-08-27  8:51 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2012-08-27  8:51 UTC (permalink / raw)
  To: Shesha Sreenivasamurthy; +Cc: kvm

Il 23/08/2012 05:35, Shesha Sreenivasamurthy ha scritto:
> Hi,
> I am trying to generate eventfd upon a IO write from the guest, say it
> is at offset IO_NOTIFY_REG (0x10). When the guest writes to this
> register, I get control to QEMU's to the write function associated in
> mypci_iomem_ops. However, instead of this I would like to register an
> eventfd.
> 
> To achieve that, first I tried:
>        memory_region_add_eventfd(&mypci->bar_iomem, IO_NOTIFY_REG, 4,
> true, 1, fd);

This is the right way.  You can look (in the git tree of QEMU) at
hw/ivshmem.c, which is the simplest user of the eventfd API.

Note that recently the API was changed to accept an EventNotifier rather
than the raw eventfd.

Paolo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-27  8:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-23  3:35 registering ioeventfd in qemu/kvm Shesha Sreenivasamurthy
2012-08-27  8:51 ` Paolo Bonzini

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).