Re: [RFC 1/9] notifier: add validity check and notify function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux