From patchwork Wed May 26 14:09:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 53632 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 0D1C0B6EEB for ; Thu, 27 May 2010 01:14:58 +1000 (EST) Received: from localhost ([127.0.0.1]:42822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHIJq-0002lV-JJ for incoming@patchwork.ozlabs.org; Wed, 26 May 2010 11:14:54 -0400 Received: from [140.186.70.92] (port=45304 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHHN8-0003KG-G4 for qemu-devel@nongnu.org; Wed, 26 May 2010 10:14:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHHIx-00046v-QT for qemu-devel@nongnu.org; Wed, 26 May 2010 10:09:59 -0400 Received: from mail-wy0-f173.google.com ([74.125.82.173]:38260) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHHIx-00046k-L8 for qemu-devel@nongnu.org; Wed, 26 May 2010 10:09:55 -0400 Received: by wyf28 with SMTP id 28so1007524wyf.4 for ; Wed, 26 May 2010 07:09:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=QVdEKEkPC1P7KDI7YD7A45XAZH5Vhe1VaGmfW1goHCk=; b=xy+je8mNXkU5kFA+N542hV2xBeWl3q1joNshugvXHqTPP8u1663+s54Um3tMSSEile 8Zapbk20m2YusiLPpJTQE1r+cwmDf4YJ7hUxU2Juky4tTb3RGafm5VeXM7VBRs+hobI5 7ZSkXd4NwALzjtIAQDUIQmpPahwuU4P4Rw+TU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; b=VXaHCO9aV3BMLzvAGY/kSuybrjNybhyiEt544Cepqnn0dOgeDC2mo53KCDXJU5afhf zzfjzBedpD7UqTHIWYeVarBhcE73d64Nqu8DZK8eqFHSP07LXU2079fmpvQKpR1dWn4W 8gzsK6M1QqW7mXdR+rqL53jBqHmj8VJo5K/vI= Received: by 10.227.136.16 with SMTP id p16mr8551615wbt.151.1274882992540; Wed, 26 May 2010 07:09:52 -0700 (PDT) Received: from localhost.localdomain (nat-pool-brq-t.redhat.com [209.132.186.34]) by mx.google.com with ESMTPS id u32sm318964wbc.11.2010.05.26.07.09.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 26 May 2010 07:09:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 26 May 2010 16:09:34 +0200 Message-Id: <1274882978-9875-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1274882978-9875-1-git-send-email-pbonzini@redhat.com> References: <1274882978-9875-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 4/8] add and use virtqueue_from_guest_notifier 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 This changes the opaque pointer passed to the handler, from being the virtqueue to being the eventnotifier. It is useful as soon as the eventnotifier will be able to set its own (type-safe) handler. Signed-off-by: Paolo Bonzini --- I don't have a vhost-enabled machine yet. So only compile-tested for now, but pretty trivial. hw/virtio-pci.c | 6 +++--- hw/virtio.c | 5 +++++ hw/virtio.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 7ddf612..988c75c 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -421,8 +421,8 @@ static unsigned virtio_pci_get_features(void *opaque) static void virtio_pci_guest_notifier_read(void *opaque) { - VirtQueue *vq = opaque; - EventNotifier *n = virtio_queue_get_guest_notifier(vq); + EventNotifier *n = opaque; + VirtQueue *vq = virtqueue_from_guest_notifier(n); if (event_notifier_test_and_clear(n)) { virtio_irq(vq); } @@ -440,7 +440,7 @@ static int virtio_pci_set_guest_notifier(void *opaque, int n, bool assign) return r; } qemu_set_fd_handler(event_notifier_get_fd(notifier), - virtio_pci_guest_notifier_read, NULL, vq); + virtio_pci_guest_notifier_read, NULL, notifier); } else { qemu_set_fd_handler(event_notifier_get_fd(notifier), NULL, NULL, NULL); diff --git a/hw/virtio.c b/hw/virtio.c index 4475bb3..bfce44b 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -805,6 +805,11 @@ VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n) return vdev->vq + n; } +VirtQueue *virtqueue_from_guest_notifier(EventNotifier *e) +{ + return container_of(e, VirtQueue, guest_notifier); +} + EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq) { return &vq->guest_notifier; diff --git a/hw/virtio.h b/hw/virtio.h index e4306cd..d6a5b00 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -210,6 +210,7 @@ target_phys_addr_t virtio_queue_get_ring_size(VirtIODevice *vdev, int n); uint16_t virtio_queue_get_last_avail_idx(VirtIODevice *vdev, int n); void virtio_queue_set_last_avail_idx(VirtIODevice *vdev, int n, uint16_t idx); VirtQueue *virtio_get_queue(VirtIODevice *vdev, int n); +VirtQueue *virtqueue_from_guest_notifier(EventNotifier *vq); EventNotifier *virtio_queue_get_guest_notifier(VirtQueue *vq); EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq); void virtio_irq(VirtQueue *vq);