qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] make vm-build-freebsd fixes
@ 2024-01-25 19:48 Ilya Leoshkevich
  2024-01-25 19:48 ` [PATCH 1/3] tests/vm: Set UseDNS=no in the sshd configuration Ilya Leoshkevich
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Ilya Leoshkevich @ 2024-01-25 19:48 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée, Ed Maste, Li-Wen Hsu,
	Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé, Thomas Huth,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel, Ilya Leoshkevich

Hi,

I needed to verify that my qemu-user changes didn't break BSD, and
Daniel Berrange suggested vm-build-freebsd on IRC. I had several
problems with it, which this series resolves.

Best regards,
Ilya

Ilya Leoshkevich (3):
  tests/vm: Set UseDNS=no in the sshd configuration
  tests/vm/freebsd: Reload the sshd configuration
  meson: Disable CONFIG_NOTIFY1 on FreeBSD

 meson.build        | 1 +
 tests/vm/basevm.py | 2 ++
 tests/vm/freebsd   | 2 ++
 3 files changed, 5 insertions(+)

-- 
2.43.0



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

* [PATCH 1/3] tests/vm: Set UseDNS=no in the sshd configuration
  2024-01-25 19:48 [PATCH 0/3] make vm-build-freebsd fixes Ilya Leoshkevich
@ 2024-01-25 19:48 ` Ilya Leoshkevich
  2024-01-31 12:51   ` Thomas Huth
  2024-01-25 19:48 ` [PATCH 2/3] tests/vm/freebsd: Reload " Ilya Leoshkevich
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Ilya Leoshkevich @ 2024-01-25 19:48 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée, Ed Maste, Li-Wen Hsu,
	Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé, Thomas Huth,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel, Ilya Leoshkevich

make vm-build-freebsd sometimes fails with "Connection timed out during
banner exchange". The client strace shows:

    13:59:30 write(3, "SSH-2.0-OpenSSH_9.3\r\n", 21) = 21
    13:59:30 getpid()                       = 252655
    13:59:30 poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
    13:59:32 read(3, "S", 1)                = 1
    13:59:32 poll([{fd=3, events=POLLIN}], 1, 3625) = 1 ([{fd=3, revents=POLLIN}])
    13:59:32 read(3, "S", 1)                = 1
    13:59:32 poll([{fd=3, events=POLLIN}], 1, 3625) = 1 ([{fd=3, revents=POLLIN}])
    13:59:32 read(3, "H", 1)                = 1

There is a 2s delay during connection, and ConnectTimeout is set to 1.
Raising it makes the issue go away, but we can do better. The server
truss shows:

    888: 27.811414714 socket(PF_INET,SOCK_DGRAM|SOCK_CLOEXEC,0) = 5 (0x5)
    888: 27.811765030 connect(5,{ AF_INET 10.0.2.3:53 },16) = 0 (0x0)
    888: 27.812166941 sendto(5,"\^Z/\^A\0\0\^A\0\0\0\0\0\0\^A2"...,39,0,NULL,0) = 39 (0x27)
    888: 29.363970743 poll({ 5/POLLRDNORM },1,5000) = 1 (0x1)

So the delay is due to a DNS query. Disable DNS queries in the server
config.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tests/vm/basevm.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 61725b83254..c0d62c08031 100644
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -423,6 +423,8 @@ def console_ssh_init(self, prompt, user, pw):
     def console_sshd_config(self, prompt):
         self.console_wait(prompt)
         self.console_send("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n")
+        self.console_wait(prompt)
+        self.console_send("echo 'UseDNS no' >> /etc/ssh/sshd_config\n")
         for var in self.envvars:
             self.console_wait(prompt)
             self.console_send("echo 'AcceptEnv %s' >> /etc/ssh/sshd_config\n" % var)
-- 
2.43.0



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

