From patchwork Tue Jan 25 13:58:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 80361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6BEECB713C for ; Wed, 26 Jan 2011 01:02:17 +1100 (EST) Received: from localhost ([127.0.0.1]:33600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhjTJ-0004Qf-BR for incoming@patchwork.ozlabs.org; Tue, 25 Jan 2011 09:02:13 -0500 Received: from [140.186.70.92] (port=47129 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhjPo-0003FN-V4 for qemu-devel@nongnu.org; Tue, 25 Jan 2011 08:58:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhjPn-00006m-S2 for qemu-devel@nongnu.org; Tue, 25 Jan 2011 08:58:37 -0500 Received: from mtagate5.uk.ibm.com ([194.196.100.165]:40816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhjPn-0008Vs-Ky for qemu-devel@nongnu.org; Tue, 25 Jan 2011 08:58:35 -0500 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate5.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p0PDwOBF003054 for ; Tue, 25 Jan 2011 13:58:24 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p0PDwP2x1552568 for ; Tue, 25 Jan 2011 13:58:27 GMT Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p0PDwMOS025288 for ; Tue, 25 Jan 2011 06:58:22 -0700 Received: from stefanha-thinkpad.manchester-maybrook.uk.ibm.com (dyn-9-174-219-24.manchester-maybrook.uk.ibm.com [9.174.219.24]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p0PDwLQw025278; Tue, 25 Jan 2011 06:58:22 -0700 From: Stefan Hajnoczi To: Date: Tue, 25 Jan 2011 13:58:08 +0000 Message-Id: <1295963888-17275-1-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.2.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Kevin Wolf , Stefan Hajnoczi , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] virtio-pci: Disable virtio-ioeventfd when !CONFIG_IOTHREAD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It is not possible to use virtio-ioeventfd when building without an I/O thread. We rely on a signal to kick us out of vcpu execution. Timers and AIO use SIGALRM and SIGUSR2 respectively. Unfortunately eventfd does not support O_ASYNC (SIGIO) so eventfd cannot be used in a signal driven manner. Signed-off-by: Stefan Hajnoczi --- hw/virtio-pci.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index d07ff97..e921eda 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -640,6 +640,25 @@ static int virtio_pci_set_host_notifier(void *opaque, int n, bool assign) return virtio_pci_set_host_notifier_internal(proxy, n, assign); } +static bool virtio_pci_can_use_ioeventfd(void) +{ + if (!kvm_has_many_ioeventfds()) { + return false; + } + + /* Use ioeventfd for virtqueue kick only if we have an I/O thread to + * perform out-of-line processing. Otherwise we might as well do + * synchronous virtqueue kicks and in fact we have to since eventfd does + * not support SIGIO. Without the I/O thread a signal would be required to + * kick the vcpu out of guest code. + */ +#ifdef CONFIG_IOTHREAD + return true; +#else + return false; +#endif +} + static void virtio_pci_vmstate_change(void *opaque, bool running) { VirtIOPCIProxy *proxy = opaque; @@ -705,7 +724,7 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, pci_register_bar(&proxy->pci_dev, 0, size, PCI_BASE_ADDRESS_SPACE_IO, virtio_map); - if (!kvm_has_many_ioeventfds()) { + if (!virtio_pci_can_use_ioeventfd()) { proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; }