From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:44730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StvTR-0003et-KD for qemu-devel@nongnu.org; Wed, 25 Jul 2012 02:53:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StvTQ-0002UI-KM for qemu-devel@nongnu.org; Wed, 25 Jul 2012 02:53:33 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:45089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StvTQ-0002U9-D1 for qemu-devel@nongnu.org; Wed, 25 Jul 2012 02:53:32 -0400 Received: by weyz53 with SMTP id z53so274144wey.4 for ; Tue, 24 Jul 2012 23:53:31 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <500F97E9.4070508@redhat.com> Date: Wed, 25 Jul 2012 08:53:29 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1343169246-17636-1-git-send-email-nab@linux-iscsi.org> <1343169246-17636-2-git-send-email-nab@linux-iscsi.org> In-Reply-To: <1343169246-17636-2-git-send-email-nab@linux-iscsi.org> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC 1/9] notifier: add validity check and notify function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Nicholas A. Bellinger" Cc: Jens Axboe , Anthony Liguori , Stefan Hajnoczi , kvm-devel , "Michael S. Tsirkin" , qemu-devel , Zhi Yong Wu , Anthony Liguori , target-devel , Hannes Reinecke , lf-virt , Christoph Hellwig Il 25/07/2012 00:33, Nicholas A. Bellinger ha scritto: > +int event_notifier_notify(EventNotifier *e) > +{ > + uint64_t value = 1; > + int r; > + > + assert(event_notifier_valid(e)); > + r = write(e->fd, &value, sizeof(value)); > + if (r < 0) { > + return -errno; > + } > + assert(r == sizeof(value)); > + return 0; > +} Note we now have event_notifier_set. > +#define EVENT_NOTIFIER_INITIALIZER ((EventNotifier){ .fd = -1 }) This is problematic when your event notifier is inside a struct, because it is extremely easy to forget the initializer. You have to initialize them yourself. Also, the right thing to test is not whether the notifier is initialized; it is whether the notifier is actually checked in QEMU's select() loop. So, I would prefer avoiding event_notifier_valid and just use a boolean (in virtio_queue_set_host_notifier_fd_handler and virtio_queue_set_guest_notifier_fd_handler) to track whether the notifiers are in use. Paolo