Page MenuHomeFreeBSD

bhyve(8): allow mevent to filter EVFILT_VNODE kevents
Needs ReviewPublic

Authored by rew on Jan 19 2021, 8:24 PM.

Details

Reviewers
grehan
jhb
allanjude
Group Reviewers
bhyve
Summary

An example use-case for this would be to monitor events on a
file-backed disk image that is being used through virtio-blk.

  • Add me_fflags member to struct mevent
  • Modify mevent_kq_fflags() to return me_fflags.
  • Modify mevent_add_state() to accept an additional argument, fflags

mevent_add() doesn't handle setting filter specific flags. I added
mevent_create() that allows the caller to specify flags and
fflags. The expected values for flags and fflags are those described in kqueue(2).

Example usage of mevent_create():

mevent_create(fd, EVF_VNODE, EV_ADD | EV_CLEAR, NOTE_ATTRIB, handler, handler_arg);

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 36397
Build 33286: arc lint + arc unit

Event Timeline

rew requested review of this revision.Jan 19 2021, 8:24 PM
chuck added inline comments.
usr.sbin/bhyve/mevent.c
303

minor style(9) nit - Insert an empty line if the function has no local variables

usr.sbin/bhyve/mevent.c
303

This is now optional in style(9).

usr.sbin/bhyve/mevent.c
303

.. though, having a blank line matches the existing style in this file.

Looks fine.

mevent only exists because libevent wasn't available in-tree at the time. It may be worth investigating that and ditching mevent entirely.

This revision is now accepted and ready to land.Jan 19 2021, 10:31 PM

fix formatting to be consistent with rest of file.

This revision now requires review to proceed.Jan 21 2021, 7:55 PM
rew marked an inline comment as done.Jan 21 2021, 8:44 PM

Looks fine.

mevent only exists because libevent wasn't available in-tree at the time. It may be worth investigating that and ditching mevent entirely.

At first glance, it doesn't look like libevent can detect file changes - I'll look into it though.