[libvirt PATCH 0/3] RFC: fix compilation on msys2

From: Marc-André Lureau <marcandre.lureau@redhat.com> Hi, libvirt fails to compile on msys2/win32. Here is a few patches that solve it, but the way python scripts are being handled in general is a bit odd, so this is RFC. (fwiw, a lot of tests fail though, I can send the log if anyone is interested - or attach it to a gitlab issue) Fixes: https://gitlab.com/libvirt/libvirt/-/issues/453 Marc-André Lureau (3): meson: don't look for unix paths on win32 meson: drop explicit python interpreter rpc/ssh: ssh_userauth_agent() is not supported on win32 docs/manpages/meson.build | 4 ++-- docs/meson.build | 6 ++---- meson.build | 14 +++++++++----- src/admin/meson.build | 4 ++-- src/esx/meson.build | 4 ++-- src/hyperv/meson.build | 2 +- src/meson.build | 8 ++++---- src/rpc/virnetlibsshsession.c | 14 ++++++++++++-- src/util/meson.build | 4 ++-- 9 files changed, 36 insertions(+), 24 deletions(-) -- 2.39.2

From: Marc-André Lureau <marcandre.lureau@redhat.com> Or meson will complain with: ../meson.build:770:2: ERROR: Search directory /sbin is not an absolute path. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- meson.build | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 47ec7fcb74..f7f31a278d 100644 --- a/meson.build +++ b/meson.build @@ -742,11 +742,15 @@ conf.set('SIZEOF_LONG', cc.sizeof('long')) # Where we look for daemons and admin binaries during configure -libvirt_sbin_path = [ - '/sbin', - '/usr/sbin', - '/usr/local/sbin', -] +libvirt_sbin_path = [] + +if host_machine.system() != 'windows' + libvirt_sbin_path += [ + '/sbin', + '/usr/sbin', + '/usr/local/sbin', + ] +endif # required programs check -- 2.39.2

