From patchwork Mon Jan 11 17:17:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 42638 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 C617FB6F08 for ; Tue, 12 Jan 2010 04:36:55 +1100 (EST) Received: from localhost ([127.0.0.1]:55882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUO65-0006tn-8p for incoming@patchwork.ozlabs.org; Mon, 11 Jan 2010 12:30:33 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NUNwe-000171-Qr for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NUNwa-00010b-Qr for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:48 -0500 Received: from [199.232.76.173] (port=58034 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUNwa-00010W-NJ for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:10677) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NUNwa-00087P-6b for qemu-devel@nongnu.org; Mon, 11 Jan 2010 12:20:44 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0BHKCQ0004266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 11 Jan 2010 12:20:27 -0500 Received: from redhat.com (vpn2-11-60.ams2.redhat.com [10.36.11.60]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o0BHKAF9025296; Mon, 11 Jan 2010 12:20:11 -0500 Date: Mon, 11 Jan 2010 19:17:17 +0200 From: "Michael S. Tsirkin" To: Anthony Liguori , qemu-devel@nongnu.org Message-ID: <20100111171717.GE11936@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH-RFC 04/13] virtio-pci: fill in irqfd/queufd support 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 Support irqfd/queuefd. The last one only with kvm, that's okay because vhost relies on kvm anyway. Signed-off-by: Michael S. Tsirkin --- hw/virtio-pci.c | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 6d0f9dd..5a3be6b 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -23,6 +23,7 @@ #include "msix.h" #include "net.h" #include "loader.h" +#include "kvm.h" /* from Linux's linux/virtio_pci.h */ @@ -388,6 +389,29 @@ static unsigned virtio_pci_get_features(void *opaque) return proxy->host_features; } +static void virtio_pci_irqfd_read(void *opaque) +{ + VirtQueue *vq = opaque; + virtio_irq(vq->vdev, vq); +} + +static int virtio_pci_irqfd(void * opaque, int n, int fd, bool assign) +{ + VirtIOPCIProxy *proxy = opaque; + VirtQueue *vq = &proxy->vdev->vq[n]; + + qemu_set_fd_handler(fd, assign ? virtio_pci_irqfd_read : NULL, NULL, vq); + return 0; +} + +static int virtio_pci_queuefd(void * opaque, int n, int fd, bool assign) +{ + VirtIOPCIProxy *proxy = opaque; + return kvm_set_ioeventfd(proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY, + n, fd, assign); +} + + static const VirtIOBindings virtio_pci_bindings = { .notify = virtio_pci_notify, .save_config = virtio_pci_save_config, @@ -395,6 +419,8 @@ static const VirtIOBindings virtio_pci_bindings = { .save_queue = virtio_pci_save_queue, .load_queue = virtio_pci_load_queue, .get_features = virtio_pci_get_features, + .set_irqfd = virtio_pci_irqfd, + .set_queuefd = virtio_pci_queuefd, }; static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,