[PATCH] build: add detection of xdrproc_t arguments count
According to 9fa3a8ab6fd82ad2f5a14b490696085061418718, macOS insists on passing 3 arguments for xdrproc_t. Passing 3 arguments was a good common ground, but since recently[1] FreeBSD only accepts 2 arguments. Add a meson.build check whether 3 arguments are accepted, and add macros which passes either 2 or 3 arguments to xdrproc_t based on the result of this check. 1: https://cgit.freebsd.org/src/commit/?id=ac5a19ec6989675c8ec6c3ca245dba243d1a... Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- meson.build | 19 +++++++++++++++++++ scripts/rpcgen/tests/test_demo.c | 12 +++++++++--- src/rpc/virnetmessage.c | 10 ++++++++-- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 964d1fa4e1..4a4f89c1cb 100644 --- a/meson.build +++ b/meson.build @@ -893,6 +893,25 @@ else xdr_dep = dependency('', required: false) endif +if xdr_dep.found() + xdrproc_3arg_code = ''' + #include <rpc/xdr.h> + + bool_t test_filter(XDR *xdr, void *data, unsigned int opaque_flags) { + return TRUE; + } + + int main() { + XDR xdr; + xdrproc_t filter = (xdrproc_t)&test_filter; + (*filter)(&xdr, NULL, 0); + return 0; + } + ''' + if cc.compiles(xdrproc_3arg_code, dependencies: xdr_dep) + conf.set('XDRPROC_T_3ARGS', 1) + endif +endif # generic build dependencies diff --git a/scripts/rpcgen/tests/test_demo.c b/scripts/rpcgen/tests/test_demo.c index e6ba7ddbc5..82eda89592 100644 --- a/scripts/rpcgen/tests/test_demo.c +++ b/scripts/rpcgen/tests/test_demo.c @@ -8,6 +8,12 @@ # define xdr_uint64_t xdr_u_int64_t #endif +#if defined(XDRPROC_T_3ARGS) +# define XDRPROC(proc, xdr, data) (proc(&xdr, data, 0)) +#else +# define XDRPROC(proc, xdr, data) (proc(&xdr, data)) +#endif + #include "demo.h" #include "demo.c" @@ -27,7 +33,7 @@ static void test_xdr(xdrproc_t proc, void *vorig, void *vnew, const char *testna /* Step 1: serialize the vorig and compare to the data in test .bin files */ xdrmem_create(&xdr, buf, buflen, XDR_ENCODE); - ret = !!proc(&xdr, vorig, 0); + ret = !!XDRPROC(proc, xdr, vorig); g_assert_cmpint(ret, ==, !fail); if (fail) @@ -54,7 +60,7 @@ static void test_xdr(xdrproc_t proc, void *vorig, void *vnew, const char *testna /* Step 2: de-serialize the state to create a new object */ xdrmem_create(&xdr, buf, buflen, XDR_DECODE); - ret = !!proc(&xdr, vnew, 0); + ret = !!XDRPROC(proc, xdr, vnew); g_assert_cmpint(ret, ==, true); actlen = xdr_getpos(&xdr); @@ -68,7 +74,7 @@ static void test_xdr(xdrproc_t proc, void *vorig, void *vnew, const char *testna xdrmem_create(&xdr, buf, buflen, XDR_ENCODE); - ret = !!proc(&xdr, vnew, 0); + ret = !!XDRPROC(proc, xdr, vnew); g_assert_cmpint(ret, ==, true); actlen = xdr_getpos(&xdr); diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c index af0f9cb30b..e66df5c9e2 100644 --- a/src/rpc/virnetmessage.c +++ b/src/rpc/virnetmessage.c @@ -34,6 +34,12 @@ VIR_LOG_INIT("rpc.netmessage"); +#if defined(XDRPROC_T_3ARGS) +# define XDRPROC_FILTER(filter, xdr, data) ((*filter)(&xdr, data, 0)) +#else +# define XDRPROC_FILTER(filter, xdr, data) ((*filter)(&xdr, data)) +#endif + virNetMessage *virNetMessageNew(bool tracked) { virNetMessage *msg; @@ -367,7 +373,7 @@ int virNetMessageEncodePayload(virNetMessage *msg, msg->bufferLength - msg->bufferOffset, XDR_ENCODE); /* Try to encode the payload. If the buffer is too small increase it. */ - while (!(*filter)(&xdr, data, 0)) { + while (!XDRPROC_FILTER(*filter, xdr, data)) { unsigned int newlen = msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX; newlen *= 2; @@ -424,7 +430,7 @@ int virNetMessageDecodePayload(virNetMessage *msg, xdrmem_create(&xdr, msg->buffer + msg->bufferOffset, msg->bufferLength - msg->bufferOffset, XDR_DECODE); - if (!(*filter)(&xdr, data, 0)) { + if (!XDRPROC_FILTER(*filter, xdr, data)) { virReportError(VIR_ERR_RPC, "%s", _("Unable to decode message payload")); goto error; } -- 2.52.0
On 1/31/26 11:43, Roman Bogorodskiy wrote:
According to 9fa3a8ab6fd82ad2f5a14b490696085061418718, macOS insists on passing 3 arguments for xdrproc_t.
Passing 3 arguments was a good common ground, but since recently[1] FreeBSD only accepts 2 arguments.
Add a meson.build check whether 3 arguments are accepted, and add macros which passes either 2 or 3 arguments to xdrproc_t based on the result of this check.
1: https://cgit.freebsd.org/src/commit/?id=ac5a19ec6989675c8ec6c3ca245dba243d1a...
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- meson.build | 19 +++++++++++++++++++ scripts/rpcgen/tests/test_demo.c | 12 +++++++++--- src/rpc/virnetmessage.c | 10 ++++++++-- 3 files changed, 36 insertions(+), 5 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
Michal Prívozník wrote:
On 1/31/26 11:43, Roman Bogorodskiy wrote:
According to 9fa3a8ab6fd82ad2f5a14b490696085061418718, macOS insists on passing 3 arguments for xdrproc_t.
Passing 3 arguments was a good common ground, but since recently[1] FreeBSD only accepts 2 arguments.
Add a meson.build check whether 3 arguments are accepted, and add macros which passes either 2 or 3 arguments to xdrproc_t based on the result of this check.
1: https://cgit.freebsd.org/src/commit/?id=ac5a19ec6989675c8ec6c3ca245dba243d1a...
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- meson.build | 19 +++++++++++++++++++ scripts/rpcgen/tests/test_demo.c | 12 +++++++++--- src/rpc/virnetmessage.c | 10 ++++++++-- 3 files changed, 36 insertions(+), 5 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Michal
Looks like this broke aarch64-macos-14. I think it also needs this: --- a/meson.build +++ b/meson.build @@ -896,6 +896,7 @@ endif if xdr_dep.found() xdrproc_3arg_code = ''' + #include <rpc/types.h> #include <rpc/xdr.h> bool_t test_filter(XDR *xdr, void *data, unsigned int opaque_flags) { I wonder though if it's possible to somehow trigger aarch64-macos-14 on feature branches because I don't seem to see that in my pipelines. Roman
On Mon, Feb 02, 2026 at 20:27:36 +0100, Roman Bogorodskiy wrote:
Michal Prívozník wrote:
[...]
Looks like this broke aarch64-macos-14.
I think it also needs this:
--- a/meson.build +++ b/meson.build @@ -896,6 +896,7 @@ endif
if xdr_dep.found() xdrproc_3arg_code = ''' + #include <rpc/types.h> #include <rpc/xdr.h>
bool_t test_filter(XDR *xdr, void *data, unsigned int opaque_flags) {
I wonder though if it's possible to somehow trigger aarch64-macos-14 on feature branches because I don't seem to see that in my pipelines.
You should be able to setup cirrus for yourself. The steps I've followed the rather long time ago I've set it up are documented in ci/README.rst You then push into your clone with: git push -o ci.variable=RUN_PIPELINE_UPSTREAM_ENV=1 to trigger all pipeline jobs.
On Mon, Feb 02, 2026 at 08:39:32PM +0100, Peter Krempa via Devel wrote:
On Mon, Feb 02, 2026 at 20:27:36 +0100, Roman Bogorodskiy wrote:
Michal Prívozník wrote:
[...]
Looks like this broke aarch64-macos-14.
I think it also needs this:
--- a/meson.build +++ b/meson.build @@ -896,6 +896,7 @@ endif
if xdr_dep.found() xdrproc_3arg_code = ''' + #include <rpc/types.h> #include <rpc/xdr.h>
bool_t test_filter(XDR *xdr, void *data, unsigned int opaque_flags) {
I wonder though if it's possible to somehow trigger aarch64-macos-14 on feature branches because I don't seem to see that in my pipelines.
You should be able to setup cirrus for yourself. The steps I've followed the rather long time ago I've set it up are documented in ci/README.rst
You then push into your clone with:
git push -o ci.variable=RUN_PIPELINE_UPSTREAM_ENV=1
Just RUN_PIPELINE=1 generally - RUN_PIPELINE_UPSTREAM_ENV=1 uses cached upstream containers that might not match your branch requirements. 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 :|
Daniel P. Berrangé wrote:
On Mon, Feb 02, 2026 at 08:39:32PM +0100, Peter Krempa via Devel wrote:
On Mon, Feb 02, 2026 at 20:27:36 +0100, Roman Bogorodskiy wrote:
Michal Prívozník wrote:
[...]
Looks like this broke aarch64-macos-14.
I think it also needs this:
--- a/meson.build +++ b/meson.build @@ -896,6 +896,7 @@ endif
if xdr_dep.found() xdrproc_3arg_code = ''' + #include <rpc/types.h> #include <rpc/xdr.h>
bool_t test_filter(XDR *xdr, void *data, unsigned int opaque_flags) {
I wonder though if it's possible to somehow trigger aarch64-macos-14 on feature branches because I don't seem to see that in my pipelines.
You should be able to setup cirrus for yourself. The steps I've followed the rather long time ago I've set it up are documented in ci/README.rst
You then push into your clone with:
git push -o ci.variable=RUN_PIPELINE_UPSTREAM_ENV=1
Just RUN_PIPELINE=1 generally - RUN_PIPELINE_UPSTREAM_ENV=1 uses cached upstream containers that might not match your branch requirements.
With regards, Daniel
Yeah, that's what I've been using for quite some time as well for pre-review / pre-push checks. E.g. for this specific push I used: https://gitlab.com/rbogorodskiy/libvirt/-/pipelines/2301366479 The thing is that the job list does not include aarch64-macos-14. This one was started using -o ci.variable=RUN_PIPELINE=1. I tried -o ci.variable=RUN_PIPELINE_UPSTREAM_ENV=1, but it does not seem to include aarch64-macos-14 also: https://gitlab.com/rbogorodskiy/libvirt/-/pipelines/2301537047
On Mon, Feb 02, 2026 at 09:02:29PM +0100, Roman Bogorodskiy wrote:
Daniel P. Berrangé wrote:
On Mon, Feb 02, 2026 at 08:39:32PM +0100, Peter Krempa via Devel wrote:
On Mon, Feb 02, 2026 at 20:27:36 +0100, Roman Bogorodskiy wrote:
Michal Prívozník wrote:
[...]
Looks like this broke aarch64-macos-14.
I think it also needs this:
--- a/meson.build +++ b/meson.build @@ -896,6 +896,7 @@ endif
if xdr_dep.found() xdrproc_3arg_code = ''' + #include <rpc/types.h> #include <rpc/xdr.h>
bool_t test_filter(XDR *xdr, void *data, unsigned int opaque_flags) {
I wonder though if it's possible to somehow trigger aarch64-macos-14 on feature branches because I don't seem to see that in my pipelines.
You should be able to setup cirrus for yourself. The steps I've followed the rather long time ago I've set it up are documented in ci/README.rst
You then push into your clone with:
git push -o ci.variable=RUN_PIPELINE_UPSTREAM_ENV=1
Just RUN_PIPELINE=1 generally - RUN_PIPELINE_UPSTREAM_ENV=1 uses cached upstream containers that might not match your branch requirements.
With regards, Daniel
Yeah, that's what I've been using for quite some time as well for pre-review / pre-push checks.
E.g. for this specific push I used:
https://gitlab.com/rbogorodskiy/libvirt/-/pipelines/2301366479
The thing is that the job list does not include aarch64-macos-14.
Right, the limitation we have is that we can only provide out-of-the-box CI for jobs hosted on gitlab. The FreeBSD and macOS jobs are both hosted on Cirrus CI, with gitlab just being a facade, via 'cirrus-run'. It extra hacky as it also involves a dummy github repo There are instructions for setting up Cirrus CI in ci/README.rst Once that's setup, then cirrus CI jobs get enabled in the pipeline 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 :|
Daniel P. Berrangé wrote:
On Mon, Feb 02, 2026 at 09:02:29PM +0100, Roman Bogorodskiy wrote:
Daniel P. Berrangé wrote:
On Mon, Feb 02, 2026 at 08:39:32PM +0100, Peter Krempa via Devel wrote:
On Mon, Feb 02, 2026 at 20:27:36 +0100, Roman Bogorodskiy wrote:
Michal Prívozník wrote:
[...]
Looks like this broke aarch64-macos-14.
I think it also needs this:
--- a/meson.build +++ b/meson.build @@ -896,6 +896,7 @@ endif
if xdr_dep.found() xdrproc_3arg_code = ''' + #include <rpc/types.h> #include <rpc/xdr.h>
bool_t test_filter(XDR *xdr, void *data, unsigned int opaque_flags) {
I wonder though if it's possible to somehow trigger aarch64-macos-14 on feature branches because I don't seem to see that in my pipelines.
You should be able to setup cirrus for yourself. The steps I've followed the rather long time ago I've set it up are documented in ci/README.rst
You then push into your clone with:
git push -o ci.variable=RUN_PIPELINE_UPSTREAM_ENV=1
Just RUN_PIPELINE=1 generally - RUN_PIPELINE_UPSTREAM_ENV=1 uses cached upstream containers that might not match your branch requirements.
With regards, Daniel
Yeah, that's what I've been using for quite some time as well for pre-review / pre-push checks.
E.g. for this specific push I used:
https://gitlab.com/rbogorodskiy/libvirt/-/pipelines/2301366479
The thing is that the job list does not include aarch64-macos-14.
Right, the limitation we have is that we can only provide out-of-the-box CI for jobs hosted on gitlab.
The FreeBSD and macOS jobs are both hosted on Cirrus CI, with gitlab just being a facade, via 'cirrus-run'. It extra hacky as it also involves a dummy github repo
There are instructions for setting up Cirrus CI in ci/README.rst
Once that's setup, then cirrus CI jobs get enabled in the pipeline
I got it working, thanks!
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 :|
participants (4)
-
Daniel P. Berrangé -
Michal Prívozník -
Peter Krempa -
Roman Bogorodskiy