* [PATCH 2/3] tests/vm/freebsd: Reload the sshd configuration
  2024-01-25 19:48 [PATCH 0/3] make vm-build-freebsd fixes Ilya Leoshkevich
  2024-01-25 19:48 ` [PATCH 1/3] tests/vm: Set UseDNS=no in the sshd configuration Ilya Leoshkevich
@ 2024-01-25 19:48 ` Ilya Leoshkevich
  2024-01-31 12:46   ` Thomas Huth
  2024-01-25 19:48 ` [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD Ilya Leoshkevich
  2024-01-31 13:24 ` [PATCH 0/3] make vm-build-freebsd fixes Thomas Huth
  3 siblings, 1 reply; 15+ messages in thread
From: Ilya Leoshkevich @ 2024-01-25 19:48 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée, Ed Maste, Li-Wen Hsu,
	Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé, Thomas Huth,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel, Ilya Leoshkevich

After console_sshd_config(), the SSH server needs to be nudged to pick
up the new configs. The scripts for the other BSD flavors already do
this with a reboot, but a simple reload is sufficient.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 tests/vm/freebsd | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index b581bd17fb7..9971bc1f2b2 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -108,6 +108,8 @@ class FreeBSDVM(basevm.BaseVM):
         prompt = "root@freebsd:~ #"
         self.console_ssh_init(prompt, "root", self._config["root_pass"])
         self.console_sshd_config(prompt)
+        self.console_wait(prompt)
+        self.console_send("service sshd reload\n")
 
         # setup virtio-blk #1 (tarfile)
         self.console_wait(prompt)
-- 
2.43.0



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

* [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-01-25 19:48 [PATCH 0/3] make vm-build-freebsd fixes Ilya Leoshkevich
  2024-01-25 19:48 ` [PATCH 1/3] tests/vm: Set UseDNS=no in the sshd configuration Ilya Leoshkevich
  2024-01-25 19:48 ` [PATCH 2/3] tests/vm/freebsd: Reload " Ilya Leoshkevich
@ 2024-01-25 19:48 ` Ilya Leoshkevich
  2024-01-31 12:50   ` Thomas Huth
  2024-01-31 16:24   ` Philippe Mathieu-Daudé
  2024-01-31 13:24 ` [PATCH 0/3] make vm-build-freebsd fixes Thomas Huth
  3 siblings, 2 replies; 15+ messages in thread
From: Ilya Leoshkevich @ 2024-01-25 19:48 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée, Ed Maste, Li-Wen Hsu,
	Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé, Thomas Huth,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel, Ilya Leoshkevich

make vm-build-freebsd fails with:

    ld: error: undefined symbol: inotify_init1
    >>> referenced by filemonitor-inotify.c:183 (../src/util/filemonitor-inotify.c:183)
    >>>               util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive libqemuutil.a

On FreeBSD inotify functions are defined in libinotify.so, so it might
be tempting to add it to the dependencies. Doing so, however, reveals
that this library handles rename events differently from Linux:

    $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
    Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt -> /tmp/test-util-filemonitor-K13LI2/two.txt
    Event id=200000000 event=2 file=one.txt
    Queue event id 200000000 event 2 file one.txt
    Queue event id 100000000 event 2 file two.txt
    Queue event id 100000002 event 2 file two.txt
    Queue event id 100000000 event 0 file two.txt
    Queue event id 100000002 event 0 file two.txt
    Event id=100000000 event=0 file=two.txt
    Expected event 0 but got 2

FreeBSD itself disables this functionality in the respective port [1].
So do it upstream too.

[1] https://cgit.freebsd.org/ports/tree/emulators/qemu-devel/files/patch-util_meson.build?id=984366c18f1bc54e38751afc29be08c596b83696

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meson.build b/meson.build
index d0329966f1b..3d67d78b522 100644
--- a/meson.build
+++ b/meson.build
@@ -2403,6 +2403,7 @@ config_host_data.set('CONFIG_GETRANDOM',
 config_host_data.set('CONFIG_INOTIFY',
                      cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
 config_host_data.set('CONFIG_INOTIFY1',
+                     host_os != 'freebsd' and
                      cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
 config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
                      cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
-- 
2.43.0



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

* Re: [PATCH 2/3] tests/vm/freebsd: Reload the sshd configuration
  2024-01-25 19:48 ` [PATCH 2/3] tests/vm/freebsd: Reload " Ilya Leoshkevich
@ 2024-01-31 12:46   ` Thomas Huth
  0 siblings, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2024-01-31 12:46 UTC (permalink / raw)
  To: Ilya Leoshkevich, Paolo Bonzini, Alex Bennée, Ed Maste,
	Li-Wen Hsu, Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel

On 25/01/2024 20.48, Ilya Leoshkevich wrote:
> After console_sshd_config(), the SSH server needs to be nudged to pick
> up the new configs. The scripts for the other BSD flavors already do
> this with a reboot, but a simple reload is sufficient.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   tests/vm/freebsd | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tests/vm/freebsd b/tests/vm/freebsd
> index b581bd17fb7..9971bc1f2b2 100755
> --- a/tests/vm/freebsd
> +++ b/tests/vm/freebsd
> @@ -108,6 +108,8 @@ class FreeBSDVM(basevm.BaseVM):
>           prompt = "root@freebsd:~ #"
>           self.console_ssh_init(prompt, "root", self._config["root_pass"])
>           self.console_sshd_config(prompt)
> +        self.console_wait(prompt)
> +        self.console_send("service sshd reload\n")

Could be simplified to:

	self.console_wait_send(prompt, "service sshd reload\n")

  Thomas



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

* Re: [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-01-25 19:48 ` [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD Ilya Leoshkevich
@ 2024-01-31 12:50   ` Thomas Huth
  2024-01-31 16:24   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2024-01-31 12:50 UTC (permalink / raw)
  To: Ilya Leoshkevich, Paolo Bonzini, Alex Bennée, Ed Maste,
	Li-Wen Hsu, Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel

On 25/01/2024 20.48, Ilya Leoshkevich wrote:
> make vm-build-freebsd fails with:
> 
>      ld: error: undefined symbol: inotify_init1
>      >>> referenced by filemonitor-inotify.c:183 (../src/util/filemonitor-inotify.c:183)
>      >>>               util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive libqemuutil.a
> 
> On FreeBSD inotify functions are defined in libinotify.so, so it might
> be tempting to add it to the dependencies. Doing so, however, reveals
> that this library handles rename events differently from Linux:
> 
>      $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
>      Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt -> /tmp/test-util-filemonitor-K13LI2/two.txt
>      Event id=200000000 event=2 file=one.txt
>      Queue event id 200000000 event 2 file one.txt
>      Queue event id 100000000 event 2 file two.txt
>      Queue event id 100000002 event 2 file two.txt
>      Queue event id 100000000 event 0 file two.txt
>      Queue event id 100000002 event 0 file two.txt
>      Event id=100000000 event=0 file=two.txt
>      Expected event 0 but got 2
> 
> FreeBSD itself disables this functionality in the respective port [1].
> So do it upstream too.
> 
> [1] https://cgit.freebsd.org/ports/tree/emulators/qemu-devel/files/patch-util_meson.build?id=984366c18f1bc54e38751afc29be08c596b83696
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   meson.build | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/meson.build b/meson.build
> index d0329966f1b..3d67d78b522 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2403,6 +2403,7 @@ config_host_data.set('CONFIG_GETRANDOM',
>   config_host_data.set('CONFIG_INOTIFY',
>                        cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
>   config_host_data.set('CONFIG_INOTIFY1',
> +                     host_os != 'freebsd' and
>                        cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
>   config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
>                        cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH 1/3] tests/vm: Set UseDNS=no in the sshd configuration
  2024-01-25 19:48 ` [PATCH 1/3] tests/vm: Set UseDNS=no in the sshd configuration Ilya Leoshkevich
@ 2024-01-31 12:51   ` Thomas Huth
  0 siblings, 0 replies; 15+ messages in thread
From: Thomas Huth @ 2024-01-31 12:51 UTC (permalink / raw)
  To: Ilya Leoshkevich, Paolo Bonzini, Alex Bennée, Ed Maste,
	Li-Wen Hsu, Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel

On 25/01/2024 20.48, Ilya Leoshkevich wrote:
> make vm-build-freebsd sometimes fails with "Connection timed out during
> banner exchange". The client strace shows:
> 
>      13:59:30 write(3, "SSH-2.0-OpenSSH_9.3\r\n", 21) = 21
>      13:59:30 getpid()                       = 252655
>      13:59:30 poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
>      13:59:32 read(3, "S", 1)                = 1
>      13:59:32 poll([{fd=3, events=POLLIN}], 1, 3625) = 1 ([{fd=3, revents=POLLIN}])
>      13:59:32 read(3, "S", 1)                = 1
>      13:59:32 poll([{fd=3, events=POLLIN}], 1, 3625) = 1 ([{fd=3, revents=POLLIN}])
>      13:59:32 read(3, "H", 1)                = 1
> 
> There is a 2s delay during connection, and ConnectTimeout is set to 1.
> Raising it makes the issue go away, but we can do better. The server
> truss shows:
> 
>      888: 27.811414714 socket(PF_INET,SOCK_DGRAM|SOCK_CLOEXEC,0) = 5 (0x5)
>      888: 27.811765030 connect(5,{ AF_INET 10.0.2.3:53 },16) = 0 (0x0)
>      888: 27.812166941 sendto(5,"\^Z/\^A\0\0\^A\0\0\0\0\0\0\^A2"...,39,0,NULL,0) = 39 (0x27)
>      888: 29.363970743 poll({ 5/POLLRDNORM },1,5000) = 1 (0x1)
> 
> So the delay is due to a DNS query. Disable DNS queries in the server
> config.
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   tests/vm/basevm.py | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 61725b83254..c0d62c08031 100644
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -423,6 +423,8 @@ def console_ssh_init(self, prompt, user, pw):
>       def console_sshd_config(self, prompt):
>           self.console_wait(prompt)
>           self.console_send("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n")
> +        self.console_wait(prompt)
> +        self.console_send("echo 'UseDNS no' >> /etc/ssh/sshd_config\n")
>           for var in self.envvars:
>               self.console_wait(prompt)
>               self.console_send("echo 'AcceptEnv %s' >> /etc/ssh/sshd_config\n" % var)

Reviewed-by: Thomas Huth <thuth@redhat.com>



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

* Re: [PATCH 0/3] make vm-build-freebsd fixes
  2024-01-25 19:48 [PATCH 0/3] make vm-build-freebsd fixes Ilya Leoshkevich
                   ` (2 preceding siblings ...)
  2024-01-25 19:48 ` [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD Ilya Leoshkevich
@ 2024-01-31 13:24 ` Thomas Huth
  2024-01-31 13:24   ` Ilya Leoshkevich
  3 siblings, 1 reply; 15+ messages in thread
From: Thomas Huth @ 2024-01-31 13:24 UTC (permalink / raw)
  To: Ilya Leoshkevich, Paolo Bonzini, Alex Bennée, Ed Maste,
	Li-Wen Hsu, Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel

On 25/01/2024 20.48, Ilya Leoshkevich wrote:
> Hi,
> 
> I needed to verify that my qemu-user changes didn't break BSD, and
> Daniel Berrange suggested vm-build-freebsd on IRC. I had several
> problems with it, which this series resolves.
> 
> Best regards,
> Ilya
> 
> Ilya Leoshkevich (3):
>    tests/vm: Set UseDNS=no in the sshd configuration
>    tests/vm/freebsd: Reload the sshd configuration
>    meson: Disable CONFIG_NOTIFY1 on FreeBSD
> 
>   meson.build        | 1 +
>   tests/vm/basevm.py | 2 ++
>   tests/vm/freebsd   | 2 ++
>   3 files changed, 5 insertions(+)

Tested-by: Thomas Huth <thuth@redhat.com>

I can take the patches through my tree (and fix the second patch to use 
console_wait_send() if you don't mind).

  Thomas



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

* Re: [PATCH 0/3] make vm-build-freebsd fixes
  2024-01-31 13:24 ` [PATCH 0/3] make vm-build-freebsd fixes Thomas Huth
@ 2024-01-31 13:24   ` Ilya Leoshkevich
  0 siblings, 0 replies; 15+ messages in thread
From: Ilya Leoshkevich @ 2024-01-31 13:24 UTC (permalink / raw)
  To: Thomas Huth, Paolo Bonzini, Alex Bennée, Ed Maste,
	Li-Wen Hsu, Warner Losh
  Cc: Marc-André Lureau, Daniel P. Berrangé,
	Philippe Mathieu-Daudé, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel

On Wed, 2024-01-31 at 14:24 +0100, Thomas Huth wrote:
> On 25/01/2024 20.48, Ilya Leoshkevich wrote:
> > Hi,
> > 
> > I needed to verify that my qemu-user changes didn't break BSD, and
> > Daniel Berrange suggested vm-build-freebsd on IRC. I had several
> > problems with it, which this series resolves.
> > 
> > Best regards,
> > Ilya
> > 
> > Ilya Leoshkevich (3):
> >    tests/vm: Set UseDNS=no in the sshd configuration
> >    tests/vm/freebsd: Reload the sshd configuration
> >    meson: Disable CONFIG_NOTIFY1 on FreeBSD
> > 
> >   meson.build        | 1 +
> >   tests/vm/basevm.py | 2 ++
> >   tests/vm/freebsd   | 2 ++
> >   3 files changed, 5 insertions(+)
> 
> Tested-by: Thomas Huth <thuth@redhat.com>
> 
> I can take the patches through my tree (and fix the second patch to
> use 
> console_wait_send() if you don't mind).
> 
>   Thomas
> 

Sure, that sounds good to me. Thanks!


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

* Re: [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-01-25 19:48 ` [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD Ilya Leoshkevich
  2024-01-31 12:50   ` Thomas Huth
@ 2024-01-31 16:24   ` Philippe Mathieu-Daudé
  2024-01-31 16:42     ` Daniel P. Berrangé
  1 sibling, 1 reply; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-31 16:24 UTC (permalink / raw)
  To: Ilya Leoshkevich, Paolo Bonzini, Daniel P. Berrangé,
	Ed Maste, Li-Wen Hsu, Warner Losh
  Cc: Marc-André Lureau, Thomas Huth, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel, Alex Bennée,
	Richard Henderson, Peter Maydell

Hi,

Warner, do you remember what this is about?

(https://cgit.freebsd.org/ports/commit/emulators/qemu-devel/files/patch-util_meson.build?id=2ab482e2c8f51eae7ffd747685b7f181fe1b3809 
isn't very verbose).

On 25/1/24 20:48, Ilya Leoshkevich wrote:
> make vm-build-freebsd fails with:
> 
>      ld: error: undefined symbol: inotify_init1
>      >>> referenced by filemonitor-inotify.c:183 (../src/util/filemonitor-inotify.c:183)
>      >>>               util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive libqemuutil.a
> 
> On FreeBSD inotify functions are defined in libinotify.so, so it might
> be tempting to add it to the dependencies. Doing so, however, reveals
> that this library handles rename events differently from Linux:
> 
>      $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
>      Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt -> /tmp/test-util-filemonitor-K13LI2/two.txt
>      Event id=200000000 event=2 file=one.txt
>      Queue event id 200000000 event 2 file one.txt
>      Queue event id 100000000 event 2 file two.txt
>      Queue event id 100000002 event 2 file two.txt
>      Queue event id 100000000 event 0 file two.txt
>      Queue event id 100000002 event 0 file two.txt
>      Event id=100000000 event=0 file=two.txt
>      Expected event 0 but got 2

Wouldn't it be better to use a runtime check in qemu_file_monitor_new()?

> FreeBSD itself disables this functionality in the respective port [1].
> So do it upstream too.
> 
> [1] https://cgit.freebsd.org/ports/tree/emulators/qemu-devel/files/patch-util_meson.build?id=984366c18f1bc54e38751afc29be08c596b83696
> 
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
>   meson.build | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/meson.build b/meson.build
> index d0329966f1b..3d67d78b522 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2403,6 +2403,7 @@ config_host_data.set('CONFIG_GETRANDOM',
>   config_host_data.set('CONFIG_INOTIFY',
>                        cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
>   config_host_data.set('CONFIG_INOTIFY1',
> +                     host_os != 'freebsd' and
>                        cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
>   config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
>                        cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))



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

* Re: [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-01-31 16:24   ` Philippe Mathieu-Daudé
@ 2024-01-31 16:42     ` Daniel P. Berrangé
  2024-02-05 15:23       ` Warner Losh
  0 siblings, 1 reply; 15+ messages in thread
From: Daniel P. Berrangé @ 2024-01-31 16:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Ilya Leoshkevich, Paolo Bonzini, Ed Maste, Li-Wen Hsu,
	Warner Losh, Marc-André Lureau, Thomas Huth,
	Wainer dos Santos Moschetta, Beraldo Leal, Kyle Evans, qemu-devel,
	Alex Bennée, Richard Henderson, Peter Maydell

On Wed, Jan 31, 2024 at 05:24:10PM +0100, Philippe Mathieu-Daudé wrote:
> Hi,
> 
> Warner, do you remember what this is about?
> 
> (https://cgit.freebsd.org/ports/commit/emulators/qemu-devel/files/patch-util_meson.build?id=2ab482e2c8f51eae7ffd747685b7f181fe1b3809
> isn't very verbose).

That's simply going to workaround our incomplete feature
check. We look for sys/inotify.h and if present, we
assume that is in the C library. That's true on Linux,
but not true on *BSD, hence the undefined symbol.

We need to augment the header file check with a linker
symbol check for the C library.

If we wanted to also check for -linotify that'd make
it portable to BSD, but not the behaviour difference
mentioned below.

> 
> On 25/1/24 20:48, Ilya Leoshkevich wrote:
> > make vm-build-freebsd fails with:
> > 
> >      ld: error: undefined symbol: inotify_init1
> >      >>> referenced by filemonitor-inotify.c:183 (../src/util/filemonitor-inotify.c:183)
> >      >>>               util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive libqemuutil.a
> > 
> > On FreeBSD inotify functions are defined in libinotify.so, so it might
> > be tempting to add it to the dependencies. Doing so, however, reveals
> > that this library handles rename events differently from Linux:
> > 
> >      $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
> >      Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt -> /tmp/test-util-filemonitor-K13LI2/two.txt
> >      Event id=200000000 event=2 file=one.txt
> >      Queue event id 200000000 event 2 file one.txt
> >      Queue event id 100000000 event 2 file two.txt
> >      Queue event id 100000002 event 2 file two.txt
> >      Queue event id 100000000 event 0 file two.txt
> >      Queue event id 100000002 event 0 file two.txt
> >      Event id=100000000 event=0 file=two.txt
> >      Expected event 0 but got 2

Interesting. So In the "Rename" test, the destination already exists.

BSD is thus reporting that 'two.txt' is deleted, before being (re)created
Linux is only reporting 'two.txt' is created.

I don't think we can easily paper over this difference. The easiest is
probably to conditionalize the test

 git diff
diff --git a/tests/unit/test-util-filemonitor.c b/tests/unit/test-util-filemonitor.c
index a22de27595..c3b2006365 100644
--- a/tests/unit/test-util-filemonitor.c
+++ b/tests/unit/test-util-filemonitor.c
@@ -281,6 +281,14 @@ test_file_monitor_events(void)
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "one.txt", .watchid = &watch1,
           .eventid = QFILE_MONITOR_EVENT_DELETED },
+#ifdef __FreeBSD__
+        { .type = QFILE_MONITOR_TEST_OP_EVENT,
+          .filesrc = "two.txt", .watchid = &watch0,
+          .eventid = QFILE_MONITOR_EVENT_DELETED },
+        { .type = QFILE_MONITOR_TEST_OP_EVENT,
+          .filesrc = "two.txt", .watchid = &watch2,
+          .eventid = QFILE_MONITOR_EVENT_DELETED },
+#endif
         { .type = QFILE_MONITOR_TEST_OP_EVENT,
           .filesrc = "two.txt", .watchid = &watch0,
           .eventid = QFILE_MONITOR_EVENT_CREATED },


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-01-31 16:42     ` Daniel P. Berrangé
@ 2024-02-05 15:23       ` Warner Losh
  2024-02-05 15:31         ` Daniel P. Berrangé
  0 siblings, 1 reply; 15+ messages in thread
From: Warner Losh @ 2024-02-05 15:23 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Philippe Mathieu-Daudé, Ilya Leoshkevich, Paolo Bonzini,
	Ed Maste, Li-Wen Hsu, Marc-André Lureau, Thomas Huth,
	Wainer dos Santos Moschetta, Beraldo Leal, Kyle Evans, qemu-devel,
	Alex Bennée, Richard Henderson, Peter Maydell

[-- Attachment #1: Type: text/plain, Size: 3493 bytes --]

On Wed, Jan 31, 2024 at 9:42 AM Daniel P. Berrangé <berrange@redhat.com>
wrote:

> On Wed, Jan 31, 2024 at 05:24:10PM +0100, Philippe Mathieu-Daudé wrote:
> > Hi,
> >
> > Warner, do you remember what this is about?
> >
> > (
> https://cgit.freebsd.org/ports/commit/emulators/qemu-devel/files/patch-util_meson.build?id=2ab482e2c8f51eae7ffd747685b7f181fe1b3809
> > isn't very verbose).
>
> That's simply going to workaround our incomplete feature
> check. We look for sys/inotify.h and if present, we
> assume that is in the C library. That's true on Linux,
> but not true on *BSD, hence the undefined symbol.
>
> We need to augment the header file check with a linker
> symbol check for the C library.
>
> If we wanted to also check for -linotify that'd make
> it portable to BSD, but not the behaviour difference
> mentioned below.
>
> >
> > On 25/1/24 20:48, Ilya Leoshkevich wrote:
> > > make vm-build-freebsd fails with:
> > >
> > >      ld: error: undefined symbol: inotify_init1
> > >      >>> referenced by filemonitor-inotify.c:183
> (../src/util/filemonitor-inotify.c:183)
> > >      >>>
>  util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive
> libqemuutil.a
> > >
> > > On FreeBSD inotify functions are defined in libinotify.so, so it might
> > > be tempting to add it to the dependencies. Doing so, however, reveals
> > > that this library handles rename events differently from Linux:
> > >
> > >      $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
> > >      Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt ->
> /tmp/test-util-filemonitor-K13LI2/two.txt
> > >      Event id=200000000 event=2 file=one.txt
> > >      Queue event id 200000000 event 2 file one.txt
> > >      Queue event id 100000000 event 2 file two.txt
> > >      Queue event id 100000002 event 2 file two.txt
> > >      Queue event id 100000000 event 0 file two.txt
> > >      Queue event id 100000002 event 0 file two.txt
> > >      Event id=100000000 event=0 file=two.txt
> > >      Expected event 0 but got 2
>
> Interesting. So In the "Rename" test, the destination already exists.
>
> BSD is thus reporting that 'two.txt' is deleted, before being (re)created
> Linux is only reporting 'two.txt' is created.
>
> I don't think we can easily paper over this difference. The easiest is
> probably to conditionalize the test
>
>  git diff
> diff --git a/tests/unit/test-util-filemonitor.c
> b/tests/unit/test-util-filemonitor.c
> index a22de27595..c3b2006365 100644
> --- a/tests/unit/test-util-filemonitor.c
> +++ b/tests/unit/test-util-filemonitor.c
> @@ -281,6 +281,14 @@ test_file_monitor_events(void)
>          { .type = QFILE_MONITOR_TEST_OP_EVENT,
>            .filesrc = "one.txt", .watchid = &watch1,
>            .eventid = QFILE_MONITOR_EVENT_DELETED },
> +#ifdef __FreeBSD__
> +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
> +          .filesrc = "two.txt", .watchid = &watch0,
> +          .eventid = QFILE_MONITOR_EVENT_DELETED },
> +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
> +          .filesrc = "two.txt", .watchid = &watch2,
> +          .eventid = QFILE_MONITOR_EVENT_DELETED },
> +#endif
>          { .type = QFILE_MONITOR_TEST_OP_EVENT,
>            .filesrc = "two.txt", .watchid = &watch0,
>            .eventid = QFILE_MONITOR_EVENT_CREATED },
>

I agree this is likely the best course of action. Has anybody filed a bug
at https://bugs.freebsd.org?

Warner

[-- Attachment #2: Type: text/html, Size: 4584 bytes --]

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

* Re: [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-02-05 15:23       ` Warner Losh
@ 2024-02-05 15:31         ` Daniel P. Berrangé
  2024-02-05 15:56           ` Ilya Leoshkevich
  2024-02-05 16:02           ` Kyle Evans
  0 siblings, 2 replies; 15+ messages in thread
From: Daniel P. Berrangé @ 2024-02-05 15:31 UTC (permalink / raw)
  To: Warner Losh
  Cc: Philippe Mathieu-Daudé, Ilya Leoshkevich, Paolo Bonzini,
	Ed Maste, Li-Wen Hsu, Marc-André Lureau, Thomas Huth,
	Wainer dos Santos Moschetta, Beraldo Leal, Kyle Evans, qemu-devel,
	Alex Bennée, Richard Henderson, Peter Maydell

On Mon, Feb 05, 2024 at 08:23:41AM -0700, Warner Losh wrote:
> On Wed, Jan 31, 2024 at 9:42 AM Daniel P. Berrangé <berrange@redhat.com>
> wrote:
> 
> > On Wed, Jan 31, 2024 at 05:24:10PM +0100, Philippe Mathieu-Daudé wrote:
> > > Hi,
> > >
> > > Warner, do you remember what this is about?
> > >
> > > (
> > https://cgit.freebsd.org/ports/commit/emulators/qemu-devel/files/patch-util_meson.build?id=2ab482e2c8f51eae7ffd747685b7f181fe1b3809
> > > isn't very verbose).
> >
> > That's simply going to workaround our incomplete feature
> > check. We look for sys/inotify.h and if present, we
> > assume that is in the C library. That's true on Linux,
> > but not true on *BSD, hence the undefined symbol.
> >
> > We need to augment the header file check with a linker
> > symbol check for the C library.
> >
> > If we wanted to also check for -linotify that'd make
> > it portable to BSD, but not the behaviour difference
> > mentioned below.
> >
> > >
> > > On 25/1/24 20:48, Ilya Leoshkevich wrote:
> > > > make vm-build-freebsd fails with:
> > > >
> > > >      ld: error: undefined symbol: inotify_init1
> > > >      >>> referenced by filemonitor-inotify.c:183
> > (../src/util/filemonitor-inotify.c:183)
> > > >      >>>
> >  util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive
> > libqemuutil.a
> > > >
> > > > On FreeBSD inotify functions are defined in libinotify.so, so it might
> > > > be tempting to add it to the dependencies. Doing so, however, reveals
> > > > that this library handles rename events differently from Linux:
> > > >
> > > >      $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
> > > >      Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt ->
> > /tmp/test-util-filemonitor-K13LI2/two.txt
> > > >      Event id=200000000 event=2 file=one.txt
> > > >      Queue event id 200000000 event 2 file one.txt
> > > >      Queue event id 100000000 event 2 file two.txt
> > > >      Queue event id 100000002 event 2 file two.txt
> > > >      Queue event id 100000000 event 0 file two.txt
> > > >      Queue event id 100000002 event 0 file two.txt
> > > >      Event id=100000000 event=0 file=two.txt
> > > >      Expected event 0 but got 2
> >
> > Interesting. So In the "Rename" test, the destination already exists.
> >
> > BSD is thus reporting that 'two.txt' is deleted, before being (re)created
> > Linux is only reporting 'two.txt' is created.
> >
> > I don't think we can easily paper over this difference. The easiest is
> > probably to conditionalize the test
> >
> >  git diff
> > diff --git a/tests/unit/test-util-filemonitor.c
> > b/tests/unit/test-util-filemonitor.c
> > index a22de27595..c3b2006365 100644
> > --- a/tests/unit/test-util-filemonitor.c
> > +++ b/tests/unit/test-util-filemonitor.c
> > @@ -281,6 +281,14 @@ test_file_monitor_events(void)
> >          { .type = QFILE_MONITOR_TEST_OP_EVENT,
> >            .filesrc = "one.txt", .watchid = &watch1,
> >            .eventid = QFILE_MONITOR_EVENT_DELETED },
> > +#ifdef __FreeBSD__
> > +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
> > +          .filesrc = "two.txt", .watchid = &watch0,
> > +          .eventid = QFILE_MONITOR_EVENT_DELETED },
> > +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
> > +          .filesrc = "two.txt", .watchid = &watch2,
> > +          .eventid = QFILE_MONITOR_EVENT_DELETED },
> > +#endif
> >          { .type = QFILE_MONITOR_TEST_OP_EVENT,
> >            .filesrc = "two.txt", .watchid = &watch0,
> >            .eventid = QFILE_MONITOR_EVENT_CREATED },
> >
> 
> I agree this is likely the best course of action. Has anybody filed a bug
> at https://bugs.freebsd.org?

I've not, and I'm not even sure I would class it a FreeBSD bug. Other
than the fact that it differs from Linux behaviour, it feels like it
is reasonble semantics to emit a 'delete' event in this scenario so
that an event consumer can detect replacement of an existing file.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



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

* Re: [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-02-05 15:31         ` Daniel P. Berrangé
@ 2024-02-05 15:56           ` Ilya Leoshkevich
  2024-02-05 16:02           ` Kyle Evans
  1 sibling, 0 replies; 15+ messages in thread
From: Ilya Leoshkevich @ 2024-02-05 15:56 UTC (permalink / raw)
  To: Daniel P. Berrangé, Warner Losh
  Cc: Philippe Mathieu-Daudé, Paolo Bonzini, Ed Maste, Li-Wen Hsu,
	Marc-André Lureau, Thomas Huth, Wainer dos Santos Moschetta,
	Beraldo Leal, Kyle Evans, qemu-devel, Alex Bennée,
	Richard Henderson, Peter Maydell

On Mon, 2024-02-05 at 15:31 +0000, Daniel P. Berrangé wrote:
> On Mon, Feb 05, 2024 at 08:23:41AM -0700, Warner Losh wrote:
> > On Wed, Jan 31, 2024 at 9:42 AM Daniel P. Berrangé
> > <berrange@redhat.com>
> > wrote:
> > 
> > > On Wed, Jan 31, 2024 at 05:24:10PM +0100, Philippe Mathieu-Daudé
> > > wrote:
> > > > Hi,
> > > > 
> > > > Warner, do you remember what this is about?
> > > > 
> > > > (
> > > https://cgit.freebsd.org/ports/commit/emulators/qemu-devel/files/patch-util_meson.build?id=2ab482e2c8f51eae7ffd747685b7f181fe1b3809
> > > > isn't very verbose).
> > > 
> > > That's simply going to workaround our incomplete feature
> > > check. We look for sys/inotify.h and if present, we
> > > assume that is in the C library. That's true on Linux,
> > > but not true on *BSD, hence the undefined symbol.
> > > 
> > > We need to augment the header file check with a linker
> > > symbol check for the C library.
> > > 
> > > If we wanted to also check for -linotify that'd make
> > > it portable to BSD, but not the behaviour difference
> > > mentioned below.
> > > 
> > > > 
> > > > On 25/1/24 20:48, Ilya Leoshkevich wrote:
> > > > > make vm-build-freebsd fails with:
> > > > > 
> > > > >      ld: error: undefined symbol: inotify_init1
> > > > >      >>> referenced by filemonitor-inotify.c:183
> > > (../src/util/filemonitor-inotify.c:183)
> > > > >      >>>
> > >  util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive
> > > libqemuutil.a
> > > > > 
> > > > > On FreeBSD inotify functions are defined in libinotify.so, so
> > > > > it might
> > > > > be tempting to add it to the dependencies. Doing so, however,
> > > > > reveals
> > > > > that this library handles rename events differently from
> > > > > Linux:
> > > > > 
> > > > >      $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-
> > > > > filemonitor
> > > > >      Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt ->
> > > /tmp/test-util-filemonitor-K13LI2/two.txt
> > > > >      Event id=200000000 event=2 file=one.txt
> > > > >      Queue event id 200000000 event 2 file one.txt
> > > > >      Queue event id 100000000 event 2 file two.txt
> > > > >      Queue event id 100000002 event 2 file two.txt
> > > > >      Queue event id 100000000 event 0 file two.txt
> > > > >      Queue event id 100000002 event 0 file two.txt
> > > > >      Event id=100000000 event=0 file=two.txt
> > > > >      Expected event 0 but got 2
> > > 
> > > Interesting. So In the "Rename" test, the destination already
> > > exists.
> > > 
> > > BSD is thus reporting that 'two.txt' is deleted, before being
> > > (re)created
> > > Linux is only reporting 'two.txt' is created.
> > > 
> > > I don't think we can easily paper over this difference. The
> > > easiest is
> > > probably to conditionalize the test
> > > 
> > >  git diff
> > > diff --git a/tests/unit/test-util-filemonitor.c
> > > b/tests/unit/test-util-filemonitor.c
> > > index a22de27595..c3b2006365 100644
> > > --- a/tests/unit/test-util-filemonitor.c
> > > +++ b/tests/unit/test-util-filemonitor.c
> > > @@ -281,6 +281,14 @@ test_file_monitor_events(void)
> > >          { .type = QFILE_MONITOR_TEST_OP_EVENT,
> > >            .filesrc = "one.txt", .watchid = &watch1,
> > >            .eventid = QFILE_MONITOR_EVENT_DELETED },
> > > +#ifdef __FreeBSD__
> > > +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
> > > +          .filesrc = "two.txt", .watchid = &watch0,
> > > +          .eventid = QFILE_MONITOR_EVENT_DELETED },
> > > +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
> > > +          .filesrc = "two.txt", .watchid = &watch2,
> > > +          .eventid = QFILE_MONITOR_EVENT_DELETED },
> > > +#endif
> > >          { .type = QFILE_MONITOR_TEST_OP_EVENT,
> > >            .filesrc = "two.txt", .watchid = &watch0,
> > >            .eventid = QFILE_MONITOR_EVENT_CREATED },
> > > 
> > 
> > I agree this is likely the best course of action. Has anybody filed
> > a bug
> > at https://bugs.freebsd.org?
> 
> I've not, and I'm not even sure I would class it a FreeBSD bug. Other
> than the fact that it differs from Linux behaviour, it feels like it
> is reasonble semantics to emit a 'delete' event in this scenario so
> that an event consumer can detect replacement of an existing file.
> 
> With regards,
> Daniel

Sounds reasonable; I will send a v2 with the meson adjustments and with
the test fix.


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

* Re: [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD
  2024-02-05 15:31         ` Daniel P. Berrangé
  2024-02-05 15:56           ` Ilya Leoshkevich
@ 2024-02-05 16:02           ` Kyle Evans
  1 sibling, 0 replies; 15+ messages in thread
From: Kyle Evans @ 2024-02-05 16:02 UTC (permalink / raw)
  To: Daniel P. Berrangé, Warner Losh
  Cc: Philippe Mathieu-Daudé, Ilya Leoshkevich, Paolo Bonzini,
	Ed Maste, Li-Wen Hsu, Marc-André Lureau, Thomas Huth,
	Wainer dos Santos Moschetta, Beraldo Leal, qemu-devel,
	Alex Bennée, Richard Henderson, Peter Maydell

On 2/5/24 09:31, Daniel P. Berrangé wrote:
> On Mon, Feb 05, 2024 at 08:23:41AM -0700, Warner Losh wrote:
>> On Wed, Jan 31, 2024 at 9:42 AM Daniel P. Berrangé <berrange@redhat.com>
>> wrote:
>>
>>> On Wed, Jan 31, 2024 at 05:24:10PM +0100, Philippe Mathieu-Daudé wrote:
 > [... snip ...]
>>>> On 25/1/24 20:48, Ilya Leoshkevich wrote:
>>>>> make vm-build-freebsd fails with:
>>>>>
>>>>>       ld: error: undefined symbol: inotify_init1
>>>>>       >>> referenced by filemonitor-inotify.c:183
>>> (../src/util/filemonitor-inotify.c:183)
>>>>>       >>>
>>>   util_filemonitor-inotify.c.o:(qemu_file_monitor_new) in archive
>>> libqemuutil.a
>>>>>
>>>>> On FreeBSD inotify functions are defined in libinotify.so, so it might
>>>>> be tempting to add it to the dependencies. Doing so, however, reveals
>>>>> that this library handles rename events differently from Linux:
>>>>>
>>>>>       $ FILEMONITOR_DEBUG=1 build/tests/unit/test-util-filemonitor
>>>>>       Rename /tmp/test-util-filemonitor-K13LI2/fish/one.txt ->
>>> /tmp/test-util-filemonitor-K13LI2/two.txt
>>>>>       Event id=200000000 event=2 file=one.txt
>>>>>       Queue event id 200000000 event 2 file one.txt
>>>>>       Queue event id 100000000 event 2 file two.txt
>>>>>       Queue event id 100000002 event 2 file two.txt
>>>>>       Queue event id 100000000 event 0 file two.txt
>>>>>       Queue event id 100000002 event 0 file two.txt
>>>>>       Event id=100000000 event=0 file=two.txt
>>>>>       Expected event 0 but got 2
>>>
>>> Interesting. So In the "Rename" test, the destination already exists.
>>>
>>> BSD is thus reporting that 'two.txt' is deleted, before being (re)created
>>> Linux is only reporting 'two.txt' is created.
>>>
>>> I don't think we can easily paper over this difference. The easiest is
>>> probably to conditionalize the test
>>>
>>>   git diff
>>> diff --git a/tests/unit/test-util-filemonitor.c
>>> b/tests/unit/test-util-filemonitor.c
>>> index a22de27595..c3b2006365 100644
>>> --- a/tests/unit/test-util-filemonitor.c
>>> +++ b/tests/unit/test-util-filemonitor.c
>>> @@ -281,6 +281,14 @@ test_file_monitor_events(void)
>>>           { .type = QFILE_MONITOR_TEST_OP_EVENT,
>>>             .filesrc = "one.txt", .watchid = &watch1,
>>>             .eventid = QFILE_MONITOR_EVENT_DELETED },
>>> +#ifdef __FreeBSD__
>>> +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
>>> +          .filesrc = "two.txt", .watchid = &watch0,
>>> +          .eventid = QFILE_MONITOR_EVENT_DELETED },
>>> +        { .type = QFILE_MONITOR_TEST_OP_EVENT,
>>> +          .filesrc = "two.txt", .watchid = &watch2,
>>> +          .eventid = QFILE_MONITOR_EVENT_DELETED },
>>> +#endif
>>>           { .type = QFILE_MONITOR_TEST_OP_EVENT,
>>>             .filesrc = "two.txt", .watchid = &watch0,
>>>             .eventid = QFILE_MONITOR_EVENT_CREATED },
>>>
>>
>> I agree this is likely the best course of action. Has anybody filed a bug
>> at https://bugs.freebsd.org?
> 
> I've not, and I'm not even sure I would class it a FreeBSD bug. Other
> than the fact that it differs from Linux behaviour, it feels like it
> is reasonble semantics to emit a 'delete' event in this scenario so
> that an event consumer can detect replacement of an existing file.
> 

FWIW, +1... unless we miss the follow-up notification that it's been 
created, I'd personally put it into the WONTFIX bucket pretty quickly.

Barring some kind of NOTE_COVER (bad name) that can be emitted if a file 
is simply replaced by another, a directory being reported as shortened 
then extended is a valid and useful representation of the situation 
(even if not completely accurate) to avoid consumers missing the action 
entirely.

Thanks,

Kyle Evans


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

end of thread, other threads:[~2024-02-05 16:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25 19:48 [PATCH 0/3] make vm-build-freebsd fixes Ilya Leoshkevich
2024-01-25 19:48 ` [PATCH 1/3] tests/vm: Set UseDNS=no in the sshd configuration Ilya Leoshkevich
2024-01-31 12:51   ` Thomas Huth
2024-01-25 19:48 ` [PATCH 2/3] tests/vm/freebsd: Reload " Ilya Leoshkevich
2024-01-31 12:46   ` Thomas Huth
2024-01-25 19:48 ` [PATCH 3/3] meson: Disable CONFIG_NOTIFY1 on FreeBSD Ilya Leoshkevich
2024-01-31 12:50   ` Thomas Huth
2024-01-31 16:24   ` Philippe Mathieu-Daudé
2024-01-31 16:42     ` Daniel P. Berrangé
2024-02-05 15:23       ` Warner Losh
2024-02-05 15:31         ` Daniel P. Berrangé
2024-02-05 15:56           ` Ilya Leoshkevich
2024-02-05 16:02           ` Kyle Evans
2024-01-31 13:24 ` [PATCH 0/3] make vm-build-freebsd fixes Thomas Huth
2024-01-31 13:24   ` Ilya Leoshkevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).