[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 1/9] notifier: add validity check and notify funct
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [RFC 1/9] notifier: add validity check and notify function |
Date: |
Wed, 25 Jul 2012 08:53:29 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 |
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
- [Qemu-devel] [RFC 0/9] vhost-scsi: Add support for host virtualized target, Nicholas A. Bellinger, 2012/07/24
- [Qemu-devel] [RFC 1/9] notifier: add validity check and notify function, Nicholas A. Bellinger, 2012/07/24
- Re: [Qemu-devel] [RFC 1/9] notifier: add validity check and notify function,
Paolo Bonzini <=
- [Qemu-devel] [RFC 2/9] virtio-pci: support host notifiers in TCG mode, Nicholas A. Bellinger, 2012/07/24
- [Qemu-devel] [RFC 3/9] virtio-pci: check that event notification worked, Nicholas A. Bellinger, 2012/07/24
- [Qemu-devel] [RFC 4/9] vhost: Pass device path to vhost_dev_init(), Nicholas A. Bellinger, 2012/07/24
- [Qemu-devel] [RFC 5/9] virtio-scsi: Add wwpn and tgpt properties, Nicholas A. Bellinger, 2012/07/24
- [Qemu-devel] [RFC 6/9] virtio-scsi: Open and initialize /dev/vhost-scsi, Nicholas A. Bellinger, 2012/07/24
- [Qemu-devel] [RFC 7/9] virtio-scsi: Start/stop vhost, Nicholas A. Bellinger, 2012/07/24