From nobody Sat May 18 08:14:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1662650181; cv=none; d=zohomail.com; s=zohoarc; b=RtaSjXYKvkvt0WEg6vFggukEB9c56x/4o9JF31lVbeqn1u8z3jkcxZMcVTND0/yxHCzV2HPuZCerwYe7F2Kq4zwD4i1P9HIyvW1Z6RL2XplPy6E+DkIgMEdJS7SZxdtnEZBnYO+qAFccqTcFSYkjydCgcd14SiSf6KEl8ZcRs4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662650181; 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=J7+8yuL85XVuhF+/8KsHf+t50gvCNXtae5OfScvdryg=; b=Gr1BqAextexVcWa1e+7ti39sr4sVwKkXe2TrTZQ34UZ6ocbdtpLy1rY4K8B5uz7SVFbsD4GOz6pYaBcjovPc289P98xc2B5lZyz3GNGSV+s8sqcEwCUjYGGWSjfmPNE6MMlc+9NppiEjK30epasXGBU5cUYoFGl3QSYN+p6dxhA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1662650181329435.5379271588761; Thu, 8 Sep 2022 08:16:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-PVxHO9v3OLmx2FbI2uY73Q-1; Thu, 08 Sep 2022 11:16:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84505803C9F; Thu, 8 Sep 2022 15:16:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DBF640CF8F0; Thu, 8 Sep 2022 15:16:05 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3E7121946A44; Thu, 8 Sep 2022 15:16:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8EA5D1946A41 for ; Thu, 8 Sep 2022 15:16:03 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7D6E91415133; Thu, 8 Sep 2022 15:16:03 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id ECB011410F36 for ; Thu, 8 Sep 2022 15:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662650180; 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=J7+8yuL85XVuhF+/8KsHf+t50gvCNXtae5OfScvdryg=; b=ewoklwzGD93ZJOC11pYK9pWaP6opx9kHIa7Gf7kb+fIxo7Xn/edQphsY4+HtbnyIpPfncs CyPBSyYAohEssBM1ehJjk6/Fhp9BNE9clqoFvTRtWZYLMc+fjqBOjkDHai00UIAhxqYaVW u4ah2eDu1T676hmr3ceoMPzzvVKlS7Y= X-MC-Unique: PVxHO9v3OLmx2FbI2uY73Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/6] virConnectOpenInternal: Avoid double free() when alias is an invalid URI Date: Thu, 8 Sep 2022 17:15:55 +0200 Message-Id: <2ad2a9c44ee444a5f5f51c8dc97bb172921a74e6.1662650080.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1662650182438100003 Content-Type: text/plain; charset="utf-8" Configuring an URI alias such as uri_aliases =3D [ "blah=3Dqemu://invaliduri@@@", ] Results in a double free when the alias is used: $ virsh -c blah free(): double free detected in tcache 2 Aborted (core dumped) This happens as the 'alias' variable is first assigned to 'uristr' which is cleared in the 'failed' label and then is explicitly freed again. Fix this by switching to 'g_autofree' for alias and stealing it into 'uristr'. Signed-off-by: Peter Krempa --- src/libvirt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index b78b49a632..7e7c0fc8e3 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -933,21 +933,19 @@ virConnectOpenInternal(const char *name, } if (uristr) { - char *alias =3D NULL; + g_autofree char *alias =3D NULL; if (!(flags & VIR_CONNECT_NO_ALIASES) && virURIResolveAlias(conf, uristr, &alias) < 0) goto failed; if (alias) { - VIR_FREE(uristr); - uristr =3D alias; + g_free(uristr); + uristr =3D g_steal_pointer(&alias); } - if (!(ret->uri =3D virURIParse(uristr))) { - VIR_FREE(alias); + if (!(ret->uri =3D virURIParse(uristr))) goto failed; - } /* Avoid need for drivers to worry about NULLs, as * no one needs to distinguish "" vs NULL */ --=20 2.37.1 From nobody Sat May 18 08:14:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1662650181; cv=none; d=zohomail.com; s=zohoarc; b=mRH/j5SrTS/SQTU2mSkZzN+jswlD5tvQlyqTnow/+iTlHiYSpxU8pcfak34/zZdN+HNTwxO/SZnRxlPPEwoxHt2Q4EwPChsPmpnLPcmQRsaWUc7wH2nNpkPpTKN/XGBPZpYgIpXX5C+t/oQY+2vfBox17IF3GIr7/Lg0xQmmgRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662650181; 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=gZARYz9DSHWg8WqXvHu7xSs+4m/eFmpX6yfkBbNysg0=; b=iTYMBF3H54Uuezh4NSIwygrc9KnFDaHPPVXAzKxpAEFuFiVa2XqDVp0i9siW0xSyUJzhao4nMHb48EoWj+SKMa1LZjW24dvAJD5rRNHlvfd2ZWxgKGJ4SwuEb+RICiw4hk3CAVB8UOLUy1SE9XgwgUlcGTlbZkpmf+a1NbXvMoQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1662650181377605.5589879826791; Thu, 8 Sep 2022 08:16:21 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-373-wN4l4cPePluu4q_dNpT_bQ-1; Thu, 08 Sep 2022 11:16:17 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C362F1C03374; Thu, 8 Sep 2022 15:16:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEAFEC15BB3; Thu, 8 Sep 2022 15:16:06 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 80A4E1946A44; Thu, 8 Sep 2022 15:16:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 700651946A41 for ; Thu, 8 Sep 2022 15:16:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 633AF1410F37; Thu, 8 Sep 2022 15:16:04 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D299A14152E0 for ; Thu, 8 Sep 2022 15:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662650179; 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=gZARYz9DSHWg8WqXvHu7xSs+4m/eFmpX6yfkBbNysg0=; b=E0pm5o6aB8pGDXXAogBwjRoHa5EPmjzHvu27W3ziSW07JI+scWY0UkLBlph9XK12KvJiKp tsm0flgGa7SJI11N7GQECv6R9AfzZ2hKXMwwscdiTc2v49ZrhAiPlfNOyvUVucn5Yvg3om FTQu58X0oPCbvVLfoEuK36awwrcRN3M= X-MC-Unique: wN4l4cPePluu4q_dNpT_bQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/6] virConnectOpenInternal: Switch to automatic memory cleanup Date: Thu, 8 Sep 2022 17:15:56 +0200 Message-Id: <8b65ac655c8fb0ff514a7fe3e69707bc8b7c49c9.1662650080.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1662650182438100004 Content-Type: text/plain; charset="utf-8" Use automatic cleanup for 'ret' and 'uristr'. Signed-off-by: Peter Krempa --- src/libvirt.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 7e7c0fc8e3..fca38dba40 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -882,9 +882,9 @@ virConnectOpenInternal(const char *name, { size_t i; int res; - virConnectPtr ret; + g_autoptr(virConnect) ret =3D NULL; g_autoptr(virConf) conf =3D NULL; - char *uristr =3D NULL; + g_autofree char *uristr =3D NULL; bool embed =3D false; ret =3D virGetConnect(); @@ -1151,14 +1151,9 @@ virConnectOpenInternal(const char *name, goto failed; } - VIR_FREE(uristr); - - return ret; + return g_steal_pointer(&ret); failed: - VIR_FREE(uristr); - virObjectUnref(ret); - return NULL; } --=20 2.37.1 From nobody Sat May 18 08:14:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1662650199; cv=none; d=zohomail.com; s=zohoarc; b=bT79kHDN0cwOIqfqkbD6hoTtdXicqJdhbRipnrAB/Cbf7NoM0OVoWTGNLwPqWVzdRA9bEK8AsVzC4XlUdOUWhCBtdLiWfgZpSaBjWbNvBRUuC5Z8kekmN35/XbA/PlacjmQM9OyLgemHGSk8tc6De9bRdeMKyRVjqIPkUqd6Oeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662650199; 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=mrsQ4eS2jY78cYIGymLe2Gw6emgKI/8cWyT7we9Q4no=; b=f68qbzXXixYx14turlSCkvX1Fnj73jU/C6BdcQF2BdGUx6HuQKhZthKQIwUmNNrDBQCHX9NeauxZ8ylZ6YnaC1JKwT1yrKd2fG+mYMOETR4BPQy4DT04Y7gG8VgFml7g2wzIuCAuzNxCzjqklyJI0cAEJ9MAaca6bVc041urlM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1662650199595131.49019558588702; Thu, 8 Sep 2022 08:16:39 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-ivSlktRNOvaxiIFAAMwefQ-1; Thu, 08 Sep 2022 11:16:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3230818A01C8; Thu, 8 Sep 2022 15:16:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C489945DF; Thu, 8 Sep 2022 15:16:07 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C2C0B1946A5E; Thu, 8 Sep 2022 15:16:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AF28D1946A41 for ; Thu, 8 Sep 2022 15:16:05 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 844C71410F37; Thu, 8 Sep 2022 15:16:05 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1CE71410F36 for ; Thu, 8 Sep 2022 15:16:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662650197; 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=mrsQ4eS2jY78cYIGymLe2Gw6emgKI/8cWyT7we9Q4no=; b=OaQDwOMggvsjG33R3z49bspOH132poaQ5U958Z4CVnOOm4Tto8qwfN4J3+1WlCXap9Ya6P njTGoZ26X2PM9JQpTXF0VUpxTyMAhcWuu8dVDnD+E8ba/OYsS0zSqFxuBhtO+ThtlZrhJZ bMjMK/7DvQ8AYl0AffZDHru8HSa+ScQ= X-MC-Unique: ivSlktRNOvaxiIFAAMwefQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/6] virConnectOpenInternal: Remove 'failed' label Date: Thu, 8 Sep 2022 17:15:57 +0200 Message-Id: <28eb7b84d43f50d51c19c331a3c44887c8666452.1662650080.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1662650200667100001 Content-Type: text/plain; charset="utf-8" Jumping to the label would just return NULL. Signed-off-by: Peter Krempa --- src/libvirt.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index fca38dba40..d5ae68d16f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -892,7 +892,7 @@ virConnectOpenInternal(const char *name, return NULL; if (virConfLoadConfig(&conf, "libvirt.conf") < 0) - goto failed; + return NULL; if (name && name[0] =3D=3D '\0') name =3D NULL; @@ -916,14 +916,14 @@ virConnectOpenInternal(const char *name, uristr =3D g_strdup(name); } else { if (virConnectGetDefaultURI(conf, &uristr) < 0) - goto failed; + return NULL; if (uristr =3D=3D NULL) { VIR_DEBUG("Trying to probe for default URI"); for (i =3D 0; i < virConnectDriverTabCount && uristr =3D=3D NU= LL; i++) { if (virConnectDriverTab[i]->hypervisorDriver->connectURIPr= obe) { if (virConnectDriverTab[i]->hypervisorDriver->connectU= RIProbe(&uristr) < 0) - goto failed; + return NULL; VIR_DEBUG("%s driver URI probe returned '%s'", virConnectDriverTab[i]->hypervisorDriver->na= me, NULLSTR(uristr)); @@ -937,7 +937,7 @@ virConnectOpenInternal(const char *name, if (!(flags & VIR_CONNECT_NO_ALIASES) && virURIResolveAlias(conf, uristr, &alias) < 0) - goto failed; + return NULL; if (alias) { g_free(uristr); @@ -945,7 +945,7 @@ virConnectOpenInternal(const char *name, } if (!(ret->uri =3D virURIParse(uristr))) - goto failed; + return NULL; /* Avoid need for drivers to worry about NULLs, as * no one needs to distinguish "" vs NULL */ @@ -967,12 +967,12 @@ virConnectOpenInternal(const char *name, virReportError(VIR_ERR_NO_CONNECT, _("URI '%s' does not include a driver name"), name); - goto failed; + return NULL; } if (virConnectCheckURIMissingSlash(uristr, ret->uri) < 0) { - goto failed; + return NULL; } if (STREQ(ret->uri->path, "/embed")) { @@ -985,26 +985,26 @@ virConnectOpenInternal(const char *name, virReportError(VIR_ERR_NO_CONNECT, _("URI scheme '%s' for embedded driver is n= ot valid"), ret->uri->scheme); - goto failed; + return NULL; } root =3D virURIGetParam(ret->uri, "root"); if (!root) - goto failed; + return NULL; if (!g_path_is_absolute(root)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("root path must be absolute")); - goto failed; + return NULL; } if (virEventRequireImpl() < 0) - goto failed; + return NULL; regMethod =3D g_strdup_printf("%sRegister", ret->uri->scheme); if (virDriverLoadModule(ret->uri->scheme, regMethod, false) < = 0) - goto failed; + return NULL; if (virAccessManagerGetDefault() =3D=3D NULL) { virAccessManager *acl; @@ -1012,12 +1012,12 @@ virConnectOpenInternal(const char *name, virResetLastError(); if (!(acl =3D virAccessManagerNew("none"))) - goto failed; + return NULL; virAccessManagerSetDefault(acl); } if (virStateInitialize(geteuid() =3D=3D 0, true, root, NULL, N= ULL) < 0) - goto failed; + return NULL; embed =3D true; } @@ -1055,7 +1055,7 @@ virConnectOpenInternal(const char *name, __FILE__, __FUNCTION__, __LINE__, _("libvirt was built without the '%s' dri= ver"), ret->uri->scheme); - goto failed; + return NULL; } VIR_DEBUG("trying driver %zu (%s) ...", @@ -1105,13 +1105,13 @@ virConnectOpenInternal(const char *name, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Driver %s cannot be used in embedded mode"), virConnectDriverTab[i]->hypervisorDriver->name); - goto failed; + return NULL; } /* before starting the new connection, check if the driver only wo= rks * with a server, and so return an error if the server is missing = */ if (virConnectDriverTab[i]->remoteOnly && ret->uri && !ret->uri->s= erver) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("URI is missing th= e server part")); - goto failed; + return NULL; } ret->driver =3D virConnectDriverTab[i]->hypervisorDriver; @@ -1141,20 +1141,17 @@ virConnectOpenInternal(const char *name, ret->storageDriver =3D NULL; if (res =3D=3D VIR_DRV_OPEN_ERROR) - goto failed; + return NULL; } } if (!ret->driver) { /* If we reach here, then all drivers declined the connection. */ virReportError(VIR_ERR_NO_CONNECT, "%s", NULLSTR(name)); - goto failed; + return NULL; } return g_steal_pointer(&ret); - - failed: - return NULL; } --=20 2.37.1 From nobody Sat May 18 08:14:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1662650180; cv=none; d=zohomail.com; s=zohoarc; b=Bwgg9jYrWBAADxvdeeEb/8GMUBzxuOq3cX7iNqA5SaiX0hwRq8HJN8QlaXTsUuX3uRZwo+JYJCEJpnDyrimIiIMZSDZUM5unBtcT3gbzplyvreIYWk77a8M/JuosYyZqSQPJK1/SPyRczmuo8e6puzfYStD3BWyLm3pgUhqjc+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662650180; 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=02AwTtRYuY8iieRmb+bsVRYpJzRFt+pRcD4FHguLyUU=; b=np4tmzCWJGDlg2OBUhyTbH1N+R8JxHoie+cC4VM8BkXQahs6YISwaR0wENHGRsZr4KcsYblIqCEXsgan+TcrcCBGKEndctkxlwK+Z9cu3Kp9KSBERtDss8W0LpnLKXbh9LSYcH/BXTTeSyQVw+lkD7UyJtGd02td4Nb4C6hWrMs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1662650180050159.16365753985554; Thu, 8 Sep 2022 08:16:20 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-461-Qn3ts-gyMryOK4oiW3x4lg-1; Thu, 08 Sep 2022 11:16:16 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 528388EB188; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FEDE1410F36; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0E2951946A44; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 992F91946A41 for ; Thu, 8 Sep 2022 15:16:06 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6D12814171FE; Thu, 8 Sep 2022 15:16:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5BF61410F38 for ; Thu, 8 Sep 2022 15:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662650179; 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=02AwTtRYuY8iieRmb+bsVRYpJzRFt+pRcD4FHguLyUU=; b=Y+kzuwi2xzwKGR0o1xhuWyiryCZb8WfWQWrOamStY/qb+/o1uERxuAof0+ItRRB/Dpa+nD 6YRR3QxIcf6BGnGSkkt6/zlp/XOcoVKbo/pOKlT49r0BbAvVmqS8pLOVCpFrXOeaKF5ID1 Mx8aGOjUxHjT4O30BSTdMsLvgRybF2w= X-MC-Unique: Qn3ts-gyMryOK4oiW3x4lg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/6] remote: remoteOpenConn: Use virConnectOpenAuth instead of virConnectOpen(ReadOnly) Date: Thu, 8 Sep 2022 17:15:58 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1662650180471100001 Content-Type: text/plain; charset="utf-8" virConnectOpenAuth provides an unified interface with using 'flags' to select the proper mode. Signed-off-by: Peter Krempa --- src/remote/remote_daemon_dispatch.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index dc5790f077..061e0f7811 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1790,6 +1790,7 @@ remoteOpenConn(const char *uri, { g_autoptr(virTypedParamList) identparams =3D NULL; g_autoptr(virConnect) newconn =3D NULL; + unsigned int connectFlags =3D 0; VIR_DEBUG("Getting secondary uri=3D%s readonly=3D%d preserveIdent=3D%d= conn=3D%p", NULLSTR(uri), readonly, preserveIdentity, conn); @@ -1814,11 +1815,9 @@ remoteOpenConn(const char *uri, VIR_DEBUG("Opening driver %s", uri); if (readonly) - newconn =3D virConnectOpenReadOnly(uri); - else - newconn =3D virConnectOpen(uri); + connectFlags |=3D VIR_CONNECT_RO; - if (!newconn) + if (!(newconn =3D virConnectOpenAuth(uri, NULL, connectFlags))) return -1; VIR_DEBUG("Opened driver %p", newconn); --=20 2.37.1 From nobody Sat May 18 08:14:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1662650232; cv=none; d=zohomail.com; s=zohoarc; b=lFjXyvPJwLwgOLhLVvZrWTRbNVcEnxyauEiOfJ49SsdO1rWyNtkkjiKKGOZWANzTQCxNtK19TEcvmgoNknv0iygRggIaupph6dtU7LZ+3yWtYUdWH9cntlxIgcO74qdVyzW4/YJuiGVFLRfmuQ8r0dj7X9dTZ1O6Ht3zOutTR2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662650232; 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=3uDFZZHKP9nuyjMqlPFyXlXsLAQVuevMcflNEYFBDl8=; b=cGek8Ullb8BV6XxN/0HayDi8ARjsaIxl3s1QLfJmE7AoGfByja3IqKuK4lRW/dug/7cIB00eIhumVBHcu4BFSId67vLKQlD+mbL1J7u0Qyd+inmeBazjyBFcuj/yON7lsgglHjEVzzHA8BSf0WTD0wX+wy1SRWXtVeFPefPmJl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1662650232440297.590859722613; Thu, 8 Sep 2022 08:17:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-WipVrhukP4GXfuHwdVbGhA-1; Thu, 08 Sep 2022 11:16:18 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CBBD58218F2; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B39E414152E6; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64E9F1946A55; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 728F61946A41 for ; Thu, 8 Sep 2022 15:16:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 568011410F36; Thu, 8 Sep 2022 15:16:07 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6858141512E for ; Thu, 8 Sep 2022 15:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662650231; 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=3uDFZZHKP9nuyjMqlPFyXlXsLAQVuevMcflNEYFBDl8=; b=GQTOlSBhAMyvsMjkYP0LSpLKeAFaPdUUA3sHjrgSwh9vf2zzzbWWskLOxv79uZl24lLsCv KK8M5zzf6ceEmxMoB1e34+KIkoWuo29dpD6X4+1KvDJLAu1tEBgjAEXWxiL78JMJ3ICQBo QAawHPZZv0QuF+nS0gxV4YAwJDTvVOo= X-MC-Unique: WipVrhukP4GXfuHwdVbGhA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/6] Introduce VIR_CONNECT_NO_REMOTE Date: Thu, 8 Sep 2022 17:15:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1662650232808100001 Content-Type: text/plain; charset="utf-8" Introduce a new virConnectFlags flag that will allow to avoid the use of the 'remote' driver. While this flag itself is not useful for users, in case when monolithic libvirtd is in use we want to avoid further delegation of connection, which can happen if libvirtd is not compiled with the requested driver. Add and implement the new flag. Signed-off-by: Peter Krempa --- include/libvirt/libvirt-host.h | 2 ++ src/libvirt.c | 38 +++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 3112f2b676..463b3f78af 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -602,6 +602,8 @@ int virNodeGetSEVInfo (virConnectPtr conn, typedef enum { VIR_CONNECT_RO =3D (1 << 0), /* A readonly connection (Since:= 0.4.1) */ VIR_CONNECT_NO_ALIASES =3D (1 << 1), /* Don't try to resolve URI alia= ses (Since: 0.9.7) */ + VIR_CONNECT_NO_REMOTE =3D (1 << 2), /* Avoid use of the remote drive= r. Users + should not use this flag. (Sinc= e: 8.8.0) */ } virConnectFlags; /** diff --git a/src/libvirt.c b/src/libvirt.c index d5ae68d16f..5312265619 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -886,6 +886,9 @@ virConnectOpenInternal(const char *name, g_autoptr(virConf) conf =3D NULL; g_autofree char *uristr =3D NULL; bool embed =3D false; + bool no_remote =3D flags & VIR_CONNECT_NO_REMOTE; + + flags &=3D ~VIR_CONNECT_NO_REMOTE; ret =3D virGetConnect(); if (ret =3D=3D NULL) @@ -1036,26 +1039,33 @@ virConnectOpenInternal(const char *name, * driver then report a useful error, instead of a cryptic one abo= ut * not being able to connect to libvirtd or not being able to find * certificates. */ - if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, "remote"= ) && - ret->uri !=3D NULL && - ( + if (STREQ(virConnectDriverTab[i]->hypervisorDriver->name, "remote"= )) { + + if (ret->uri !=3D NULL && + ( #ifndef WITH_ESX - STRCASEEQ(ret->uri->scheme, "vpx") || - STRCASEEQ(ret->uri->scheme, "esx") || - STRCASEEQ(ret->uri->scheme, "gsx") || + STRCASEEQ(ret->uri->scheme, "vpx") || + STRCASEEQ(ret->uri->scheme, "esx") || + STRCASEEQ(ret->uri->scheme, "gsx") || #endif #ifndef WITH_HYPERV - STRCASEEQ(ret->uri->scheme, "hyperv") || + STRCASEEQ(ret->uri->scheme, "hyperv") || #endif #ifndef WITH_VZ - STRCASEEQ(ret->uri->scheme, "parallels") || + STRCASEEQ(ret->uri->scheme, "parallels") || #endif - false)) { - virReportErrorHelper(VIR_FROM_NONE, VIR_ERR_CONFIG_UNSUPPORTED, - __FILE__, __FUNCTION__, __LINE__, - _("libvirt was built without the '%s' dri= ver"), - ret->uri->scheme); - return NULL; + false)) { + virReportErrorHelper(VIR_FROM_NONE, VIR_ERR_CONFIG_UNSUPPO= RTED, + __FILE__, __FUNCTION__, __LINE__, + _("libvirt was built without the '%s'= driver"), + ret->uri->scheme); + return NULL; + } + + if (no_remote) { + VIR_DEBUG("skipping 'remote' per VIR_CONNECT_NO_REMOTE"); + continue; + } } VIR_DEBUG("trying driver %zu (%s) ...", --=20 2.37.1 From nobody Sat May 18 08:14:10 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1662650236; cv=none; d=zohomail.com; s=zohoarc; b=Hj92u3D80SOkojJIgNsFGT19Yr288Dza6Yfoz37ZVNNq4Th52GsWljbELAD1SPffpRtb6zbLY6zAr7tXoS0rJLLQEp5/4vx+FtMHBxyz5k+DB5/G77Zpp+OhVZ08D2jY6TKEZx6rxRcaGl4cxbfXPEPtzZHQ7sZYe90BHZCCp78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662650236; 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=9aN59B/OzlDQT+2J3Q3yVvAer7r06yl5mj2VPbza7SI=; b=jGAHgnZwxm7IL0Wlsoi7n5HTpfC0T57T8KykN3er8wC/m+Km0M0I8i1R6lGK1UXPP1CoYqyJOSe2ryFNDdKiv1NvM/+VzW/eWIi4/Pv99MHrukMg+hsvvE+5D2ZUKID3DW8Cl5cn1GsxRQ5l2AZ9jVMvCKyscTuYGYv1WEX4A0Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1662650236392353.3964672965484; Thu, 8 Sep 2022 08:17:16 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-XmHDNcehOVezroBMcWf6Fg-1; Thu, 08 Sep 2022 11:16:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 651D118A06B5; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 514F42166B26; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1E4DA1946A55; Thu, 8 Sep 2022 15:16:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 562931946A41 for ; Thu, 8 Sep 2022 15:16:08 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3C37A14152E2; Thu, 8 Sep 2022 15:16:08 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE7D014152E3 for ; Thu, 8 Sep 2022 15:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662650234; 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=9aN59B/OzlDQT+2J3Q3yVvAer7r06yl5mj2VPbza7SI=; b=WvcDMWIBCdQUz0KQaDANNcUji4Co0lmGnbJDmHED5QJCdp20vHe6NiHk/zXfrF1Rz1gjRK NADJsPG01zgnB92uTc9+eparu5/ABUfKzmqljDyKPIAxMKshOd05nrEZHks2iVBKm2wFZ+ 53Q/P9f/nQVsGJUaXCCCa/tt9tPJnV0= X-MC-Unique: XmHDNcehOVezroBMcWf6Fg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 6/6] remote: Don't attempt remote connection from libvirtd Date: Thu, 8 Sep 2022 17:16:00 +0200 Message-Id: <0948fe2d966df5c31c15cd031144de8afcce7bfb.1662650080.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1662650236840100001 Content-Type: text/plain; charset="utf-8" When a hypervisor driver is not compiled in and a user enables the monolithic libvirtd, they get the following misleading error: $ virsh -c qemu:///system error: failed to connect to the hypervisor error: Failed to connect socket to '/var/run/libvirt/virtqemud-sock': No = such file or directory The issue is that the daemon side of the remote driver can't find the appropriate driver, but the remote driver always accepts everything and thus attempts to delegate further, which in case of libvirtd makes no sense. Use the new flag VIR_CONNECT_NO_REMOTE and pass it from libvirtd to the opening function to avoid delegation in this specific case. After this patch the above attempt produces: $ virsh -c qemu:///system error: failed to connect to the hypervisor error: no connection driver available for qemu:///system Discovered when investigating https://gitlab.com/libvirt/libvirt/-/issues/3= 70 Signed-off-by: Peter Krempa --- src/remote/remote_daemon_dispatch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 061e0f7811..d7c473d2a1 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1798,6 +1798,14 @@ remoteOpenConn(const char *uri, if (*conn) return 0; +#ifdef LIBVIRTD + /* When libvirtd is in use we need to avoid any further delegation of = the + * connection, which can be attempted in cases when the appropriate + * connection driver was not compiled in. In such case a wrong error m= essage + * would be reported. */ + connectFlags |=3D VIR_CONNECT_NO_REMOTE; +#endif /* LIBVIRTD */ + if (!uri) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not ope= n")); return -1; --=20 2.37.1