From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9ZS7-0006qu-IT for qemu-devel@nongnu.org; Mon, 19 Mar 2012 06:04:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9ZS1-0000J9-0N for qemu-devel@nongnu.org; Mon, 19 Mar 2012 06:04:35 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:34382) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9ZS0-0000Im-Nn for qemu-devel@nongnu.org; Mon, 19 Mar 2012 06:04:28 -0400 Received: by werp12 with SMTP id p12so6717405wer.4 for ; Mon, 19 Mar 2012 03:04:26 -0700 (PDT) Date: Mon, 19 Mar 2012 08:21:22 +0000 From: Stefan Hajnoczi Message-ID: <20120319082122.GA20995@stefanha-thinkpad.localdomain> References: <20120313103602.8741.71939.stgit@dhcp-8-167.nay.redhat.com> <4F606356.9080003@redhat.com> <4F606D84.8000807@redhat.com> <4F6076EE.9090005@redhat.com> <4F6300F7.6080806@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F6300F7.6080806@redhat.com> Subject: Re: [Qemu-devel] [PATCH 0/2] virtio-pci: fix abort when fail to allocate ioeventfd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, kvm@vger.kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, Avi Kivity On Fri, Mar 16, 2012 at 04:59:35PM +0800, Amos Kong wrote: > On 14/03/12 19:46, Stefan Hajnoczi wrote: > >On Wed, Mar 14, 2012 at 10:46 AM, Avi Kivity wrote: > >>On 03/14/2012 12:39 PM, Stefan Hajnoczi wrote: > >>>On Wed, Mar 14, 2012 at 10:05 AM, Avi Kivity wrote: > >>>>On 03/14/2012 11:59 AM, Stefan Hajnoczi wrote: > >>>>>On Wed, Mar 14, 2012 at 9:22 AM, Avi Kivity wrote: > >>>>>>On 03/13/2012 12:42 PM, Amos Kong wrote: > >>>>>>>Boot up guest with 232 virtio-blk disk, qemu will abort for fail to > >>>>>>>allocate ioeventfd. This patchset changes kvm_has_many_ioeventfds(), > >>>>>>>and check if available ioeventfd exists. If not, virtio-pci will > >>>>>>>fallback to userspace, and don't use ioeventfd for io notification. > >>>>>> > >>>>>>How about an alternative way of solving this, within the memory core: > >>>>>>trap those writes in qemu and write to the ioeventfd yourself. This way > >>>>>>ioeventfds work even without kvm: > >>>>>> > >>>>>> > >>>>>> core: create eventfd > >>>>>> core: install handler for memory address that writes to ioeventfd > >>>>>> kvm (optional): install kernel handler for ioeventfd > > Can you give some detail about this? I'm not familiar with Memory API. > > > btw, can we fix this problem by replacing abort() by a error note? > virtio-pci will auto fallback to userspace. > > diff --git a/kvm-all.c b/kvm-all.c > index 3c6b4f0..cf23dbf 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -749,7 +749,8 @@ static void > kvm_mem_ioeventfd_add(MemoryRegionSection *section, > r = kvm_set_ioeventfd_mmio_long(fd, > section->offset_within_address_space, > data, true); > if (r < 0) { > - abort(); > + fprintf(stderr, "%s: unable to map ioeventfd: %s.\nFallback to " > + "userspace (slower).\n", __func__, strerror(-r)); The challenge is propagating the error code. If virtio-pci.c doesn't know that ioeventfd has failed, then it's not possible to fall back to a userspace handler. I believe Avi's suggestion is to put the fallback code into the KVM memory API implementation so that virtio-pci.c doesn't need to know that ioeventfd failed at all. Stefan