From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035327; cv=none; d=zohomail.com; s=zohoarc; b=UTeEfI0vV8U0tum1zxwrba0qn2g9HbX+fEc+XRnG1qlpsbD4T83lNtGuO0PrBxPnGeZaEydIcIQBFeREKNUDxz96mkC21qYW+5sArfmJ9LXb1uTYcjwaZi6iTEijuS/AZTGOWMERC3F4XHNrITEc8jtCr28eFXrfs8bFhngS7zI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035327; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jJjJ+zCpeVMBWzaOoclr5HNyPs6z46MvGpgnWeiQpAo=; b=RkA7cYgnOS+93Qk0Ntjei+ilPxOeNfl3Bl7zzJhuYdzcBXQpjI+YRtnwIx036YT2VOajJ9YqFFJWfHwgxbOt/K4y83jNpn/e4xZ89J0BQRAE2AbVyqtw1BwCp3MgujZZHDdeeREpXCx5R9Ps65Hk06AymiI2LUlROVd8ON3lFRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622035327811319.3426040192762; Wed, 26 May 2021 06:22:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-492-xqVuamyjPrqr1V7fusff8A-1; Wed, 26 May 2021 09:21:12 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2026EFC92; Wed, 26 May 2021 13:20:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E71A55C257; Wed, 26 May 2021 13:20:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A3B8F5534D; Wed, 26 May 2021 13:20:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKPbg022341 for ; Wed, 26 May 2021 09:20:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 080EE50B44; Wed, 26 May 2021 13:20:25 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 585972DAC5; Wed, 26 May 2021 13:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035326; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jJjJ+zCpeVMBWzaOoclr5HNyPs6z46MvGpgnWeiQpAo=; b=CxHleOu1rzne8/sqa93uAJDbaZH4pt8nIp4xmFAcZDHB1sLQpknPTNCMQjJuLg/9hG5h3t RzxuYCbvR5UJJMFjhvf7iD6hQ+3u+S41Z2G1/hgBhNLVub+02djahNj+GlgXwWq9YKHjDA shrBaMpCswdAB96b+XJiXXZHiJYVZZY= X-MC-Unique: xqVuamyjPrqr1V7fusff8A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 01/10] remote: use absolute path to check for daemons Date: Wed, 26 May 2021 14:20:08 +0100 Message-Id: <20210526132017.273817-2-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) virFileFindResource needs to be given the absolute build path otherwise its results will vary according to the CWD, leading to spurious failures in dev testing. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_daemon_dispatch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 1b4f5256c3..13f76cc685 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2001,7 +2001,9 @@ remoteDispatchProbeURI(bool readonly, =20 daemonname =3D g_strdup_printf("virt%sd", drivers[i]); =20 - if (!(daemonpath =3D virFileFindResource(daemonname, "src", SB= INDIR))) + if (!(daemonpath =3D virFileFindResource(daemonname, + abs_top_builddir "/src", + SBINDIR))) return -1; =20 if (!virFileExists(daemonpath)) { --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035244; cv=none; d=zohomail.com; s=zohoarc; b=IpIDjAGjkFmLgoMcw0yHmLGPgzQoIoObMTWL2DQDvG5GUEX+pSXQZsY5warpq19PSI5H+DRxdR4pJKAe67xCIt2+tLGEWaWRFsVFGjCAufKgEAp5VbMROorWUHAQYPao/Kco1KX847YiO7YMpkugHlNz12v+otUB1UKjpGO/Cwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035244; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HQ/zcwOZZDhbhbWA/BaDcCVaotpglTofnvPThuYoYlI=; b=drr9FOKp4HpqoFJvAkeJD/JWPSs6zrW7LFhUcosizNkS4wtFACZOhyFB9UBtIJbaxks0Jx4LFZU9gS/MQjhx03KHzLU2Ag2tNM5zhyLgxPiJ2NFc4l4UdpPBRRcWOeIqBFkGXiE9q5SD6q71eoQUPgbzYG+DpCZfdDIxdtBV/1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622035244700737.9266236055125; Wed, 26 May 2021 06:20:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-596-QatJWgH8M8WkC7rHfjJmKg-1; Wed, 26 May 2021 09:20:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2647107ACE4; Wed, 26 May 2021 13:20:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4F455B826; Wed, 26 May 2021 13:20:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 78A0855345; Wed, 26 May 2021 13:20:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKQEa022351 for ; Wed, 26 May 2021 09:20:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 31B8359440; Wed, 26 May 2021 13:20:26 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B66D5B826; Wed, 26 May 2021 13:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035243; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HQ/zcwOZZDhbhbWA/BaDcCVaotpglTofnvPThuYoYlI=; b=WrEVjlzRxv9Ci5rhKDhsFhaghBVfFl6gdKwocEIrZMbYLvUfbJXfDlOShhyHhwzQCoD5Kq AvIyYzvFch1Dt0pUzdkphEu7uaYJXVAGTK3/EvY9uSAjMosqm1FT+O7NSyiwbYSjRk7PyE /g95EvMwH4YgVC5kNNvTbjafZsFR+Dc= X-MC-Unique: QatJWgH8M8WkC7rHfjJmKg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/10] remote: stop checking for errors from socket allocations Date: Wed, 26 May 2021 14:20:09 +0100 Message-Id: <20210526132017.273817-3-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The remoteGetUNIXSocketHelper method always returns a non-NULL string. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_sockets.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index 43f78023fe..e9d865213f 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -155,12 +155,10 @@ remoteGetUNIXSocket(remoteDriverTransport transport, =20 legacy_daemon =3D g_strdup("libvirtd"); =20 - if (driver && - !(direct_sock_name =3D remoteGetUNIXSocketHelper(transport, direct= _daemon, ro, session))) - return NULL; + if (driver) + direct_sock_name =3D remoteGetUNIXSocketHelper(transport, direct_d= aemon, ro, session); =20 - if (!(legacy_sock_name =3D remoteGetUNIXSocketHelper(transport, "libvi= rt", ro, session))) - return NULL; + legacy_sock_name =3D remoteGetUNIXSocketHelper(transport, "libvirt", r= o, session); =20 if (mode =3D=3D REMOTE_DRIVER_MODE_AUTO) { if (transport =3D=3D REMOTE_DRIVER_TRANSPORT_UNIX) { --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035244; cv=none; d=zohomail.com; s=zohoarc; b=TqRVe98HUBpMOoD5ZymSsZwMC7APl/A/4ueSqFgSGUt/3TH54aFjlUumUmzEaCe3uwY9Fu6Vg9zW1HiL4QzQfc5LLjL9aM/0bv02UINZZjNJYBYjkMbPG95o58YOVsYx9xqqwvZ/ChnPBDEhpkeXLdR8nQFaFnxSEBr6JLyXg2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035244; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=USXBgXjrpPWtLn14ya0p7OQnJa4RLDZS6usye7axmoA=; b=PVWzCeMd52hIaa9UPueCYlW608KpXGyl9Zq6nUVP9lS/g/GpWEBBsH7GnXZgpCu2ZVc1gPFpv1JMl4c5TupppAmK47nP5sruTLQeBa/1BzmzVwHk8Uxx+NPgIJCQJs7qLbtp200eutiPb3qcqFOuDdEET7vuXgoC9nx94oP2HwQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622035244458667.1151083643389; Wed, 26 May 2021 06:20:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-0KWlBJmHOE-J-dzuvcowzw-1; Wed, 26 May 2021 09:20:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3AF4B1020C33; Wed, 26 May 2021 13:20:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6B3850DD2; Wed, 26 May 2021 13:20:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 089E6180B464; Wed, 26 May 2021 13:20:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKR5s022362 for ; Wed, 26 May 2021 09:20:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5BAD02BFF7; Wed, 26 May 2021 13:20:27 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9355759440; Wed, 26 May 2021 13:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035243; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=USXBgXjrpPWtLn14ya0p7OQnJa4RLDZS6usye7axmoA=; b=Z8pQ4hz9A+XXEP1Di1Ovyw38UCEYtt7sD1C7nN2ZqetRoBwhapyCJMVIi9EOZSJkFw2+xB F/U/baUQr0be5GmJ7Utvy3R/wVVvsVqiH0jEI3Ak6+T+E6qOfYLIt1kNECyyNp5LhM3oUH UUMH56bNXPK9veXHf9YPlwp1lh61zL0= X-MC-Unique: 0KWlBJmHOE-J-dzuvcowzw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 03/10] remote: move open flags enum to sockets header Date: Wed, 26 May 2021 14:20:10 +0100 Message-Id: <20210526132017.273817-4-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) This enum will shortly be used by the remote driver sockets helper methods too. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_driver.c | 28 +++++++++++----------------- src/remote/remote_sockets.h | 7 +++++++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 0bacd0bc4b..6b615b9286 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -650,12 +650,6 @@ static virNetClientProgramEvent qemuEvents[] =3D { (xdrproc_t)xdr_qemu_domain_monitor_event_msg }, }; =20 -enum virDrvOpenRemoteFlags { - VIR_DRV_OPEN_REMOTE_RO =3D (1 << 0), - VIR_DRV_OPEN_REMOTE_USER =3D (1 << 1), /* Use the per-user socket= path */ - VIR_DRV_OPEN_REMOTE_AUTOSTART =3D (1 << 2), /* Autostart a per-user da= emon */ -}; - =20 static void remoteClientCloseFunc(virNetClient *client G_GNUC_UNUSED, @@ -789,7 +783,7 @@ doRemoteOpen(virConnectPtr conn, /* Historically we didn't allow ssh tunnel with session mode, * since we can't construct the accurate path remotely, * so we can default to modern virt-ssh-helper */ - if (flags & VIR_DRV_OPEN_REMOTE_USER) + if (flags & REMOTE_DRIVER_OPEN_USER) proxy =3D VIR_NET_CLIENT_PROXY_NATIVE; else proxy =3D VIR_NET_CLIENT_PROXY_AUTO; @@ -923,8 +917,8 @@ doRemoteOpen(virConnectPtr conn, case REMOTE_DRIVER_TRANSPORT_LIBSSH2: if (!sockname && !(sockname =3D remoteGetUNIXSocket(transport, mode, driver_str, - flags & VIR_DRV_OPEN_REMOTE_R= O, - flags & VIR_DRV_OPEN_REMOTE_U= SER, + flags & REMOTE_DRIVER_OPEN_RO, + flags & REMOTE_DRIVER_OPEN_US= ER, &daemon_name))) goto failed; break; @@ -986,7 +980,7 @@ doRemoteOpen(virConnectPtr conn, netcat, sockname, name, - flags & VIR_DRV_OPEN_REMOTE_= RO, + flags & REMOTE_DRIVER_OPEN_R= O, auth, conn->uri); if (!priv->client) @@ -1010,7 +1004,7 @@ doRemoteOpen(virConnectPtr conn, netcat, sockname, name, - flags & VIR_DRV_OPEN_REMOTE_R= O, + flags & REMOTE_DRIVER_OPEN_RO, auth, conn->uri); if (!priv->client) @@ -1021,7 +1015,7 @@ doRemoteOpen(virConnectPtr conn, =20 #ifndef WIN32 case REMOTE_DRIVER_TRANSPORT_UNIX: - if (flags & VIR_DRV_OPEN_REMOTE_AUTOSTART) { + if (flags & REMOTE_DRIVER_OPEN_AUTOSTART) { const char *env_name =3D remoteGetDaemonPathEnv(); if (!(daemonPath =3D virFileFindResourceFull(daemon_name, NULL, NULL, @@ -1032,7 +1026,7 @@ doRemoteOpen(virConnectPtr conn, } =20 if (!(priv->client =3D virNetClientNewUNIX(sockname, - flags & VIR_DRV_OPEN_REMO= TE_AUTOSTART, + flags & REMOTE_DRIVER_OPE= N_AUTOSTART, daemonPath))) goto failed; =20 @@ -1054,7 +1048,7 @@ doRemoteOpen(virConnectPtr conn, netcat, sockname, name, - flags & VIR_DRV_OPEN_REMOT= E_RO))) + flags & REMOTE_DRIVER_OPEN= _RO))) goto failed; =20 priv->is_secure =3D 1; @@ -1277,13 +1271,13 @@ remoteConnectOpen(virConnectPtr conn, goto cleanup; =20 if (flags & VIR_CONNECT_RO) - rflags |=3D VIR_DRV_OPEN_REMOTE_RO; + rflags |=3D REMOTE_DRIVER_OPEN_RO; =20 remoteGetURIDaemonInfo(conn->uri, transport, &user, &autostart); if (user) - rflags |=3D VIR_DRV_OPEN_REMOTE_USER; + rflags |=3D REMOTE_DRIVER_OPEN_USER; if (autostart) - rflags |=3D VIR_DRV_OPEN_REMOTE_AUTOSTART; + rflags |=3D REMOTE_DRIVER_OPEN_AUTOSTART; =20 ret =3D doRemoteOpen(conn, priv, driver, transport, auth, conf, rflags= ); if (ret !=3D VIR_DRV_OPEN_SUCCESS) { diff --git a/src/remote/remote_sockets.h b/src/remote/remote_sockets.h index b3e0ce7da4..749389700e 100644 --- a/src/remote/remote_sockets.h +++ b/src/remote/remote_sockets.h @@ -48,6 +48,13 @@ typedef enum { REMOTE_DRIVER_MODE_LAST } remoteDriverMode; =20 +typedef enum { + REMOTE_DRIVER_OPEN_RO =3D (1 << 0), /* Use the read-only socket path */ + REMOTE_DRIVER_OPEN_USER =3D (1 << 1), /* Use the per-user socket path = */ + REMOTE_DRIVER_OPEN_AUTOSTART =3D (1 << 2), /* Autostart a per-user dae= mon */ +} remoteDriverOpenFlags; + + VIR_ENUM_DECL(remoteDriverMode); =20 int --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035329; cv=none; d=zohomail.com; s=zohoarc; b=Qv88uioxSjM6+45ShpEt81YPpzXsB9nSU2DQQMepe8XGFkAA6RF60PfD5buUEU3HbNC7wdOs3QMwEln4lytN6TFpHG3FkYd9DV9JnRbl0tomjQV9unP2rkSgXhrC1I+lJqRTvNDc1s//uJoJ2s3S/N7REBXRUwYY/oG+Zql3oOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035329; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cMd/CLYqKc6UBgnUFVIs3ACE72nAJkWmZwSdXoHTOeI=; b=EtVWCvzHqgCEf8TuW2fsl8IJWjoR8Mfai7FB4Ub1B0dydSTaQ/WiG4JZfp2DqhK0N9u9WAYFTrOwnlE9f/yzTFDWFLlIslePkAGQ3ADPgoxzQM39hGhlLRoJOytdURORCGyO0PvqBePw+1SMczFDLZFrvxAlRPBRkzncbsbFd+I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622035329615999.6960871939763; Wed, 26 May 2021 06:22:09 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-bmmRlGMZOkWDRHjtWQlpFw-1; Wed, 26 May 2021 09:21:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25E7219253C4; Wed, 26 May 2021 13:20:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB1EF5D9E2; Wed, 26 May 2021 13:20:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A57371801263; Wed, 26 May 2021 13:20:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKSpq022367 for ; Wed, 26 May 2021 09:20:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6DFB959444; Wed, 26 May 2021 13:20:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id B21CA51150; Wed, 26 May 2021 13:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035328; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cMd/CLYqKc6UBgnUFVIs3ACE72nAJkWmZwSdXoHTOeI=; b=PuHx4D52ZhfNapVYskOtsciaxLSuiNdNsrC5N6lhTN/Of0wLe+a2+QfFJULac4eqYesSFS vF+oyjzY8bRGRgDBS39kDO2Vr6XM5bpfMbQp5r3G454pYcsyYlQUlB/QAc+ZzYkL3vPeP1 Ql3X313F4dHX/dmxwBag6PQPyRGGI6k= X-MC-Unique: bmmRlGMZOkWDRHjtWQlpFw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/10] remote: consistently use flags for passing ro/user/autostart props Date: Wed, 26 May 2021 14:20:11 +0100 Message-Id: <20210526132017.273817-5-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We have helper methods that return boolans for ro/user/autostart properties. We then pack them into a flags parameter, and later unpack them again. This makes te code consistently use flags throughout. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_driver.c | 16 ++++----------- src/remote/remote_sockets.c | 37 ++++++++++++++++------------------ src/remote/remote_sockets.h | 6 ++---- src/remote/remote_ssh_helper.c | 13 ++++++------ 4 files changed, 30 insertions(+), 42 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6b615b9286..d03369b168 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -917,9 +917,7 @@ doRemoteOpen(virConnectPtr conn, case REMOTE_DRIVER_TRANSPORT_LIBSSH2: if (!sockname && !(sockname =3D remoteGetUNIXSocket(transport, mode, driver_str, - flags & REMOTE_DRIVER_OPEN_RO, - flags & REMOTE_DRIVER_OPEN_US= ER, - &daemon_name))) + flags, &daemon_name))) goto failed; break; =20 @@ -1232,9 +1230,7 @@ remoteConnectOpen(virConnectPtr conn, { struct private_data *priv; int ret =3D VIR_DRV_OPEN_ERROR; - int rflags =3D 0; - bool user; - bool autostart; + unsigned int rflags =3D 0; char *driver =3D NULL; remoteDriverTransport transport; =20 @@ -1270,15 +1266,11 @@ remoteConnectOpen(virConnectPtr conn, if (!(priv =3D remoteAllocPrivateData())) goto cleanup; =20 + + remoteGetURIDaemonInfo(conn->uri, transport, &rflags); if (flags & VIR_CONNECT_RO) rflags |=3D REMOTE_DRIVER_OPEN_RO; =20 - remoteGetURIDaemonInfo(conn->uri, transport, &user, &autostart); - if (user) - rflags |=3D REMOTE_DRIVER_OPEN_USER; - if (autostart) - rflags |=3D REMOTE_DRIVER_OPEN_AUTOSTART; - ret =3D doRemoteOpen(conn, priv, driver, transport, auth, conf, rflags= ); if (ret !=3D VIR_DRV_OPEN_SUCCESS) { conn->privateData =3D NULL; diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index e9d865213f..06315fe9c0 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -101,13 +101,12 @@ remoteSplitURIScheme(virURI *uri, static char * remoteGetUNIXSocketHelper(remoteDriverTransport transport, const char *sock_prefix, - bool ro, - bool session) + unsigned int flags) { char *sockname =3D NULL; g_autofree char *userdir =3D NULL; =20 - if (session) { + if (flags & REMOTE_DRIVER_OPEN_USER) { userdir =3D virGetUserRuntimeDirectory(); =20 sockname =3D g_strdup_printf("%s/%s-sock", userdir, sock_prefix); @@ -120,13 +119,14 @@ remoteGetUNIXSocketHelper(remoteDriverTransport trans= port, */ sockname =3D g_strdup_printf("%s/run/libvirt/%s-%s", LOCALSTATEDIR, sock_prefix, - ro ? "sock-ro" : "sock"); + flags & REMOTE_DRIVER_OPEN_RO ? + "sock-ro" : "sock"); } =20 VIR_DEBUG("Built UNIX sockname=3D%s for transport=3D%s " - "prefix=3D%s ro=3D%d session=3D%d", + "prefix=3D%s flags=3D0x%x", sockname, remoteDriverTransportTypeToString(transport), - sock_prefix, ro, session); + sock_prefix, flags); return sockname; } =20 @@ -135,8 +135,7 @@ char * remoteGetUNIXSocket(remoteDriverTransport transport, remoteDriverMode mode, const char *driver, - bool ro, - bool session, + unsigned int flags, char **daemon) { char *sock_name =3D NULL; @@ -145,10 +144,10 @@ remoteGetUNIXSocket(remoteDriverTransport transport, g_autofree char *direct_sock_name =3D NULL; g_autofree char *legacy_sock_name =3D NULL; =20 - VIR_DEBUG("Choosing remote socket for transport=3D%s mode=3D%s driver= =3D%s ro=3D%d session=3D%d", + VIR_DEBUG("Choosing remote socket for transport=3D%s mode=3D%s driver= =3D%s flags=3D0x%x", remoteDriverTransportTypeToString(transport), remoteDriverModeTypeToString(mode), - driver, ro, session); + driver, flags); =20 if (driver) direct_daemon =3D g_strdup_printf("virt%sd", driver); @@ -156,9 +155,9 @@ remoteGetUNIXSocket(remoteDriverTransport transport, legacy_daemon =3D g_strdup("libvirtd"); =20 if (driver) - direct_sock_name =3D remoteGetUNIXSocketHelper(transport, direct_d= aemon, ro, session); + direct_sock_name =3D remoteGetUNIXSocketHelper(transport, direct_d= aemon, flags); =20 - legacy_sock_name =3D remoteGetUNIXSocketHelper(transport, "libvirt", r= o, session); + legacy_sock_name =3D remoteGetUNIXSocketHelper(transport, "libvirt", f= lags); =20 if (mode =3D=3D REMOTE_DRIVER_MODE_AUTO) { if (transport =3D=3D REMOTE_DRIVER_TRANSPORT_UNIX) { @@ -221,13 +220,11 @@ remoteGetUNIXSocket(remoteDriverTransport transport, void remoteGetURIDaemonInfo(virURI *uri, remoteDriverTransport transport, - bool *session, - bool *autostart) + unsigned int *flags) { const char *autostart_str =3D getenv("LIBVIRT_AUTOSTART"); =20 - *session =3D false; - *autostart =3D false; + *flags =3D 0; =20 /* * User session daemon is used for @@ -244,7 +241,7 @@ remoteGetURIDaemonInfo(virURI *uri, STRPREFIX(uri->scheme, "test+")) && geteuid() > 0) { VIR_DEBUG("User session daemon required"); - *session =3D true; + *flags |=3D REMOTE_DRIVER_OPEN_USER; =20 /* * Furthermore if no servername is given, @@ -256,7 +253,7 @@ remoteGetURIDaemonInfo(virURI *uri, (!autostart_str || STRNEQ(autostart_str, "0"))) { VIR_DEBUG("Try daemon autostart"); - *autostart =3D true; + *flags |=3D REMOTE_DRIVER_OPEN_AUTOSTART; } } =20 @@ -268,10 +265,10 @@ remoteGetURIDaemonInfo(virURI *uri, VIR_DEBUG("Auto-probe remote URI"); if (geteuid() > 0) { VIR_DEBUG("Auto-spawn user daemon instance"); - *session =3D true; + *flags |=3D REMOTE_DRIVER_OPEN_USER; if (!autostart_str || STRNEQ(autostart_str, "0")) - *autostart =3D true; + *flags |=3D REMOTE_DRIVER_OPEN_AUTOSTART; } } } diff --git a/src/remote/remote_sockets.h b/src/remote/remote_sockets.h index 749389700e..2331f81425 100644 --- a/src/remote/remote_sockets.h +++ b/src/remote/remote_sockets.h @@ -66,12 +66,10 @@ char * remoteGetUNIXSocket(remoteDriverTransport transport, remoteDriverMode mode, const char *driver, - bool ro, - bool session, + unsigned int flags, /* remoteDriverOpenFlags */ char **daemon); =20 void remoteGetURIDaemonInfo(virURI *uri, remoteDriverTransport transport, - bool *session, - bool *autostart); + unsigned int *flags); /* remoteDriverOpenFlags */ diff --git a/src/remote/remote_ssh_helper.c b/src/remote/remote_ssh_helper.c index 7934e14509..7123fc6d00 100644 --- a/src/remote/remote_ssh_helper.c +++ b/src/remote/remote_ssh_helper.c @@ -355,8 +355,6 @@ int main(int argc, char **argv) g_autoptr(virURI) uri =3D NULL; g_autofree char *driver =3D NULL; remoteDriverTransport transport; - bool user =3D false; - bool autostart =3D false; gboolean version =3D false; gboolean readonly =3D false; g_autofree char *sock_path =3D NULL; @@ -369,6 +367,7 @@ int main(int argc, char **argv) { "version", 'V', 0, G_OPTION_ARG_NONE, &version, "Display version= information", NULL }, { NULL, '\0', 0, 0, NULL, NULL, NULL } }; + unsigned int flags; =20 context =3D g_option_context_new("- libvirt socket proxy"); g_option_context_add_main_entries(context, entries, PACKAGE); @@ -422,16 +421,18 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } =20 - remoteGetURIDaemonInfo(uri, transport, &user, &autostart); + remoteGetURIDaemonInfo(uri, transport, &flags); + if (readonly) + flags |=3D REMOTE_DRIVER_OPEN_RO; =20 sock_path =3D remoteGetUNIXSocket(transport, REMOTE_DRIVER_MODE_AUTO, driver, - !!readonly, - user, + flags, &daemon_name); =20 - if (virNetSocketNewConnectUNIX(sock_path, autostart, daemon_name, &soc= k) < 0) { + if (virNetSocketNewConnectUNIX(sock_path, flags & REMOTE_DRIVER_OPEN_A= UTOSTART, + daemon_name, &sock) < 0) { g_printerr(_("%s: cannot connect to '%s': %s\n"), argv[0], sock_path, virGetLastErrorMessage()); exit(EXIT_FAILURE); --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035332; cv=none; d=zohomail.com; s=zohoarc; b=Zagg5FY8V3a87PUWbSUN9MXz4zzcY+WNZNiRi+RJZcYXkFqVB+HZxzFIlRB1crpOJ9nuBULEO+PAhWuvvU6KQirJEyUrHG202jZzoo35ZwoYXMTcbVL8D9NHXXSg32Kh+jjvRZpe90Y4y8AxyslQXqu9CHJuCWTYX7nJyk/VnCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035332; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AfTNDlE2BPy1t6zZY7vylnptXNCywtttv7q8SToQaf8=; b=jmiV6Lnv0HECIauvZvE0/JEbVaClRuUg1OKVpHZLtRnjpdZLQaJRH1YCorQ0u0G7Xr1o5Z9t8cWm0cbwV/rnn0W7oKIcddoeYMtj0VhW+/bgXsUWBj1Fh6E9zht0lq0z0bgwy+7+baP4SfTcAqygzH6lhuJ6m+khAZMkIPQSoXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1622035332293981.060445232277; Wed, 26 May 2021 06:22:12 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-Q9hkR1z0MBiK52nBRnv7mQ-1; Wed, 26 May 2021 09:21:13 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13ED9107ACCD; Wed, 26 May 2021 13:20:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DDA58608BA; Wed, 26 May 2021 13:20:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 925D05534F; Wed, 26 May 2021 13:20:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKTII022375 for ; Wed, 26 May 2021 09:20:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E6E96A857; Wed, 26 May 2021 13:20:29 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id B82D651150; Wed, 26 May 2021 13:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035331; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AfTNDlE2BPy1t6zZY7vylnptXNCywtttv7q8SToQaf8=; b=iMmpRkozzeaNg9mNZ09lPhdi/R70uG2RtsqxP3IRR7Je4k2Je38kJWfmmZciQPW56t2/hj woY2o/VzqDYUu2nKBe7DoYlzXoYA/csIJ8ZlbvXB0urZNL5bhROVB7eDTucNzX+r+IFkDZ sM2vBMbywFQD+O+IzpnYnrnCmSxkYgo= X-MC-Unique: Q9hkR1z0MBiK52nBRnv7mQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/10] remote: change socket helper to return full daemon path Date: Wed, 26 May 2021 14:20:12 +0100 Message-Id: <20210526132017.273817-6-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The remoteGetUNIXSocket method currently just returns the daemon name and the caller then converts this to a path. Except the SSH helper didn't do this, so it was relying on later code expanding $PATH, and this doesn't allow for build root overrides. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_driver.c | 33 +++------------------------- src/remote/remote_sockets.c | 39 +++++++++++++++++++++++++++++----- src/remote/remote_sockets.h | 2 +- src/remote/remote_ssh_helper.c | 6 +++--- 4 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d03369b168..e4e412dd01 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -700,23 +700,6 @@ remoteConnectSupportsFeatureUnlocked(virConnectPtr con= n, } =20 =20 -#ifndef WIN32 -static const char * -remoteGetDaemonPathEnv(void) -{ - /* We prefer a VIRTD_PATH env var to use for all daemons, - * but if it is not set we will fallback to LIBVIRTD_PATH - * for previous behaviour - */ - if (getenv("VIRTD_PATH") !=3D NULL) { - return "VIRTD_PATH"; - } else { - return "LIBVIRTD_PATH"; - } -} -#endif /* WIN32 */ - - /* * URIs that this driver needs to handle: * @@ -763,7 +746,7 @@ doRemoteOpen(virConnectPtr conn, g_autofree char *knownHostsVerify =3D NULL; g_autofree char *knownHosts =3D NULL; g_autofree char *mode_str =3D NULL; - g_autofree char *daemon_name =3D NULL; + g_autofree char *daemon_path =3D NULL; g_autofree char *proxy_str =3D NULL; bool sanity =3D true; bool verify =3D true; @@ -917,7 +900,7 @@ doRemoteOpen(virConnectPtr conn, case REMOTE_DRIVER_TRANSPORT_LIBSSH2: if (!sockname && !(sockname =3D remoteGetUNIXSocket(transport, mode, driver_str, - flags, &daemon_name))) + flags, &daemon_path))) goto failed; break; =20 @@ -1013,19 +996,9 @@ doRemoteOpen(virConnectPtr conn, =20 #ifndef WIN32 case REMOTE_DRIVER_TRANSPORT_UNIX: - if (flags & REMOTE_DRIVER_OPEN_AUTOSTART) { - const char *env_name =3D remoteGetDaemonPathEnv(); - if (!(daemonPath =3D virFileFindResourceFull(daemon_name, - NULL, NULL, - abs_top_builddir "/= src", - SBINDIR, - env_name))) - goto failed; - } - if (!(priv->client =3D virNetClientNewUNIX(sockname, flags & REMOTE_DRIVER_OPE= N_AUTOSTART, - daemonPath))) + daemon_path))) goto failed; =20 priv->is_secure =3D 1; diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index 06315fe9c0..6d33b69467 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -47,6 +47,22 @@ VIR_ENUM_IMPL(remoteDriverMode, "legacy", "direct"); =20 +#ifndef WIN32 +static const char * +remoteGetDaemonPathEnv(void) +{ + /* We prefer a VIRTD_PATH env var to use for all daemons, + * but if it is not set we will fallback to LIBVIRTD_PATH + * for previous behaviour + */ + if (getenv("VIRTD_PATH") !=3D NULL) { + return "VIRTD_PATH"; + } else { + return "LIBVIRTD_PATH"; + } +} +#endif /* WIN32 */ + =20 int remoteSplitURIScheme(virURI *uri, @@ -136,13 +152,19 @@ remoteGetUNIXSocket(remoteDriverTransport transport, remoteDriverMode mode, const char *driver, unsigned int flags, - char **daemon) + char **daemon_path) { char *sock_name =3D NULL; g_autofree char *direct_daemon =3D NULL; g_autofree char *legacy_daemon =3D NULL; + g_autofree char *daemon_name =3D NULL; g_autofree char *direct_sock_name =3D NULL; g_autofree char *legacy_sock_name =3D NULL; +#ifndef WIN32 + const char *env_name =3D remoteGetDaemonPathEnv(); +#else + const char *env_path =3D NULL; +#endif =20 VIR_DEBUG("Choosing remote socket for transport=3D%s mode=3D%s driver= =3D%s flags=3D0x%x", remoteDriverTransportTypeToString(transport), @@ -182,7 +204,7 @@ remoteGetUNIXSocket(remoteDriverTransport transport, switch ((remoteDriverMode)mode) { case REMOTE_DRIVER_MODE_LEGACY: sock_name =3D g_steal_pointer(&legacy_sock_name); - *daemon =3D g_steal_pointer(&legacy_daemon); + daemon_name =3D g_steal_pointer(&legacy_daemon); break; =20 case REMOTE_DRIVER_MODE_DIRECT: @@ -200,7 +222,7 @@ remoteGetUNIXSocket(remoteDriverTransport transport, } =20 sock_name =3D g_steal_pointer(&direct_sock_name); - *daemon =3D g_steal_pointer(&direct_daemon); + daemon_name =3D g_steal_pointer(&direct_daemon); break; =20 case REMOTE_DRIVER_MODE_AUTO: @@ -210,8 +232,15 @@ remoteGetUNIXSocket(remoteDriverTransport transport, return NULL; } =20 - VIR_DEBUG("Chosen UNIX sockname=3D%s daemon=3D%s with mode=3D%s", - sock_name, NULLSTR(*daemon), + if (!(*daemon_path =3D virFileFindResourceFull(daemon_name, + NULL, NULL, + abs_top_builddir "/src", + SBINDIR, + env_name))) + return NULL; + + VIR_DEBUG("Chosen UNIX sockname=3D%s daemon_path=3D%s with mode=3D%s", + sock_name, NULLSTR(*daemon_path), remoteDriverModeTypeToString(mode)); return sock_name; } diff --git a/src/remote/remote_sockets.h b/src/remote/remote_sockets.h index 2331f81425..11934dbf70 100644 --- a/src/remote/remote_sockets.h +++ b/src/remote/remote_sockets.h @@ -67,7 +67,7 @@ remoteGetUNIXSocket(remoteDriverTransport transport, remoteDriverMode mode, const char *driver, unsigned int flags, /* remoteDriverOpenFlags */ - char **daemon); + char **daemon_path); =20 void remoteGetURIDaemonInfo(virURI *uri, diff --git a/src/remote/remote_ssh_helper.c b/src/remote/remote_ssh_helper.c index 7123fc6d00..2a24f2df96 100644 --- a/src/remote/remote_ssh_helper.c +++ b/src/remote/remote_ssh_helper.c @@ -358,7 +358,7 @@ int main(int argc, char **argv) gboolean version =3D false; gboolean readonly =3D false; g_autofree char *sock_path =3D NULL; - g_autofree char *daemon_name =3D NULL; + g_autofree char *daemon_path =3D NULL; g_autoptr(virNetSocket) sock =3D NULL; GError *error =3D NULL; g_autoptr(GOptionContext) context =3D NULL; @@ -429,10 +429,10 @@ int main(int argc, char **argv) REMOTE_DRIVER_MODE_AUTO, driver, flags, - &daemon_name); + &daemon_path); =20 if (virNetSocketNewConnectUNIX(sock_path, flags & REMOTE_DRIVER_OPEN_A= UTOSTART, - daemon_name, &sock) < 0) { + daemon_path, &sock) < 0) { g_printerr(_("%s: cannot connect to '%s': %s\n"), argv[0], sock_path, virGetLastErrorMessage()); exit(EXIT_FAILURE); --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035278; cv=none; d=zohomail.com; s=zohoarc; b=eEj07rJQjzaG0mvuC7tQe+KDe3Pd+xB/e4euDiL/Ha2A99wdl9G9uqfzjyicFy2bxeQTqTPwcfeGAJOzFcbQDPkWas7mXPOBG82hvpNjTVg+0QCGQJd7JAKaBflrL3DagH6vMFS941nJZLSUu0TIwSguuwk2un+KxqHngovkM2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035278; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=++lAeelDW+PboiLQf92YXibgqBe5qVryyrysSOgB+dg=; b=SBLn5hkQf6tO+6PCYdR2jNVA9eZb9BMW1QFUYc7suoJT8hKLP4BfMcxI1oFbVape1r6b6+r0smE2XZo5FEJSKH0ZUF7BKVwmVDSWg2KE3Hp8FHqgJR/nndWssdSvdSELycF/xEskuJWfdYtWmuiuzJHHMQ9Kp7BkmWkXIFHgsII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622035278743460.9503620665205; Wed, 26 May 2021 06:21:18 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-512-am1MjwkrO9-V8AoNqpIbhQ-1; Wed, 26 May 2021 09:21:11 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BC23FC8F; Wed, 26 May 2021 13:21:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 28317100E113; Wed, 26 May 2021 13:21:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C785C55356; Wed, 26 May 2021 13:21:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKUWQ022390 for ; Wed, 26 May 2021 09:20:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE3CC5944A; Wed, 26 May 2021 13:20:30 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF7C659449; Wed, 26 May 2021 13:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035277; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=++lAeelDW+PboiLQf92YXibgqBe5qVryyrysSOgB+dg=; b=WL/qu5+kB1JStuamhKiRZLhrjEPn76+Rmtq2Wt0sDTw8CF/X0+bfjpsgJBdqC9Z57/tW1U eN/GGH3s1ldLM0XXiNpxVWfZUZ5de7nRYSpi/BlQudLhO5wYMaP6CHamWBpoKDysxFlkrx E+e4EI4Rd7c1cS2KYof+f8mTXFRmj5I= X-MC-Unique: am1MjwkrO9-V8AoNqpIbhQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/10] remote: don't populate daemon path if autostart is not required Date: Wed, 26 May 2021 14:20:13 +0100 Message-Id: <20210526132017.273817-7-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) When deciding what socket to connect to, we build the daemon path that we need to autostart. This path only needs to be populated if we actually intend to use autostart. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_sockets.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index 6d33b69467..cce6703e75 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -232,12 +232,16 @@ remoteGetUNIXSocket(remoteDriverTransport transport, return NULL; } =20 - if (!(*daemon_path =3D virFileFindResourceFull(daemon_name, - NULL, NULL, - abs_top_builddir "/src", - SBINDIR, - env_name))) - return NULL; + if (flags & REMOTE_DRIVER_OPEN_AUTOSTART) { + if (!(*daemon_path =3D virFileFindResourceFull(daemon_name, + NULL, NULL, + abs_top_builddir "/sr= c", + SBINDIR, + env_name))) + return NULL; + } else { + *daemon_path =3D NULL; + } =20 VIR_DEBUG("Chosen UNIX sockname=3D%s daemon_path=3D%s with mode=3D%s", sock_name, NULLSTR(*daemon_path), --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035324; cv=none; d=zohomail.com; s=zohoarc; b=cu6fIADcpTylKuZZcF8q7P2lH4BNss9xMo06kVjW0mxZvWnSOGXTTwca6k34pXeb6J3jbAx2OEloG22QZhDRMe3Zg6y2VhvVSnQtRjEcroywChpG1Hk7MYNfF0lqJRheEHddnxty3ZBsML5yZKaP88s7kt92uCcSUsjDWmTk6dA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035324; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ulwDYWsdRLpDcKW2tE2booUi00C8WuE3mnWCij+MSCs=; b=Iq9fGSU99fs6Xwtitw3VlH4SOyRs3Q6RPfVm9J1G+IdHSUlgUr7nfj2toEciW7+Av3ixIOrktyHgvVIRsO80ZsuyLGcgGJzonCwSu0VX0q4puDMwnnB4NT4TZYyjogKSE+Lps9vwcQGH6EVnv7otDp00aoicGrxJvezTVP6MEZQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622035324668154.52303793499027; Wed, 26 May 2021 06:22:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-514-4deDcDC7Mc-7UZZxaBnQyA-1; Wed, 26 May 2021 09:21:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6524819253C2; Wed, 26 May 2021 13:21:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3783559440; Wed, 26 May 2021 13:21:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DE939180102C; Wed, 26 May 2021 13:20:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKVAJ022402 for ; Wed, 26 May 2021 09:20:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id B22CB2C01B; Wed, 26 May 2021 13:20:31 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04A3B2B9F7; Wed, 26 May 2021 13:20:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035323; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ulwDYWsdRLpDcKW2tE2booUi00C8WuE3mnWCij+MSCs=; b=Pd6x1XXKh93/845YQwK2P5epyKHCdx0Cz4TYFRW0HOrsyMYxgVCZyZUOQBdmHLzinTpw1N 8WyvXOrAaS+uP+LxsXKI6xm4w8TiO6ZEF7YysE3//mSMPIk9kyuhXnMQqt6/W+wjecl/AV 7whd/B2Sau3UChBVeIB4pcsgueA1k7M= X-MC-Unique: 4deDcDC7Mc-7UZZxaBnQyA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/10] rpc: remove "spawnDaemon" parameter Date: Wed, 26 May 2021 14:20:14 +0100 Message-Id: <20210526132017.273817-8-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The "spawnDaemon" and "binary" parameters are co-dependant, with the latter non-NULL, if-and-only-if the former is true. Getting rid of the "spawnDaemon" parameter simplifies life for the callers and eliminates an error checking scenario. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/admin/admin_remote.c | 2 +- src/locking/lock_driver_lockd.c | 1 - src/logging/log_manager.c | 1 - src/lxc/lxc_monitor.c | 2 +- src/qemu/qemu_migration.c | 3 +-- src/remote/remote_driver.c | 1 - src/remote/remote_ssh_helper.c | 3 +-- src/rpc/virnetclient.c | 5 ++--- src/rpc/virnetclient.h | 3 +-- src/rpc/virnetsocket.c | 26 +++++++------------------- src/rpc/virnetsocket.h | 3 +-- tests/virnetsockettest.c | 4 ++-- 12 files changed, 17 insertions(+), 37 deletions(-) diff --git a/src/admin/admin_remote.c b/src/admin/admin_remote.c index 55ac81c5de..83a6be2b97 100644 --- a/src/admin/admin_remote.c +++ b/src/admin/admin_remote.c @@ -222,7 +222,7 @@ remoteAdminPrivNew(const char *sock_path) if (!(priv =3D virObjectLockableNew(remoteAdminPrivClass))) goto error; =20 - if (!(priv->client =3D virNetClientNewUNIX(sock_path, false, NULL))) + if (!(priv->client =3D virNetClientNewUNIX(sock_path, NULL))) goto error; =20 if (!(priv->program =3D virNetClientProgramNew(ADMIN_PROGRAM, diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lock= d.c index 823b918db3..3a7386af30 100644 --- a/src/locking/lock_driver_lockd.c +++ b/src/locking/lock_driver_lockd.c @@ -208,7 +208,6 @@ static virNetClient *virLockManagerLockDaemonConnection= New(bool privileged, goto error; =20 if (!(client =3D virNetClientNewUNIX(lockdpath, - daemonPath !=3D NULL, daemonPath))) goto error; =20 diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c index f66ebda495..e605ed9930 100644 --- a/src/logging/log_manager.c +++ b/src/logging/log_manager.c @@ -79,7 +79,6 @@ virLogManagerConnect(bool privileged, goto error; =20 if (!(client =3D virNetClientNewUNIX(logdpath, - daemonPath !=3D NULL, daemonPath))) goto error; =20 diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c index 445bea281d..d8ef489a01 100644 --- a/src/lxc/lxc_monitor.c +++ b/src/lxc/lxc_monitor.c @@ -151,7 +151,7 @@ virLXCMonitor *virLXCMonitorNew(virDomainObj *vm, =20 sockpath =3D g_strdup_printf("%s/%s.sock", socketdir, vm->def->name); =20 - if (!(mon->client =3D virNetClientNewUNIX(sockpath, false, NULL))) + if (!(mon->client =3D virNetClientNewUNIX(sockpath, NULL))) goto error; =20 if (virNetClientRegisterAsyncIO(mon->client) < 0) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3b0026a28e..a199758feb 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3761,8 +3761,7 @@ qemuMigrationSrcConnect(virQEMUDriver *driver, break; case MIGRATION_DEST_CONNECT_SOCKET: if (virNetSocketNewConnectUNIX(spec->dest.socket.path, - false, NULL, - &sock) =3D=3D 0) { + NULL, &sock) =3D=3D 0) { fd_qemu =3D virNetSocketDupFD(sock, true); virObjectUnref(sock); } diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index e4e412dd01..9ca4348f6f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -997,7 +997,6 @@ doRemoteOpen(virConnectPtr conn, #ifndef WIN32 case REMOTE_DRIVER_TRANSPORT_UNIX: if (!(priv->client =3D virNetClientNewUNIX(sockname, - flags & REMOTE_DRIVER_OPE= N_AUTOSTART, daemon_path))) goto failed; =20 diff --git a/src/remote/remote_ssh_helper.c b/src/remote/remote_ssh_helper.c index 2a24f2df96..0945b90331 100644 --- a/src/remote/remote_ssh_helper.c +++ b/src/remote/remote_ssh_helper.c @@ -431,8 +431,7 @@ int main(int argc, char **argv) flags, &daemon_path); =20 - if (virNetSocketNewConnectUNIX(sock_path, flags & REMOTE_DRIVER_OPEN_A= UTOSTART, - daemon_path, &sock) < 0) { + if (virNetSocketNewConnectUNIX(sock_path, daemon_path, &sock) < 0) { g_printerr(_("%s: cannot connect to '%s': %s\n"), argv[0], sock_path, virGetLastErrorMessage()); exit(EXIT_FAILURE); diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 3797a6097b..ffe2f343f9 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -366,12 +366,11 @@ virNetClientFindDefaultSshKey(const char *homedir, ch= ar **retPath) =20 =20 virNetClient *virNetClientNewUNIX(const char *path, - bool spawnDaemon, - const char *binary) + const char *spawnDaemonPath) { virNetSocket *sock; =20 - if (virNetSocketNewConnectUNIX(path, spawnDaemon, binary, &sock) < 0) + if (virNetSocketNewConnectUNIX(path, spawnDaemonPath, &sock) < 0) return NULL; =20 return virNetClientNew(sock, NULL); diff --git a/src/rpc/virnetclient.h b/src/rpc/virnetclient.h index c6ad59cf0d..5048033325 100644 --- a/src/rpc/virnetclient.h +++ b/src/rpc/virnetclient.h @@ -48,8 +48,7 @@ virNetClientSSHHelperCommand(virNetClientProxy proxy, bool readonly); =20 virNetClient *virNetClientNewUNIX(const char *path, - bool spawnDaemon, - const char *binary); + const char *spawnDaemonPath); =20 virNetClient *virNetClientNewTCP(const char *nodename, const char *service, diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index c762b605a5..c3fae8b626 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -664,8 +664,7 @@ int virNetSocketNewConnectTCP(const char *nodename, =20 #ifndef WIN32 int virNetSocketNewConnectUNIX(const char *path, - bool spawnDaemon, - const char *binary, + const char *spawnDaemonPath, virNetSocket **retsock) { char *lockpath =3D NULL; @@ -678,25 +677,15 @@ int virNetSocketNewConnectUNIX(const char *path, int ret =3D -1; bool daemonLaunched =3D false; =20 - VIR_DEBUG("path=3D%s spawnDaemon=3D%d binary=3D%s", path, spawnDaemon, - NULLSTR(binary)); + VIR_DEBUG("path=3D%s spawnDaemonPath=3D%s", path, NULLSTR(spawnDaemonP= ath)); =20 memset(&localAddr, 0, sizeof(localAddr)); memset(&remoteAddr, 0, sizeof(remoteAddr)); =20 remoteAddr.len =3D sizeof(remoteAddr.data.un); =20 - if (spawnDaemon) { - g_autofree char *binname =3D NULL; - - if (!binary) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Auto-spawn of daemon requested, " - "but no binary specified")); - goto cleanup; - } - - binname =3D g_path_get_basename(binary); + if (spawnDaemonPath) { + g_autofree char *binname =3D g_path_get_basename(spawnDaemonPath); rundir =3D virGetUserRuntimeDirectory(); =20 if (g_mkdir_with_parents(rundir, 0700) < 0) { @@ -741,7 +730,7 @@ int virNetSocketNewConnectUNIX(const char *path, VIR_DEBUG("connect() failed: retries=3D%d errno=3D%d", retries, er= rno); =20 retries--; - if (!spawnDaemon || + if (!spawnDaemonPath || retries =3D=3D 0 || (errno !=3D ENOENT && errno !=3D ECONNREFUSED)) { virReportSystemError(errno, _("Failed to connect socket to '%s= '"), @@ -750,7 +739,7 @@ int virNetSocketNewConnectUNIX(const char *path, } =20 if (!daemonLaunched) { - if (virNetSocketForkDaemon(binary) < 0) + if (virNetSocketForkDaemon(spawnDaemonPath) < 0) goto cleanup; =20 daemonLaunched =3D true; @@ -785,8 +774,7 @@ int virNetSocketNewConnectUNIX(const char *path, } #else int virNetSocketNewConnectUNIX(const char *path G_GNUC_UNUSED, - bool spawnDaemon G_GNUC_UNUSED, - const char *binary G_GNUC_UNUSED, + const char *spawnDaemonPath, virNetSocket **retsock G_GNUC_UNUSED) { virReportSystemError(ENOSYS, "%s", diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h index 2dc4d06f42..6fef8d30b3 100644 --- a/src/rpc/virnetsocket.h +++ b/src/rpc/virnetsocket.h @@ -65,8 +65,7 @@ int virNetSocketNewConnectTCP(const char *nodename, virNetSocket **addr); =20 int virNetSocketNewConnectUNIX(const char *path, - bool spawnDaemon, - const char *binary, + const char *spawnDaemonPath, virNetSocket **addr); =20 int virNetSocketNewConnectCommand(virCommand *cmd, diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index 6afdcbdbc7..8059c6cbb0 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -131,7 +131,7 @@ testSocketClient(void *opaque) virNetSocket *csock =3D NULL; =20 if (data->path) { - if (virNetSocketNewConnectUNIX(data->path, false, + if (virNetSocketNewConnectUNIX(data->path, NULL, &csock) < 0) return; } else { @@ -339,7 +339,7 @@ static int testSocketUNIXAddrs(const void *data G_GNUC_= UNUSED) if (virNetSocketListen(lsock, 0) < 0) goto cleanup; =20 - if (virNetSocketNewConnectUNIX(path, false, NULL, &csock) < 0) + if (virNetSocketNewConnectUNIX(path, NULL, &csock) < 0) goto cleanup; =20 if (STRNEQ(virNetSocketLocalAddrStringSASL(csock), "127.0.0.1;0")) { --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035306; cv=none; d=zohomail.com; s=zohoarc; b=hTKR1BOQWqXoYFQWXf/P8JKDcqsu1kZ/rnilhekp35SVz0vQIos9AXa77N8cZ9SLfKES3Z0WXVleZ5Ean/Fn/faIjfR7TdeirfvwGkU1Q2ZLD0Z8CT1ofZKRl5BSwZyIqQ6ScQVSi1BT4WbWg9leoScLhnF/GE0Fc4fJq1pUtRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035306; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3OGjrqmDW8piW2YMIFTlHRHnUk+1XQDIfnVU3CQFOlQ=; b=Gvh2dCz7/02yct8/Z4F8aO54gtEoodmE+vU61dlly+OCEZdCW9jIVDY2u72XbPmA78wwdEyp7M2tKiIBokcM4yyOr9xrSlH9hA91xxLeJLServxOYu9pk4bsCNLUKVr9PimB6vXksJTir01wCULBpBB84KzFqxma/MvmGhGzjXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1622035306352873.740534883625; Wed, 26 May 2021 06:21:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-J1oeR6pWMNyTxuQ6MSyCsg-1; Wed, 26 May 2021 09:21:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 964F3FC86; Wed, 26 May 2021 13:21:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5CF1619D9D; Wed, 26 May 2021 13:21:05 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1807E5535F; Wed, 26 May 2021 13:21:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKWXM022411 for ; Wed, 26 May 2021 09:20:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0F5450B44; Wed, 26 May 2021 13:20:32 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22EBB2DAC5; Wed, 26 May 2021 13:20:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035305; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3OGjrqmDW8piW2YMIFTlHRHnUk+1XQDIfnVU3CQFOlQ=; b=SiixcvVU7Nz7dY7kxBnN9ZeAaRRYhF/fN24wdDNwSy2D5THJgwUtiFxZA+WOpiADTd+Y+p Sgqmm4v5mSwXqUs+KutkVHdY7k3VyHAsYjssTO5lXrLSU4ZuyVCezFB82rOLDW+LVkpsCC 2FteGNOJ77O+euvRInan4kUGGnoEfow= X-MC-Unique: J1oeR6pWMNyTxuQ6MSyCsg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/10] remote: move proxy/mode defaults after URI parsing Date: Wed, 26 May 2021 14:20:15 +0100 Message-Id: <20210526132017.273817-9-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Currently the defaults for the proxy/mode settings are set before parsing URI parameters. A following commit will introduce a dependancy on the URI parsing for the defaults, so they need to move. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_driver.c | 50 ++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9ca4348f6f..6a881fff28 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -757,20 +757,6 @@ doRemoteOpen(virConnectPtr conn, size_t i; int proxy; =20 - if (inside_daemon && !conn->uri->server) { - mode =3D REMOTE_DRIVER_MODE_DIRECT; - } else { - mode =3D REMOTE_DRIVER_MODE_AUTO; - } - - /* Historically we didn't allow ssh tunnel with session mode, - * since we can't construct the accurate path remotely, - * so we can default to modern virt-ssh-helper */ - if (flags & REMOTE_DRIVER_OPEN_USER) - proxy =3D VIR_NET_CLIENT_PROXY_NATIVE; - else - proxy =3D VIR_NET_CLIENT_PROXY_AUTO; - /* We handle *ALL* URIs here. The caller has rejected any * URIs we don't care about */ =20 @@ -857,22 +843,38 @@ doRemoteOpen(virConnectPtr conn, virConfGetValueString(conf, "remote_mode", &mode_str) < 0) goto failed; =20 - if (mode_str && - (mode =3D remoteDriverModeTypeFromString(mode_str)) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Unknown remote mode '%s'"), mode_str); - goto failed; + if (mode_str) { + if ((mode =3D remoteDriverModeTypeFromString(mode_str)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Unknown remote mode '%s'"), mode_str); + goto failed; + } + } else { + if (inside_daemon && !conn->uri->server) { + mode =3D REMOTE_DRIVER_MODE_DIRECT; + } else { + mode =3D REMOTE_DRIVER_MODE_AUTO; + } } =20 if (conf && !proxy_str && virConfGetValueString(conf, "remote_proxy", &proxy_str) < 0) goto failed; =20 - if (proxy_str && - (proxy =3D virNetClientProxyTypeFromString(proxy_str)) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Unnkown proxy type '%s'"), proxy_str); - goto failed; + if (proxy_str) { + if ((proxy =3D virNetClientProxyTypeFromString(proxy_str)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Unnkown proxy type '%s'"), proxy_str); + goto failed; + } + } else { + /* Historically we didn't allow ssh tunnel with session mode, + * since we can't construct the accurate path remotely, + * so we can default to modern virt-ssh-helper */ + if (flags & REMOTE_DRIVER_OPEN_USER) + proxy =3D VIR_NET_CLIENT_PROXY_NATIVE; + else + proxy =3D VIR_NET_CLIENT_PROXY_AUTO; } =20 /* Sanity check that nothing requested !direct mode by mistake */ --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035276; cv=none; d=zohomail.com; s=zohoarc; b=Y+ADA1SyEohsasLe+V+QnfY5Gq1xvA92mFB45qVgHtqSB59lv+YceNHSwHRwHSSYky8z9Adz5QWKF5kVDTDtHi7XiT+8dg+f7wKp8U2CoLwYfq3J/hc4pq/nM6HrzJMp0AyVzAObaE2c5dbwkmyxTRqeq5BZ7UBNgt7JaBMy598= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035276; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X+IgKggzkjWbI7x2fS2CZV2QEW/FBjzUugbctPExz3E=; b=kl/vIDcSpwZovXWSGItl/i4ZJtwKrp/Bfj2zQeXtR8LzySQFU8H/RqQsLQNB1nOhd+lv/C1xAC9oLyOR7G5QvgjBP9fodOp3fM+Nndpcm5qV+CCLIzQAwwLC86Sz5r8KGYVUGoAinPS6GJM/meatm8VNW9yupxc7q8I1E6epmN8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1622035276770150.12480232215785; Wed, 26 May 2021 06:21:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-ug5TTgAUM4aDLIwFSBNw7g-1; Wed, 26 May 2021 09:21:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CEF0E1020C36; Wed, 26 May 2021 13:21:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D835629DA; Wed, 26 May 2021 13:21:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A4E1C5534F; Wed, 26 May 2021 13:21:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKYlM022423 for ; Wed, 26 May 2021 09:20:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1517D2DAC5; Wed, 26 May 2021 13:20:34 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F4785B826; Wed, 26 May 2021 13:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035275; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=X+IgKggzkjWbI7x2fS2CZV2QEW/FBjzUugbctPExz3E=; b=jJ6+naB0nj0KU1sjaFebewb/UJ3O/2/uhRw1pkCCRofxkmOqiEKZgS7fSjIjB9qKW8B2sF IeszewYYnkk8NZ9ulG6rzrqFYBu2nI4qUGc9q7LOZIinYNfrBoss4AjGUSCfi+9PbXjPgQ 3yzOD3DthxK4wThG6eCNE/0cgip7VdE= X-MC-Unique: ug5TTgAUM4aDLIwFSBNw7g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/10] remote: fix regression connecting to remote session daemon Date: Wed, 26 May 2021 14:20:16 +0100 Message-Id: <20210526132017.273817-10-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) While we couldn't historically connect to the remote session daemon automatically, we do allow the user to set an explicit socket path to enable the connections to work. This ability was accidentally lost in commit f8ec7c842df9e40c6607eae9b0223766cb226336 Author: Daniel P. Berrang=C3=A9 Date: Wed Jul 8 17:03:38 2020 +0100 rpc: use new virt-ssh-helper binary for remote tunnelling We need to force use of 'netcat' when a 'socket' path is given in the URI parameters. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_driver.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6a881fff28..da672b0d00 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -868,10 +868,33 @@ doRemoteOpen(virConnectPtr conn, goto failed; } } else { - /* Historically we didn't allow ssh tunnel with session mode, - * since we can't construct the accurate path remotely, - * so we can default to modern virt-ssh-helper */ - if (flags & REMOTE_DRIVER_OPEN_USER) + /* + * Goal is to maximise usage of virt-ssh-helper + * + * Historically tunnelling access for the session mode + * daemon did not automatically work, since we can't + * construct the accurate path remotely. Users could, + * however, specify the 'socket' URI parameter explicitly. + * + * If we see a 'socket' path we must always use netcat, + * since virt-ssh-helper won't handle an explicit socket. + * Autostart won't work for session mode, so we assume + * user started it manually on the remote host in this + * case. + * + * If we have a 'session' URI without explicit socket, + * we can just assume the use of virt-ssh-helper, since + * logic for constructing socket paths relies on env + * envs whose values have no guarantee of matching those + * on the remote host. It was explicitly blocked with an + * error check before virt-ssh-helper was introduced. + * + * For 'system' URIs, we need to try virt-ssh-helper but + * with fallback to netcat for back compat. + */ + if (sockname) + proxy =3D VIR_NET_CLIENT_PROXY_NETCAT; + else if (flags & REMOTE_DRIVER_OPEN_USER) proxy =3D VIR_NET_CLIENT_PROXY_NATIVE; else proxy =3D VIR_NET_CLIENT_PROXY_AUTO; --=20 2.31.1 From nobody Fri May 17 03:54:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622035280; cv=none; d=zohomail.com; s=zohoarc; b=V2Om0VzMqrtFGDH1rL0XS7KES0mNJI5M+fUOvC13qVk66idKYNiCfOq4DUuzEeBPQHW1d1ERtx9lZyK2TZz6uX/2NmYz24qnTKVslhNmRu8b9h0+Fs2e0f2mr34ZToxlnfcRMoKXvLQ2QjPYh2YPkHifHAviWgSbc1BwuKl1mqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622035280; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RQ9ottrmw8C7c/rcLrwjS1Ys7PGFCI/orHcvuEk7yT0=; b=m8TLlgSBEToFySyYH+vBSCmzeYUTRAXvSwCZn3pJZLOaPs7rIcP8vYSho+Yv0ZKK662vnMknwfl9HLd+WjZpLLmymNjZF3/XN5OO+cgRdNa7s2P4AQFA1p0H6Q3HUq3syAhpVA0LkfmYgkHYFcLJMAfFRpm9NtYYknAZdXO1A+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1622035280259603.5686279645269; Wed, 26 May 2021 06:21:20 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-wL8TPA0FOp6YLADFLHycSA-1; Wed, 26 May 2021 09:21:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DCAD19253CA; Wed, 26 May 2021 13:21:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50D5060CCD; Wed, 26 May 2021 13:21:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F2D58180B465; Wed, 26 May 2021 13:21:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14QDKZax022430 for ; Wed, 26 May 2021 09:20:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4018D51150; Wed, 26 May 2021 13:20:35 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-19.ams2.redhat.com [10.36.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8175150B44; Wed, 26 May 2021 13:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622035279; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RQ9ottrmw8C7c/rcLrwjS1Ys7PGFCI/orHcvuEk7yT0=; b=agMGbge1sFPMvi/htw2F1eC/7wEx7PcDBUnGI9EBliO2zNEDsVClBzaulvxAXLVaGc1D9Y PY4vUeRYbw0GjD1AbyJJHmOsq3zreZp7gBRIN4zfCH5yzdqKa75fOMEPowjlu00pczsv13 VUCatBVFPrdANBxb6xISOCeWWCc6JyY= X-MC-Unique: wL8TPA0FOp6YLADFLHycSA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/10] remote: use virtproxyd if no URI is given Date: Wed, 26 May 2021 14:20:17 +0100 Message-Id: <20210526132017.273817-11-berrange@redhat.com> In-Reply-To: <20210526132017.273817-1-berrange@redhat.com> References: <20210526132017.273817-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) When the default driver mode requests the modular daemons, we still defaulted to spawning libvirtd if the URI was NULL, because we don't know which driver specific daemon to spawn. virtproxyd has logic that can handle this as it is used for compatibility when accepting incoming TCP connections with a NULL URI. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_sockets.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index cce6703e75..ed4e4a329c 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -171,14 +171,15 @@ remoteGetUNIXSocket(remoteDriverTransport transport, remoteDriverModeTypeToString(mode), driver, flags); =20 - if (driver) + if (driver) { direct_daemon =3D g_strdup_printf("virt%sd", driver); - - legacy_daemon =3D g_strdup("libvirtd"); - - if (driver) direct_sock_name =3D remoteGetUNIXSocketHelper(transport, direct_d= aemon, flags); + } else { + direct_daemon =3D g_strdup("virtproxyd"); + direct_sock_name =3D remoteGetUNIXSocketHelper(transport, "libvirt= ", flags); + } =20 + legacy_daemon =3D g_strdup("libvirtd"); legacy_sock_name =3D remoteGetUNIXSocketHelper(transport, "libvirt", f= lags); =20 if (mode =3D=3D REMOTE_DRIVER_MODE_AUTO) { @@ -187,14 +188,12 @@ remoteGetUNIXSocket(remoteDriverTransport transport, mode =3D REMOTE_DRIVER_MODE_DIRECT; } else if (virFileExists(legacy_sock_name)) { mode =3D REMOTE_DRIVER_MODE_LEGACY; - } else if (driver) { + } else { /* * This constant comes from the configure script and * maps to either the direct or legacy mode constant */ mode =3D REMOTE_DRIVER_MODE_DEFAULT; - } else { - mode =3D REMOTE_DRIVER_MODE_LEGACY; } } else { mode =3D REMOTE_DRIVER_MODE_LEGACY; --=20 2.31.1