From nobody Fri May 10 00:59:16 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) 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 1698840205544565.5617430641253; Wed, 1 Nov 2023 05:03:25 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2B68217BC; Wed, 1 Nov 2023 08:03:24 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id BFDD91769; Wed, 1 Nov 2023 08:02:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 535C3176A; Wed, 1 Nov 2023 08:01:59 -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 C6D7D173E for ; Wed, 1 Nov 2023 08:01:58 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-J1zoWbMEMuy9Jg2aTRtjKA-1; Wed, 01 Nov 2023 08:01:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD8A61DD35C6 for ; Wed, 1 Nov 2023 12:01:56 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.42.28.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EC002026D4C; Wed, 1 Nov 2023 12:01:56 +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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: J1zoWbMEMuy9Jg2aTRtjKA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [libvirt PATCH v2] rpc: don't try to spawn non-existant daemon Date: Wed, 1 Nov 2023 12:01:55 +0000 Message-ID: <20231101120155.3179397-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NGLJ6GNKBMQXKZWKXJK24UKYHYRIKV5I X-Message-ID-Hash: NGLJ6GNKBMQXKZWKXJK24UKYHYRIKV5I X-MailFrom: berrange@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-ZM-MESSAGEID: 1698840207870100001 Content-Type: text/plain; charset="utf-8" If libvirt is built in client only mode, the libvirtd/virtqemud/etc daemons won't exist. If the client is told to connect to a local hypervisor, it'll see the socket doesn't exist, try to spawn the daemon and then re-try connecting to the socket for a few seconds. Ultimately this will fail because the daemon doesn't exist and the user gets an error message error: Failed to connect socket to '/run/user/1000/libvirt/virtqemud-sock= ': No such file or directory technically this is accurate, but it doesn't help identify the root cause. With this change it will now report error: binary 'virtqemud' does not exist in $PATH: No such file or direct= ory and will skip all the socket connect retries Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michal Privoznik --- Last time it was suggested that virCommandGetBinaryPath could be extended to always check whether the binary exists. I started doing that and realized it was a bad idea as this method runs in a context which might not have permission to access to the binary we are about to run, as we've not changed user/group ID yet. So I'm re-posting this targetted fix, with format string fixup. src/rpc/virnetsocket.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index b58f7a6b8f..0215c99c73 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -123,9 +123,19 @@ VIR_ONCE_GLOBAL_INIT(virNetSocket); #ifndef WIN32 static int virNetSocketForkDaemon(const char *binary) { - g_autoptr(virCommand) cmd =3D virCommandNewArgList(binary, - "--timeout=3D120", - NULL); + g_autofree char *binarypath =3D virFindFileInPath(binary); + g_autoptr(virCommand) cmd =3D NULL; + + if (!binarypath) { + virReportSystemError(ENOENT, + _("binary '%1$s' does not exist in $PATH"), + binary); + return -1; + } + + cmd =3D virCommandNewArgList(binarypath, + "--timeout=3D120", + NULL); =20 virCommandAddEnvPassCommon(cmd); virCommandAddEnvPass(cmd, "XDG_CACHE_HOME"); --=20 2.41.0