virtiofsd: Meson build fixes
cover virtiofsd: Meson build fixes
A pair of fixes to allow building virtiofsd without sysemu/tools.
Should this configuration be tested in CI?
Regards,
Phil.
Philippe Mathieu-Daudé (2):
meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled util/meson: Build iov/hexdump/buffer_is_zero with virtiofsd
meson.build | 4 ++-- util/meson.build | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
2.26.3
PATCH 1/2 meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled
When not explicitly select a sysemu target and building virtiofsd, the seccomp/cap-ng libraries are not resolved, leading to this error:
$ configure --target-list=i386-linux-user --disable-tools --enable-virtiofsd tools/meson.build:12:6: ERROR: Problem encountered: virtiofsd requires libcap-ng-devel and seccomp-devel
Fix by checking the seccomp/cap-ng libraries if virtiofsd is built.
--- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
meson.build +2 -2
@@ -393,14 +393,14 @@ endif seccomp = not_found -if not get_option('seccomp').auto() or have_system or have_tools +if not get_option('seccomp').auto() or have_system or have_tools or not get_option('virtiofsd').auto() seccomp = dependency('libseccomp', version: '>=2.3.0', required: get_option('seccomp'), method: 'pkg-config', kwargs: static_kwargs) endif libcap_ng = not_found -if not get_option('cap_ng').auto() or have_system or have_tools +if not get_option('cap_ng').auto() or have_system or have_tools or not get_option('virtiofsd').auto() libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'], required: get_option('cap_ng'), kwargs: static_kwargs)
Signature · 1 line
2.26.3
Re: [PATCH 1/2] meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled
On Wed, 28 Apr 2021 at 15:55, Philippe Mathieu-Daudé <[email protected]> wrote:
(cc'ing Paolo for a meson.build question below...)
Quoted 25 lines
When not explicitly select a sysemu target and building virtiofsd, the seccomp/cap-ng libraries are not resolved, leading to this error:
$ configure --target-list=i386-linux-user --disable-tools --enable-virtiofsd tools/meson.build:12:6: ERROR: Problem encountered: virtiofsd requires libcap-ng-devel and seccomp-develFix by checking the seccomp/cap-ng libraries if virtiofsd is built.
Reported-by Mahmoud Mandour <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)meson.build +1
-1@@ -393,14 +393,14 @@ endif seccomp = not_found -if not get_option('seccomp').auto() or have_system or have_tools +if not get_option('seccomp').auto() or have_system or have_tools or not get_option('virtiofsd').auto() seccomp = dependency('libseccomp', version: '>=2.3.0',
meson.build line 406
Quoted 10 lines
meson.build +1
-1required: get_option('seccomp'), method: 'pkg-config', kwargs: static_kwargs) endif libcap_ng = not_found -if not get_option('cap_ng').auto() or have_system or have_tools +if not get_option('cap_ng').auto() or have_system or have_tools or not get_option('virtiofsd').auto() libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'], required: get_option('cap_ng'), kwargs: static_kwargs)
Now we have "virtiofsd requires cap-ng and seccomp" recorded in three places in different meson.build files:
* here, if this patch goes in
* in tools/meson.build, in its logic for setting have_virtiofsd (I generously do not count the "decide which error message to print" logic in that file as a separate item in this list...)
* in tools/virtiofsd/meson.build, where the executable('virtiofsd', ...) lists them in its dependencies: setting
Is there some way to avoid this duplication?
thanks
-- PMM
Re: [PATCH 1/2] meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled
Quoted 49 lines · Peter Maydell
On Wed, 28 Apr 2021 at 15:55, Philippe Mathieu-Daudé <[email protected]> wrote:
(cc'ing Paolo for a meson.build question below...)
Quoted 25 lines
When not explicitly select a sysemu target and building virtiofsd, the seccomp/cap-ng libraries are not resolved, leading to this error:
$ configure --target-list=i386-linux-user --disable-tools --enable-virtiofsd tools/meson.build:12:6: ERROR: Problem encountered: virtiofsd requires libcap-ng-devel and seccomp-develFix by checking the seccomp/cap-ng libraries if virtiofsd is built.
Reported-by Mahmoud Mandour <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)meson.build +1
-1@@ -393,14 +393,14 @@ endif seccomp = not_found -if not get_option('seccomp').auto() or have_system or have_tools +if not get_option('seccomp').auto() or have_system or have_tools or not get_option('virtiofsd').auto() seccomp = dependency('libseccomp', version: '>=2.3.0',meson.build line 406
Quoted 10 lines
meson.build +1
-1required: get_option('seccomp'), method: 'pkg-config', kwargs: static_kwargs) endif libcap_ng = not_found -if not get_option('cap_ng').auto() or have_system or have_tools +if not get_option('cap_ng').auto() or have_system or have_tools or not get_option('virtiofsd').auto() libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'], required: get_option('cap_ng'), kwargs: static_kwargs)Now we have "virtiofsd requires cap-ng and seccomp" recorded in three places in different meson.build files:
* here, if this patch goes in
* intools/meson.build, in its logic for settinghave_virtiofsd(I generously do not count the "decide which error message to print" logic in that file as a separate item in this list...)
* intools/virtiofsd/meson.build, where theexecutable('virtiofsd', ...)lists them in its dependencies: setting
Quoted 1 line
Is there some way to avoid this duplication?
I noticed that too, I think the problem is we never considered the case of a standalone binary buildable without sysemu / tools, such virtiofsd.
TIL virtiofsd is not a tool, so tools/meson.build needs rework, in particular to remove the 'have_tools' but maybe to move it out of tools/:
have_virtiofsd = (targetos == 'linux' and
have_tools and
seccomp.found() and
libcap_ng.found() and
'CONFIG_VHOST_USER' in config_host)
If virtiofsd requires Linux, shouldn't we check it directly in ./configure, not allowing --enable-virtiofsd on non-linux hosts?
Maybe it is there for cross-compilation... Is it supported to cross-build it on non-Linux hosts?
It could be clearer to use:
want_virtiofsd = get_option('virtiofsd').auto()
BTW to test I used:
$ configure --target-list=i386-linux-user --disable-tools --enable-virtiofsd $ ninja tools/virtiofsd/virtiofsd
Re: [PATCH 1/2] meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled
In reply to Philippe Mathieu-Daudémeson.build line 399
Quoted 6 lines · Philippe Mathieu-Daudé
seccomp =
not_foundmeson.build +1
-1-if not get_option('seccomp').auto() or have_system or have_tools +if not get_option('seccomp').auto() or have_system or have_tools or not get_option('virtiofsd').auto() seccomp = dependency('libseccomp', version: '>=2.3.0', required: get_option('seccomp'), method: 'pkg-config', kwargs: static_kwargs)
This construct is wrong, both before and after, as I read it.
not get_option(foo).auto() is true for both enabled and disabled. If disabled, why are we examining the dependency? If auto, if we have all of the dependencies we want to enable the feature -- if we don't probe for the dependency, how can we enable it?
This error seems to be offset by the OR have_* tests, for which the logic also seems off.
I think the test should have been
if (have_system or have_tools) and
(not get_option('seccomp').disabled() or
not get_option('virtiofsd').disabled())
Then we need to combine the required: argument, probably like
required: get_option('seccomp').enabled() or
get_option('virtiofsd').enabled()
r~
Re: [PATCH 1/2] meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled
Quoted 16 lines · Richard Henderson
Quoted 7 lines · Philippe Mathieu-Daudé
seccomp =
not_found(quoted diff) +1
-1-if not get_option('seccomp').auto() or have_system or have_tools +if not get_option('seccomp').auto() or have_system or have_tools ornot get_option('virtiofsd').auto()
seccomp = dependency('libseccomp', version: '>=2.3.0',
required:get_option('seccomp'),
method: 'pkg-config', kwargs:static_kwargs)This construct is wrong, both before and after, as I read it.
not get_option(foo).auto() is true for both enabled and disabled. If disabled, why are we examining the dependency? If auto, if we have all of the dependencies we want to enable the feature -- if we don't probe for the dependency, how can we enable it?
Quoted 6 lines
This error seems to be offset by the OR have_* tests, for which the logic also seems off.
I think the test should have been
if (
have_systemorhave_tools) and
Yes but virtiofsd is not a tool... It is a standalone binary. Maybe have_system is the culprit here:
have_system = have_system or target.endswith('-softmmu')
We should somewhere add:
have_system = have_system or something('virtiofsd')
However I wonder if we aren't going to build many objects that are irrelevant for virtiofsd.
Quoted 11 lines
(not get_option('seccomp').disabled() or
not get_option('virtiofsd').disabled())Then we need to combine the required: argument, probably like
required: get_option('seccomp').enabled() or
get_option('virtiofsd').enabled()r~
Re: [PATCH 1/2] meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Richard Henderson
I think the test should have been
if (
have_systemorhave_tools) andYes but virtiofsd is not a tool... It is a standalone binary.
This is not a distinction that our build/configure system currently makes. We have three categories:
* user-mode emulator binaries
* system-mode emulator binaries
* tools
where essentially a "tool" is "any binary we build that isn't a QEMU binary proper".
If virtiofsd is genuinely not related to QEMU at all, what is it doing in our source tree ?
thanks
-- PMM
Re: [PATCH 1/2] meson: Check for seccomp/cap-ng libraries if virtiofsd is enabled
In reply to Philippe Mathieu-DaudéQuoted 24 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Richard Henderson
Quoted 7 lines · Philippe Mathieu-Daudé
seccomp =
not_found(quoted diff) +1
-1-if not get_option('seccomp').auto() or have_system or have_tools +if not get_option('seccomp').auto() or have_system or have_tools ornot get_option('virtiofsd').auto()
seccomp = dependency('libseccomp', version: '>=2.3.0',
required:get_option('seccomp'),
method: 'pkg-config', kwargs:static_kwargs)This construct is wrong, both before and after, as I read it.
not get_option(foo).auto() is true for both enabled and disabled. If disabled, why are we examining the dependency? If auto, if we have all of the dependencies we want to enable the feature -- if we don't probe for the dependency, how can we enable it?
Quoted 6 lines
This error seems to be offset by the OR have_* tests, for which the logic also seems off.
I think the test should have been
if (
have_systemorhave_tools) and
Quoted 8 lines
Yes but virtiofsd is not a tool... It is a standalone binary. Maybe
have_systemis the culprit here:
have_system=have_systemortarget.endswith('-softmmu')We should somewhere add:
have_system=have_systemor something('virtiofsd')
So this hunk does fix the issue ...:
-- >8 --
meson.build +2 -0
@@ -52,4 +52,5 @@ endforeach have_tools = 'CONFIG_TOOLS' in config_host +# virtiofsd depends on sysemu +have_system = have_system or not get_option('virtiofsd').disabled() have_block = have_system or have_tools
---
Quoted 2 lines
However I wonder if we aren't going to build many objects that are irrelevant for virtiofsd.
Based on top of
https://www.mail-archive.com/[email protected]/msg799069.html
to remove libsoftfloat, 216 objects are required to build virtiofsd:
[216/216] Linking target tools/virtiofsd/virtiofsd
This one-line fix seems good enough (to keep virtiofsd as a 'tool').
PATCH 2/2 util/meson: Build iov/hexdump/buffer_is_zero with virtiofsd
In reply to Philippe Mathieu-DaudéWhen not explicitly select a sysemu target or the QEMU tools and building virtiofsd, libqemuutil.a has missing symbols:
/usr/bin/ld: tools/virtiofsd/virtiofsd.p/fuse_virtio.c.o: in function `virtio_send_msg':
tools/virtiofsd/fuse_virtio.c:236: undefined reference to `iov_size'
/usr/bin/ld: libqemuutil.a(util_iov.c.o): in function `iov_hexdump':
util/iov.c:240: undefined reference to `qemu_hexdump'
/usr/bin/ld: libqemuutil.a(util_iov.c.o): in function `qemu_iovec_is_zero':
util/iov.c:494: undefined reference to `buffer_is_zero'
Fix by linking bufferiszero/hexdump/iov objects when building virtiofsd (regardless of sysemu / tools).
--- util/meson.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
util/meson.build +7 -3
@@ -59,12 +59,10 @@ util_ss.add(files('aiocb.c', 'async.c', 'aio-wait.c')) util_ss.add(files('base64.c')) util_ss.add(files('buffer.c')) - util_ss.add(files('bufferiszero.c')) util_ss.add(files('coroutine-@[email protected]'.format(config_host['CONFIG_COROUTINE_BACKEND']))) util_ss.add(files('hbitmap.c')) - util_ss.add(files('hexdump.c')) util_ss.add(files('iova-tree.c')) - util_ss.add(files('iov.c', 'qemu-sockets.c', 'uri.c')) + util_ss.add(files('qemu-sockets.c', 'uri.c')) util_ss.add(files('lockcnt.c')) util_ss.add(files('main-loop.c')) util_ss.add(files('nvdimm-utils.c'))
@@ -83,3 +81,9 @@ if_false: files('filemonitor-stub.c')) util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c')) endif + +if have_block or config_host.has_key('CONFIG_VHOST_USER_FS') + util_ss.add(files('hexdump.c')) + util_ss.add(files('bufferiszero.c')) + util_ss.add(files('iov.c')) +endif
Signature · 1 line
2.26.3
Re: [PATCH 2/2] util/meson: Build iov/hexdump/buffer_is_zero with virtiofsd
Quoted 39 lines · Philippe Mathieu-Daudé
When not explicitly select a sysemu target or the QEMU tools and building virtiofsd, libqemuutil.a has missing symbols:
/usr/bin/ld:tools/virtiofsd/virtiofsd.p/fuse_virtio.c.o: in function `virtio_send_msg':
tools/virtiofsd/fuse_virtio.c:236: undefined reference to `iov_size'
/usr/bin/ld:libqemuutil.a(util_iov.c.o): in function `iov_hexdump':
util/iov.c:240: undefined reference to `qemu_hexdump'
/usr/bin/ld:libqemuutil.a(util_iov.c.o): in function `qemu_iovec_is_zero':
util/iov.c:494: undefined reference to `buffer_is_zero'Fix by linking bufferiszero/hexdump/iov objects when building virtiofsd (regardless of sysemu / tools).
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- util/meson.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)util/meson.build +1
-3@@ -59,12 +59,10 @@ util_ss.add(files('aiocb.c', 'async.c', 'aio-wait.c')) util_ss.add(files('base64.c')) util_ss.add(files('buffer.c')) - util_ss.add(files('bufferiszero.c')) util_ss.add(files('coroutine-@[email protected]'.format(config_host['CONFIG_COROUTINE_BACKEND']))) util_ss.add(files('hbitmap.c')) - util_ss.add(files('hexdump.c')) util_ss.add(files('iova-tree.c')) - util_ss.add(files('iov.c', 'qemu-sockets.c', 'uri.c')) + util_ss.add(files('qemu-sockets.c', 'uri.c')) util_ss.add(files('lockcnt.c')) util_ss.add(files('main-loop.c')) util_ss.add(files('nvdimm-utils.c'))
util/meson.build line 87
Quoted 7 lines
util/meson.build +4
-0@@ -83,3 +81,9 @@ if_false: files('filemonitor-stub.c')) util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c')) endif + +if have_block or config_host.has_key('CONFIG_VHOST_USER_FS') + util_ss.add(files('hexdump.c')) + util_ss.add(files('bufferiszero.c'))
Doh it isn't sorted :/ and maybe better subject:
"Build virtiofsd with iov/hexdump/buffer_is_zero objects"?
Quoted 3 lines
util/meson.build +2
-0+ util_ss.add(files('iov.c')) +endif
Re: [PATCH 2/2] util/meson: Build iov/hexdump/buffer_is_zero with virtiofsd
In reply to Philippe Mathieu-DaudéQuoted 19 lines · Philippe Mathieu-Daudé
util/meson.build +1
-3@@ -59,12 +59,10 @@ util_ss.add(files('aiocb.c', 'async.c', 'aio-wait.c')) util_ss.add(files('base64.c')) util_ss.add(files('buffer.c')) - util_ss.add(files('bufferiszero.c')) util_ss.add(files('coroutine-@[email protected]'.format(config_host['CONFIG_COROUTINE_BACKEND']))) util_ss.add(files('hbitmap.c')) - util_ss.add(files('hexdump.c')) util_ss.add(files('iova-tree.c')) - util_ss.add(files('iov.c', 'qemu-sockets.c', 'uri.c')) + util_ss.add(files('qemu-sockets.c', 'uri.c')) util_ss.add(files('lockcnt.c')) util_ss.add(files('main-loop.c')) util_ss.add(files('nvdimm-utils.c'))
util/meson.build line 89
Quoted 9 lines
util/meson.build +6
-0@@ -83,3 +81,9 @@ if_false: files('filemonitor-stub.c')) util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c')) endif + +if have_block or config_host.has_key('CONFIG_VHOST_USER_FS') + util_ss.add(files('hexdump.c')) + util_ss.add(files('bufferiszero.c')) + util_ss.add(files('iov.c')) +endif
Isn't util a static library, built once? Why are we avoiding building these unconditionally? Surely symbols will be included in any linked binaries only as needed.
r~
Re: [PATCH 2/2] util/meson: Build iov/hexdump/buffer_is_zero with virtiofsd
Quoted 28 lines · Richard Henderson
Quoted 27 lines · Philippe Mathieu-Daudé
util/meson.build +0
-1@@ -59,12 +59,10 @@ util_ss.add(files('aiocb.c', 'async.c', 'aio-wait.c')) util_ss.add(files('base64.c')) util_ss.add(files('buffer.c')) - util_ss.add(files('bufferiszero.c'))util_ss.add(files('coroutine-@[email protected]'.format(config_host['CONFIG_COROUTINE_BACKEND'])))
util_ss.add(files('hbitmap.c'))
- util_ss.add(files('hexdump.c')) util_ss.add(files('iova-tree.c'))
-util_ss.add(files('iov.c', 'qemu-sockets.c', 'uri.c'))+util_ss.add(files('qemu-sockets.c', 'uri.c'))util_ss.add(files('lockcnt.c')) util_ss.add(files('main-loop.c')) util_ss.add(files('nvdimm-utils.c'))util/meson.build +0
-0@@ -83,3 +81,9 @@
if_false:
files('filemonitor-stub.c'))
util_ss.add(when: 'CONFIG_LINUX', if_true: files('vfio-helpers.c'))endifutil/meson.build +2
-0+ +if have_block or config_host.has_key('CONFIG_VHOST_USER_FS')
Quoted 8 lines
Quoted 4 lines
+ util_ss.add(files('hexdump.c'))
+ util_ss.add(files('bufferiszero.c'))
+ util_ss.add(files('iov.c'))
+endifIsn't util a static library, built once? Why are we avoiding building these unconditionally? Surely symbols will be included in any linked binaries only as needed.
Yes, in this case built once for $ configure --target-list=i386-linux-user --disable-tools --enable-virtiofsd.
Are you suggesting to remove the 'if have_block' check? This makes build a the files pointlessly for user-mode-only builds...
Re: [PATCH 2/2] util/meson: Build iov/hexdump/buffer_is_zero with virtiofsd
Quoted 2 lines · Philippe Mathieu-Daudé
Are you suggesting to remove the 'if
have_block' check? This makes build a the files pointlessly for user-mode-only builds...
But since the objects are not included in the binary, I don't care.
The build system is already too complex, and building a couple of extra small files makes only milliseconds of difference.
r~
Re: [PATCH 2/2] util/meson: Build iov/hexdump/buffer_is_zero with virtiofsd
Quoted 8 lines · Richard Henderson
Quoted 2 lines · Philippe Mathieu-Daudé
Are you suggesting to remove the 'if
have_block' check? This makes build a the files pointlessly for user-mode-only builds...But since the objects are not included in the binary, I don't care.
The build system is already too complex, and building a couple of extra small files makes only milliseconds of difference.
Maybe for libqemuutil.a (this does make a difference with the Python QAPI generated files - another series).
I'll wait if we get to a consensus about what exactly is virtiofsd, then revisit this series.
Thanks!
Phil.
Quoted 4 lines · Philippe Mathieu-Daudé
A pair of fixes to allow building virtiofsd without sysemu/tools.
Should this configuration be tested in CI?
Does the configuration make sense to support? I thought virtiofsd was only of use with system emulation ?
thanks
-- PMM
Quoted 8 lines · * Peter Maydell ([email protected]) wrote:
Quoted 4 lines · Philippe Mathieu-Daudé
A pair of fixes to allow building virtiofsd without sysemu/tools.
Should this configuration be tested in CI?
Does the configuration make sense to support? I thought virtiofsd was only of use with system emulation ?
It probably is; although arguably it makes sense to build virtiofsd by itself without either emulation.
Dave
Quoted 3 lines
thanks
-- PMM
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK