All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test-util-filemonitor: Adapt to FreeBSD 15's native inotify semantics
@ 2026-07-09 18:42 Jessica Clarke
  2026-07-10 11:05 ` Daniel P. Berrangé
  0 siblings, 1 reply; 2+ messages in thread
From: Jessica Clarke @ 2026-07-09 18:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jessica Clarke, Daniel P. Berrangé

FreeBSD 15 introduces a native inotify implementation rather than
requiring use of the kqueue-based libinotify package. This native
implementation does not generate the extra deleted events, so don't
expect them. However, the original implementation did have a bug that
caused IN_IGNORED to never be generated if you did not also watch for
IN_DELETE_SELF, which affects 15.0 and 15.1, but has been fixed and will
no longer apply in 15.2 / 16.0.

Note that the deleted event check is for the userspace version, since
that governs whether libinotify is being used or not, whereas the
ignored event check is both for the userspace version (to check if we're
using the native syscall) and the kernel version (to check if the kernel
has the bug or not).

All __FreeBSD_version values used here correspond to the value in-tree
at the time of the relevant commits. Since neither commit bumped the
value there will be a window of development snapshots between each
commit and the previous bump that will be incorrectly identified here,
but this is the best we can do, and something users of snapshots should
be prepared to deal with.

Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
---
 tests/unit/test-util-filemonitor.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/tests/unit/test-util-filemonitor.c b/tests/unit/test-util-filemonitor.c
index 02e67fc96ac..972651dc1e1 100644
--- a/tests/unit/test-util-filemonitor.c
+++ b/tests/unit/test-util-filemonitor.c
@@ -27,6 +27,10 @@
 
 #include <utime.h>
 
+#ifdef __FreeBSD__
+#include <osreldate.h>
+#endif
+
 enum {
     QFILE_MONITOR_TEST_OP_ADD_WATCH,
     QFILE_MONITOR_TEST_OP_DEL_WATCH,
@@ -221,6 +225,24 @@ qemu_file_monitor_test_expect(QFileMonitorTestData *data,
 }
 
 
+static bool
+expect_broken_ignored(void)
+{
+#if defined(__FreeBSD__) && __FreeBSD_version >= 1500051
+    int osreldate;
+
+    osreldate = getosreldate();
+    if (osreldate == -1) {
+        g_printerr("Unable to call getosreldate: %s\n", strerror(errno));
+        abort();
+    }
+    return osreldate < 1501501 || (osreldate >= 1600000 && osreldate < 1600019);
+#else
+    return false;
+#endif
+}
+
+
 static void
 test_file_monitor_events(void)
 {
@@ -360,7 +382,7 @@ test_file_monitor_events(void)
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "one.txt", .watchid = &watch4,
           .eventid = QFILE_MONITOR_EVENT_DELETED },
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) && __FreeBSD_version < 1500051
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "two.txt", .watchid = &watch0,
           .eventid = QFILE_MONITOR_EVENT_DELETED },
@@ -539,6 +561,11 @@ test_file_monitor_events(void)
                 g_printerr("Event id=%" PRIx64 " event=%d file=%s\n",
                            *op->watchid, op->eventid, op->filesrc);
             }
+            if (op->eventid == QFILE_MONITOR_EVENT_IGNORED &&
+                expect_broken_ignored()) {
+                g_printerr("Expect ignored event to be broken, skipping\n");
+                break;
+            }
             if (!qemu_file_monitor_test_expect(&data, *op->watchid,
                                                op->eventid, op->filesrc,
                                                op->swapnext))
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] test-util-filemonitor: Adapt to FreeBSD 15's native inotify semantics
  2026-07-09 18:42 [PATCH] test-util-filemonitor: Adapt to FreeBSD 15's native inotify semantics Jessica Clarke
@ 2026-07-10 11:05 ` Daniel P. Berrangé
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel P. Berrangé @ 2026-07-10 11:05 UTC (permalink / raw)
  To: Jessica Clarke; +Cc: qemu-devel

On Thu, Jul 09, 2026 at 07:42:27PM +0100, Jessica Clarke wrote:
> FreeBSD 15 introduces a native inotify implementation rather than
> requiring use of the kqueue-based libinotify package. This native
> implementation does not generate the extra deleted events, so don't
> expect them. However, the original implementation did have a bug that
> caused IN_IGNORED to never be generated if you did not also watch for
> IN_DELETE_SELF, which affects 15.0 and 15.1, but has been fixed and will
> no longer apply in 15.2 / 16.0.
> 
> Note that the deleted event check is for the userspace version, since
> that governs whether libinotify is being used or not, whereas the
> ignored event check is both for the userspace version (to check if we're
> using the native syscall) and the kernel version (to check if the kernel
> has the bug or not).
> 
> All __FreeBSD_version values used here correspond to the value in-tree
> at the time of the relevant commits. Since neither commit bumped the
> value there will be a window of development snapshots between each
> commit and the previous bump that will be incorrectly identified here,
> but this is the best we can do, and something users of snapshots should
> be prepared to deal with.
> 
> Signed-off-by: Jessica Clarke <jrtc27@jrtc27.com>
> ---
>  tests/unit/test-util-filemonitor.c | 29 ++++++++++++++++++++++++++++-
>  1 file changed, 28 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Daniel P. Berrangé <berrange@redhat.com>

and queued.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-10 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09 18:42 [PATCH] test-util-filemonitor: Adapt to FreeBSD 15's native inotify semantics Jessica Clarke
2026-07-10 11:05 ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.