From: Marc-André Lureau <marcandre.lureau@redhat.com> meson wraps python scripts already on win32, so we end up with these failing commands: [1/359] "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1" FAILED: src/util/virkeycodetable_atset1.h "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1" If LC_ALL, LANG and LC_CTYPE need to be set, it would probably be better to use a meson environment() instead. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- docs/manpages/meson.build | 4 ++-- docs/meson.build | 6 ++---- src/admin/meson.build | 4 ++-- src/esx/meson.build | 4 ++-- src/hyperv/meson.build | 2 +- src/meson.build | 8 ++++---- src/util/meson.build | 4 ++-- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build index 84b2e247e9..afcadaefbd 100644 --- a/docs/manpages/meson.build +++ b/docs/manpages/meson.build @@ -49,7 +49,7 @@ foreach name : keycode_list input: keymap_src_file, output: 'virkeycode-@0@.rst'.format(name), command: [ - meson_python_prog, python3_prog, keymap_gen_prog, 'code-docs', + keymap_gen_prog, 'code-docs', '--lang', 'rst', '--title', 'virkeycode-@0@'.format(name), '--subtitle', 'Key code values for @0@'.format(name), @@ -70,7 +70,7 @@ foreach name : keyname_list input: keymap_src_file, output: 'virkeyname-@0@.rst'.format(name), command: [ - meson_python_prog, python3_prog, keymap_gen_prog, 'name-docs', + keymap_gen_prog, 'name-docs', '--lang', 'rst', '--title', 'virkeyname-@0@'.format(name), '--subtitle', 'Key name values for @0@'.format(name), diff --git a/docs/meson.build b/docs/meson.build index 8f84d08912..769efe7b6a 100644 --- a/docs/meson.build +++ b/docs/meson.build @@ -123,7 +123,7 @@ aclperms_gen = custom_target( input: access_perm_h, output: 'aclperms.htmlinc', command: [ - meson_python_prog, python3_prog, genaclperms_prog, '@INPUT@', + genaclperms_prog, '@INPUT@', ], capture: true, ) @@ -145,7 +145,7 @@ docs_api_generated = custom_target( 'libvirt-admin-api.xml', ], command: [ - meson_python_prog, python3_prog, apibuild_prog, + apibuild_prog, meson.current_source_dir(), meson.current_build_dir(), ], @@ -264,8 +264,6 @@ hvsupport_html_in = custom_target( 'hvsupport.html.in', output: 'hvsupport.html.in', command: [ - meson_python_prog, - python3_prog, hvsupport_prog, meson.project_source_root(), meson.project_build_root(), diff --git a/src/admin/meson.build b/src/admin/meson.build index 692cc128a3..e04d610f92 100644 --- a/src/admin/meson.build +++ b/src/admin/meson.build @@ -68,7 +68,7 @@ libvirt_admin_syms = custom_target( ], output: 'libvirt_admin.syms', command: [ - meson_python_prog, python3_prog, meson_gen_sym_prog, + meson_gen_sym_prog, '@OUTPUT@', 'LIBVIRT_ADMIN_PRIVATE_' + meson.project_version(), '@INPUT@', ], ) @@ -79,7 +79,7 @@ if host_machine.system() == 'windows' input: libvirt_admin_syms, output: 'libvirt_admin.def', command: [ - meson_python_prog, python3_prog, meson_gen_def_prog, + meson_gen_def_prog, '@INPUT@', '@OUTPUT@', ], ) diff --git a/src/esx/meson.build b/src/esx/meson.build index d1f42fdcc4..4bd0dadd51 100644 --- a/src/esx/meson.build +++ b/src/esx/meson.build @@ -25,7 +25,7 @@ esx_gen_headers = custom_target( 'esx_vi_types.generated.typeenum', ], command: [ - meson_python_prog, python3_prog, esx_vi_generator_prog, + esx_vi_generator_prog, meson.project_source_root() / 'src', meson.project_build_root() / 'src', 'header', @@ -46,7 +46,7 @@ esx_gen_sources = custom_target( 'esx_vi_types.generated.typetostring', ], command: [ - meson_python_prog, python3_prog, esx_vi_generator_prog, + esx_vi_generator_prog, meson.project_source_root() / 'src', meson.project_build_root() / 'src', 'source', diff --git a/src/hyperv/meson.build b/src/hyperv/meson.build index 3509ce12f7..446b6ddada 100644 --- a/src/hyperv/meson.build +++ b/src/hyperv/meson.build @@ -17,7 +17,7 @@ hyperv_gen_sources = custom_target( 'hyperv_wmi_classes.generated.typedef', ], command: [ - meson_python_prog, python3_prog, hyperv_wmi_generator_prog, + hyperv_wmi_generator_prog, meson.project_source_root() / 'src', meson.project_build_root() / 'src', ], diff --git a/src/meson.build b/src/meson.build index 35951d8990..ad7796f03d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -350,7 +350,7 @@ libvirt_syms = custom_target( input: [ public_sym_file ] + used_sym_files + generated_sym_files, output: 'libvirt.syms', command: [ - meson_python_prog, python3_prog, meson_gen_sym_prog, + meson_gen_sym_prog, '@OUTPUT@', 'LIBVIRT_PRIVATE_' + meson.project_version(), '@INPUT@', ], ) @@ -361,7 +361,7 @@ if host_machine.system() == 'windows' input: libvirt_syms, output: 'libvirt.def', command: [ - meson_python_prog, python3_prog, meson_gen_def_prog, + meson_gen_def_prog, '@INPUT@', '@OUTPUT@', ], ) @@ -417,7 +417,7 @@ if host_machine.system() == 'windows' input: libvirt_qemu_syms, output: 'libvirt_qemu.def', command: [ - meson_python_prog, python3_prog, meson_gen_def_prog, + meson_gen_def_prog, '@INPUT@', '@OUTPUT@', ], ) @@ -476,7 +476,7 @@ if host_machine.system() == 'windows' input: libvirt_lxc_syms, output: 'libvirt_lxc.def', command: [ - meson_python_prog, python3_prog, meson_gen_def_prog, + meson_gen_def_prog, '@INPUT@', '@OUTPUT@', ], ) diff --git a/src/util/meson.build b/src/util/meson.build index 2fe6f7699e..ace5bb04a5 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -147,7 +147,7 @@ foreach name : keycode_list input: keymap_src_file, output: 'virkeycodetable_@0@.h'.format(name), command: [ - meson_python_prog, python3_prog, keymap_gen_prog, 'code-table', + keymap_gen_prog, 'code-table', '--lang', 'stdc', '--varname', 'virKeyCodeTable_@0@'.format(name), '@INPUT@', name, @@ -162,7 +162,7 @@ foreach name : keyname_list input: keymap_src_file, output: 'virkeynametable_@0@.h'.format(name), command: [ - meson_python_prog, python3_prog, keymap_gen_prog, 'name-table', + keymap_gen_prog, 'name-table', '--lang', 'stdc', '--varname', 'virKeyNameTable_@0@'.format(name), '@INPUT@', name, -- 2.39.2

On 4/6/23 17:58, marcandre.lureau@redhat.com wrote:
From: Marc-André Lureau <marcandre.lureau@redhat.com>
meson wraps python scripts already on win32, so we end up with these failing commands:
[1/359] "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1" FAILED: src/util/virkeycodetable_atset1.h "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1"
If LC_ALL, LANG and LC_CTYPE need to be set, it would probably be better to use a meson environment() instead.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- docs/manpages/meson.build | 4 ++-- docs/meson.build | 6 ++---- src/admin/meson.build | 4 ++-- src/esx/meson.build | 4 ++-- src/hyperv/meson.build | 2 +- src/meson.build | 8 ++++---- src/util/meson.build | 4 ++-- 7 files changed, 15 insertions(+), 17 deletions(-)
After this, there are still some occurrences of meson_python_prog or python3_prog left; mostly in locations which are never built on Windows (e.g. src/qemu/, src/network/ and so on. But is it worth removing them too? Michal

Hi On Tue, Apr 11, 2023 at 11:10 AM Michal Prívozník <mprivozn@redhat.com> wrote:
On 4/6/23 17:58, marcandre.lureau@redhat.com wrote:
From: Marc-André Lureau <marcandre.lureau@redhat.com>
meson wraps python scripts already on win32, so we end up with these failing commands:
[1/359] "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1" FAILED: src/util/virkeycodetable_atset1.h "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1"
If LC_ALL, LANG and LC_CTYPE need to be set, it would probably be better to use a meson environment() instead.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- docs/manpages/meson.build | 4 ++-- docs/meson.build | 6 ++---- src/admin/meson.build | 4 ++-- src/esx/meson.build | 4 ++-- src/hyperv/meson.build | 2 +- src/meson.build | 8 ++++---- src/util/meson.build | 4 ++-- 7 files changed, 15 insertions(+), 17 deletions(-)
After this, there are still some occurrences of meson_python_prog or python3_prog left; mostly in locations which are never built on Windows (e.g. src/qemu/, src/network/ and so on. But is it worth removing them too?
If we don't have a good reason for this extra wrapping, yes. Is gitlab CI covering enough to validate the change? Someone more familiar with libvirt build environments should know better. thanks

On 4/11/23 09:27, Marc-André Lureau wrote:
Hi
On Tue, Apr 11, 2023 at 11:10 AM Michal Prívozník <mprivozn@redhat.com <mailto:mprivozn@redhat.com>> wrote:
On 4/6/23 17:58, marcandre.lureau@redhat.com <mailto:marcandre.lureau@redhat.com> wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com <mailto:marcandre.lureau@redhat.com>> > > meson wraps python scripts already on win32, so we end up with these > failing commands: > > [1/359] "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1" > FAILED: src/util/virkeycodetable_atset1.h > "C:/msys64/ucrt64/bin/meson" "--internal" "exe" "--capture" "src/util/virkeycodetable_atset1.h" "--" "sh" "C:/msys64/home/marca/src/libvirt/scripts/meson-python.sh" "C:/msys64/ucrt64/bin/python3.EXE" "python" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/tools/keymap-gen" "code-table" "--lang" "stdc" "--varname" "virKeyCodeTable_atset1" "C:/msys64/home/marca/src/libvirt/src/keycodemapdb/data/keymaps.csv" "atset1" > > If LC_ALL, LANG and LC_CTYPE need to be set, it would probably be better > to use a meson environment() instead. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com <mailto:marcandre.lureau@redhat.com>> > --- > docs/manpages/meson.build | 4 ++-- > docs/meson.build | 6 ++---- > src/admin/meson.build | 4 ++-- > src/esx/meson.build | 4 ++-- > src/hyperv/meson.build | 2 +- > src/meson.build | 8 ++++---- > src/util/meson.build | 4 ++-- > 7 files changed, 15 insertions(+), 17 deletions(-)
After this, there are still some occurrences of meson_python_prog or python3_prog left; mostly in locations which are never built on Windows (e.g. src/qemu/, src/network/ and so on. But is it worth removing them too?
If we don't have a good reason for this extra wrapping, yes. Is gitlab CI covering enough to validate the change? Someone more familiar with libvirt build environments should know better.
Yeah, good point. Let me run this as-is before pushing it: https://gitlab.com/MichalPrivoznik/libvirt/-/pipelines/833467320 and actually, it breaks the build. Thing is, it looks for scripts in the builddir rather than srcdir: [4/1482] /usr/bin/meson --internal exe --capture src/util/virkeycodetable_atset1.h -- /builds/MichalPrivoznik/libvirt/rpmbuild/BUILD/libvirt-9.3.0/src/keycodemapdb/tools/keymap-gen code-table --lang stdc --varname virKeyCodeTable_atset1 /builds/MichalPrivoznik/libvirt/rpmbuild/BUILD/libvirt-9.3.0/src/keycodemapdb/data/keymaps.csv atset1 But what I don't understand is: why prefixing the script with meson_python_prog and/or python3_prog causes the script to be looked for in the srcdir. Michal

From: Marc-André Lureau <marcandre.lureau@redhat.com> The function does not exist on win32. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- src/rpc/virnetlibsshsession.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index e71a79d0fb..e94b0d7a2e 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -60,7 +60,9 @@ typedef enum { VIR_NET_LIBSSH_AUTH_KEYBOARD_INTERACTIVE, VIR_NET_LIBSSH_AUTH_PASSWORD, VIR_NET_LIBSSH_AUTH_PRIVKEY, - VIR_NET_LIBSSH_AUTH_AGENT +#ifndef WIN32 + VIR_NET_LIBSSH_AUTH_AGENT, +#endif } virNetLibsshAuthMethods; @@ -698,6 +700,7 @@ virNetLibsshAuthenticate(virNetLibsshSession *sess) /* try to authenticate using the keyboard interactive way */ ret = virNetLibsshAuthenticateKeyboardInteractive(sess, auth); break; +#ifndef WIN32 case VIR_NET_LIBSSH_AUTH_AGENT: /* try to authenticate using ssh-agent */ ret = ssh_userauth_agent(sess->session, NULL); @@ -708,6 +711,7 @@ virNetLibsshAuthenticate(virNetLibsshSession *sess) errmsg); } break; +#endif case VIR_NET_LIBSSH_AUTH_PRIVKEY: /* try to authenticate using the provided ssh key */ ret = virNetLibsshAuthenticatePrivkey(sess, auth); @@ -861,8 +865,13 @@ virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSession *sess, } int -virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess) +virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess G_GNUC_UNUSED) { +#ifdef WIN32 + virReportError(VIR_ERR_LIBSSH, "%s", + _("Agent authentication is not supported on this host")); + return -1; +#else virNetLibsshAuthMethod *auth; virObjectLock(sess); @@ -873,6 +882,7 @@ virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess) virObjectUnlock(sess); return 0; +#endif } int -- 2.39.2

On 4/6/23 17:58, marcandre.lureau@redhat.com wrote:
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The function does not exist on win32.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- src/rpc/virnetlibsshsession.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index e71a79d0fb..e94b0d7a2e 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -60,7 +60,9 @@ typedef enum { VIR_NET_LIBSSH_AUTH_KEYBOARD_INTERACTIVE, VIR_NET_LIBSSH_AUTH_PASSWORD, VIR_NET_LIBSSH_AUTH_PRIVKEY, - VIR_NET_LIBSSH_AUTH_AGENT +#ifndef WIN32 + VIR_NET_LIBSSH_AUTH_AGENT, +#endif } virNetLibsshAuthMethods;
I'd just drop this hunk, and ...
@@ -698,6 +700,7 @@ virNetLibsshAuthenticate(virNetLibsshSession *sess) /* try to authenticate using the keyboard interactive way */ ret = virNetLibsshAuthenticateKeyboardInteractive(sess, auth); break; +#ifndef WIN32 case VIR_NET_LIBSSH_AUTH_AGENT: /* try to authenticate using ssh-agent */ ret = ssh_userauth_agent(sess->session, NULL); @@ -708,6 +711,7 @@ virNetLibsshAuthenticate(virNetLibsshSession *sess) errmsg); } break; +#endif
.. here just wrap the actual ssh_userauth_agent() call in ifdnef. The @ret is set to SSH_AUTH_DENIED beforehand, and later in the code a proper error message is reported.
case VIR_NET_LIBSSH_AUTH_PRIVKEY: /* try to authenticate using the provided ssh key */ ret = virNetLibsshAuthenticatePrivkey(sess, auth); @@ -861,8 +865,13 @@ virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSession *sess, }
int -virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess) +virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess G_GNUC_UNUSED) { +#ifdef WIN32 + virReportError(VIR_ERR_LIBSSH, "%s", + _("Agent authentication is not supported on this host")); + return -1; +#else virNetLibsshAuthMethod *auth;
virObjectLock(sess); @@ -873,6 +882,7 @@ virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess)
virObjectUnlock(sess); return 0; +#endif }
int
This hunk alone is enough to ensure agent is not available on WIN32. Michal

Hi On Tue, Apr 11, 2023 at 11:10 AM Michal Prívozník <mprivozn@redhat.com> wrote:
On 4/6/23 17:58, marcandre.lureau@redhat.com wrote:
From: Marc-André Lureau <marcandre.lureau@redhat.com>
The function does not exist on win32.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- src/rpc/virnetlibsshsession.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index e71a79d0fb..e94b0d7a2e 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -60,7 +60,9 @@ typedef enum { VIR_NET_LIBSSH_AUTH_KEYBOARD_INTERACTIVE, VIR_NET_LIBSSH_AUTH_PASSWORD, VIR_NET_LIBSSH_AUTH_PRIVKEY, - VIR_NET_LIBSSH_AUTH_AGENT +#ifndef WIN32 + VIR_NET_LIBSSH_AUTH_AGENT, +#endif } virNetLibsshAuthMethods;
I'd just drop this hunk, and ...
@@ -698,6 +700,7 @@ virNetLibsshAuthenticate(virNetLibsshSession *sess) /* try to authenticate using the keyboard interactive way */ ret = virNetLibsshAuthenticateKeyboardInteractive(sess,
auth);
break; +#ifndef WIN32 case VIR_NET_LIBSSH_AUTH_AGENT: /* try to authenticate using ssh-agent */ ret = ssh_userauth_agent(sess->session, NULL); @@ -708,6 +711,7 @@ virNetLibsshAuthenticate(virNetLibsshSession *sess) errmsg); } break; +#endif
.. here just wrap the actual ssh_userauth_agent() call in ifdnef. The @ret is set to SSH_AUTH_DENIED beforehand, and later in the code a proper error message is reported.
case VIR_NET_LIBSSH_AUTH_PRIVKEY: /* try to authenticate using the provided ssh key */ ret = virNetLibsshAuthenticatePrivkey(sess, auth); @@ -861,8 +865,13 @@
virNetLibsshSessionAuthAddPasswordAuth(virNetLibsshSession *sess,
}
int -virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess) +virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess G_GNUC_UNUSED) { +#ifdef WIN32 + virReportError(VIR_ERR_LIBSSH, "%s", + _("Agent authentication is not supported on this host")); + return -1; +#else virNetLibsshAuthMethod *auth;
virObjectLock(sess); @@ -873,6 +882,7 @@ virNetLibsshSessionAuthAddAgentAuth(virNetLibsshSession *sess)
virObjectUnlock(sess); return 0; +#endif }
int
This hunk alone is enough to ensure agent is not available on WIN32.
Sure, that's fine with me. thanks

On 4/6/23 17:58, marcandre.lureau@redhat.com wrote:
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Hi,
libvirt fails to compile on msys2/win32. Here is a few patches that solve it, but the way python scripts are being handled in general is a bit odd, so this is RFC. (fwiw, a lot of tests fail though, I can send the log if anyone is interested - or attach it to a gitlab issue)
Fixes: https://gitlab.com/libvirt/libvirt/-/issues/453
Marc-André Lureau (3): meson: don't look for unix paths on win32 meson: drop explicit python interpreter rpc/ssh: ssh_userauth_agent() is not supported on win32
docs/manpages/meson.build | 4 ++-- docs/meson.build | 6 ++---- meson.build | 14 +++++++++----- src/admin/meson.build | 4 ++-- src/esx/meson.build | 4 ++-- src/hyperv/meson.build | 2 +- src/meson.build | 8 ++++---- src/rpc/virnetlibsshsession.c | 14 ++++++++++++-- src/util/meson.build | 4 ++-- 9 files changed, 36 insertions(+), 24 deletions(-)
Hey, thanks for this. I have couple of questions though. No need to resend, I can squash in obvious changes if you agree before pushing. Michal
participants (3)
-
Marc-André Lureau
-
marcandre.lureau@redhat.com
-
Michal Prívozník