From nobody Sat Nov 23 15:12:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1723467915448167.03241648813946; Mon, 12 Aug 2024 06:05:15 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2A9AC11E5; Mon, 12 Aug 2024 09:05:14 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 18BD61556; Mon, 12 Aug 2024 09:04:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 33A811537; Mon, 12 Aug 2024 09:04:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1393613EC for ; Mon, 12 Aug 2024 09:04:42 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-151-b-gfeF9MP4qDSsJSdH4Evg-1; Mon, 12 Aug 2024 09:04:39 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2DB351955F43 for ; Mon, 12 Aug 2024 13:04:39 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 60B7119560A3 for ; Mon, 12 Aug 2024 13:04:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723467881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Rc+hKCgW2HF9JapRTQ/U1245Kl7x1elfx+1V3AWgrdk=; b=YIw+Ye3F98GZH3Jeh0L+E+rdoU0mQAcOg+TFPDwh5Xf+yasm1gxJEWXyNvUdS7sp7MR7Y4 cm9Z6rbStUc2rc5vWuUh+IhNPONkbwKf05xEG96Kby2z6K7QbAU6u2zeDSH9jcmQVPhG8f raiizqSZKoWXwRGuEE/fmCQ6/RsOkDU= X-MC-Unique: b-gfeF9MP4qDSsJSdH4Evg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH] virnetlibsshsession: Reflect API change in libssh Date: Mon, 12 Aug 2024 15:04:36 +0200 Message-ID: <2f3752553d73f3f5ab9a98a7667d6a90de654767.1723467876.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GCXIRNUG7AYJV52VZM4FJM6ZXXRBROYD X-Message-ID-Hash: GCXIRNUG7AYJV52VZM4FJM6ZXXRBROYD X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1723467917768116600 Content-Type: text/plain; charset="utf-8"; x-default="true" As of libssh commit of libssh-0.11.0~70 [1] the ssh_channel_get_exit_status() function is deprecated and a new one is introduced instead: ssh_channel_get_exit_state(). It's not a drop-in replacement, but it's simple enough. Adapt our libssh handling code to this change. 1: https://git.libssh.org/projects/libssh.git/commit/?id=3D04d86aeeae73c78a= f8b3dcdabb2e588cd31a8923 Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- meson.build | 3 +++ src/rpc/virnetlibsshsession.c | 39 +++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 06d88ad1f3..f31485c395 100644 --- a/meson.build +++ b/meson.build @@ -1096,6 +1096,9 @@ if conf.has('WITH_REMOTE') libssh_dep =3D dependency('libssh', version: '>=3D' + libssh_version, re= quired: get_option('libssh')) if libssh_dep.found() conf.set('WITH_LIBSSH', 1) + if cc.has_function('ssh_channel_get_exit_state', dependencies: libssh_= dep) + conf.set('WITH_SSH_CHANNEL_GET_EXIT_STATE', 1) + endif endif else libssh_dep =3D dependency('', required: false) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 6632e4a9ef..e496d3334e 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -170,6 +170,25 @@ virNetLibsshSessionOnceInit(void) } VIR_ONCE_GLOBAL_INIT(virNetLibsshSession); =20 + +static int virNetLibsshChannelGetExitStatus(ssh_channel channel, + uint32_t *exit_status) +{ +#ifdef WITH_SSH_CHANNEL_GET_EXIT_STATE + return ssh_channel_get_exit_state(channel, exit_status, NULL, NULL); +#else + int rc; + + rc =3D *exit_status =3D ssh_channel_get_exit_status(channel); + + if (rc !=3D SSH_OK) + return SSH_ERROR; + + return *exit_status; +#endif +} + + static virNetLibsshAuthMethod * virNetLibsshSessionAuthMethodNew(virNetLibsshSession *sess) { @@ -1179,12 +1198,16 @@ virNetLibsshChannelRead(virNetLibsshSession *sess, } =20 if (ssh_channel_is_eof(sess->channel)) { + uint32_t exit_status; + int rc; eof: - if (ssh_channel_get_exit_status(sess->channel)) { + + rc =3D virNetLibsshChannelGetExitStatus(sess->channel, &exit_statu= s); + if (rc !=3D SSH_OK || exit_status !=3D 0) { virReportError(VIR_ERR_LIBSSH, _("Remote command terminated with non-zero code= : %1$d"), - ssh_channel_get_exit_status(sess->channel)); - sess->channelCommandReturnValue =3D ssh_channel_get_exit_statu= s(sess->channel); + exit_status); + sess->channelCommandReturnValue =3D exit_status; sess->state =3D VIR_NET_LIBSSH_STATE_ERROR_REMOTE; virObjectUnlock(sess); return -1; @@ -1227,12 +1250,16 @@ virNetLibsshChannelWrite(virNetLibsshSession *sess, } =20 if (ssh_channel_is_eof(sess->channel)) { - if (ssh_channel_get_exit_status(sess->channel)) { + uint32_t exit_status; + int rc; + + rc =3D virNetLibsshChannelGetExitStatus(sess->channel, &exit_statu= s); + if (rc !=3D SSH_OK || exit_status !=3D 0) { virReportError(VIR_ERR_LIBSSH, _("Remote program terminated with non-zero code= : %1$d"), - ssh_channel_get_exit_status(sess->channel)); + exit_status); sess->state =3D VIR_NET_LIBSSH_STATE_ERROR_REMOTE; - sess->channelCommandReturnValue =3D ssh_channel_get_exit_statu= s(sess->channel); + sess->channelCommandReturnValue =3D exit_status; =20 ret =3D -1; goto cleanup; --=20 2.44.2