From nobody Tue Apr 23 17:10:58 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=1683309720; cv=none; d=zohomail.com; s=zohoarc; b=ia9thuFzx1u3fR2w6HtUYjqsaaTXTNaL5r97ojMSeVsAhSmWUBg5p+Gs+1AY4A8cdTqLhkppP8u8I86LNU3LqxxQU19/mA304beZvHa3S1BGw4El59+yefCbfT7sJv0/2864qgZnoxp9QFoBDpVUWYaA+i1SEGwG9zTb+qFGogk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683309720; 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=0E0pG0RhLjYQKKbAYI1VpZMgXlwja3/EbGpIiIoj/9A=; b=N1yoncqpWOrka1VEZAU41a03ORTmkLVlRq6O1n59jIfVB6D/Xxlb6qvi7ojqrCGfj4oW453AHKkTZ8cAp/8SBlGu4qkbJqOgeA3hkB/ySci+5rXmc7G2vd2MKgqdXG9GpDojFqbCau5n7Oj8VU2h62TvrsYzVzyaGWjSU6uBg3Y= 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) 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 1683309720621687.0640201890043; Fri, 5 May 2023 11:02:00 -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-44-pd_e77x6P_CnDd6hohkkzA-1; Fri, 05 May 2023 14:01:54 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 884B218A646B; Fri, 5 May 2023 18:01:50 +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 753C8492B01; Fri, 5 May 2023 18:01:50 +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 542AA1946A48; Fri, 5 May 2023 18:01:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5DB311946A5E for ; Fri, 5 May 2023 18:01:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3EB142026D25; Fri, 5 May 2023 18:01:49 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C14332026D16 for ; Fri, 5 May 2023 18:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683309717; 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=0E0pG0RhLjYQKKbAYI1VpZMgXlwja3/EbGpIiIoj/9A=; b=R9Vjy3O27Qrr0skSkhsZ/JEMPBzfkVVReEixRdof3EArQyRviG7aKrsSFMPrTceDT4J1ap QgQNd/fztGZREoBL/32y26VU+pg5fhxMkxj97Y2JmJLVB//a9UBAeZXO099XaywjcbQBSW CAzzm9NpPPLmpDvPcZurN7QSQYfTjYY= X-MC-Unique: pd_e77x6P_CnDd6hohkkzA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 1/5] util: Small refactor Date: Fri, 5 May 2023 20:01:42 +0200 Message-Id: <20230505180146.551086-2-abologna@redhat.com> In-Reply-To: <20230505180146.551086-1-abologna@redhat.com> References: <20230505180146.551086-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 3.1 on 10.11.54.9 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: 1683309720964100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Prepare for further changes. Signed-off-by: Andrea Bolognani Reviewed-by: Martin Kletzander --- src/util/virfile.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 228482e8f8..8e94d19e45 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1743,13 +1743,15 @@ virFindFileInPath(const char *file) return NULL; =20 path =3D g_find_program_in_path(file); - if (!path) - return NULL; =20 - /* Workaround for a bug in g_find_program_in_path() not returning abso= lute - * path as documented. TODO drop it once we require GLib >=3D 2.69.0 - */ - return g_canonicalize_filename(path, NULL); + if (path) { + /* Workaround for a bug in g_find_program_in_path() not returning = absolute + * path as documented. TODO drop it once we require GLib >=3D 2.69= .0 + */ + return g_canonicalize_filename(path, NULL); + } + + return NULL; } =20 =20 --=20 2.40.1 From nobody Tue Apr 23 17:10:58 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=1683309719; cv=none; d=zohomail.com; s=zohoarc; b=YulEHRpyXrsFOMK3zfExf2IEHe7HYSZTaFEEYhYxEqy7ASalIapjhJNnSsJoMhcBF069X95RbeeglTM9N/MHnWuHg+BvVAlZGAhAz7ltMM9wJPHVERj2l2PyVWshL1jiE6/PhAY6lnNW2NRhyt8XoDkb6adHHMtYpYa6WPNFAV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683309719; 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=Bswrv4ixAwaeCliNg/kV2ZfKYlwskNXxHtrCMzK0Y5I=; b=nzTAfhpl432cWpAxCXq+8nt+Y4J4m1AEYc/B7Hkgsme6QWK2aCTe3YLrjOobp4In13ZYY4CXJJIIUyb1XX6ftUTxKjwr3ZUv6CGlHhxk6HhfKtZW4pzp95dIg0evjHvWeWrG30We/3lYZhpI2hChlsgKh8f266XIrX0olzbhXoE= 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) 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 168330971971059.01670743276952; Fri, 5 May 2023 11:01:59 -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-510--CK_4pdpNnOjMj0uP8SL8w-1; Fri, 05 May 2023 14:01:55 -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 CF7FD100F661; Fri, 5 May 2023 18:01:50 +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 BC67963F3D; Fri, 5 May 2023 18:01:50 +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 925891946A62; Fri, 5 May 2023 18:01:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2BBE21946A43 for ; Fri, 5 May 2023 18:01:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 034B62026D25; Fri, 5 May 2023 18:01:50 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 862D72026D16 for ; Fri, 5 May 2023 18:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683309718; 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=Bswrv4ixAwaeCliNg/kV2ZfKYlwskNXxHtrCMzK0Y5I=; b=PCLA36h0ssIlp+greIkhrNIjaS+4XQB4uTl8KXNMB7+VNxAeE2LutbDVQaS6jtPDwwBbZc yMaJcjrkd1rq6Hrl6FBFBafg2xLqBKoCDino3vAVJzR7XBBw8mK4GJ3dwPK+6RJBo9YWRL 2aYuOqFjOLyQIYuoAfhYvDCMyzKvhPo= X-MC-Unique: -CK_4pdpNnOjMj0uP8SL8w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 2/5] util: Introduce virFileFindInPathFull() Date: Fri, 5 May 2023 20:01:43 +0200 Message-Id: <20230505180146.551086-3-abologna@redhat.com> In-Reply-To: <20230505180146.551086-1-abologna@redhat.com> References: <20230505180146.551086-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 3.1 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: 1683309721912100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Andrea Bolognani Reviewed-by: Martin Kletzander --- src/libvirt_private.syms | 1 + src/util/virfile.c | 33 +++++++++++++++++++++++++++++++++ src/util/virfile.h | 3 +++ 3 files changed, 37 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 62c296bf5f..27b8e111aa 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2358,6 +2358,7 @@ virFileWrapperFdFree; virFileWrapperFdNew; virFileWriteStr; virFindFileInPath; +virFindFileInPathFull; =20 =20 # util/virfilecache.h diff --git a/src/util/virfile.c b/src/util/virfile.c index 8e94d19e45..6b4d4c3522 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1737,6 +1737,25 @@ virFileIsLink(const char *linkpath) */ char * virFindFileInPath(const char *file) +{ + return virFindFileInPathFull(file, NULL); +} + +/* virFindFileInPathFull: + * @file: name of the program + * @extraDirs: NULL-terminated list of additional directories + * + * Like virFindFileInPath(), but in addition to searching $PATH also + * looks into all directories listed in @extraDirs. This is useful to + * locate helpers that are installed outside of $PATH. + * + * The returned path must be freed by the caller. + * + * Returns: absolute path of the program or NULL + */ +char * +virFindFileInPathFull(const char *file, + const char *const *extraDirs) { g_autofree char *path =3D NULL; if (file =3D=3D NULL) @@ -1751,6 +1770,20 @@ virFindFileInPath(const char *file) return g_canonicalize_filename(path, NULL); } =20 + if (extraDirs) { + while (*extraDirs) { + g_autofree char *extraPath =3D NULL; + + extraPath =3D g_strdup_printf("%s/%s", *extraDirs, file); + + if (virFileIsExecutable(extraPath)) { + return g_steal_pointer(&extraPath); + } + + extraDirs++; + } + } + return NULL; } =20 diff --git a/src/util/virfile.h b/src/util/virfile.h index f7a31d9f57..6a14173625 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -189,6 +189,9 @@ int virFileIsLink(const char *linkpath) =20 char *virFindFileInPath(const char *file) G_NO_INLINE; +char *virFindFileInPathFull(const char *file, + const char *const *extraDirs) + G_NO_INLINE; =20 char *virFileFindResource(const char *filename, const char *builddir, --=20 2.40.1 From nobody Tue Apr 23 17:10:58 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=1683309721; cv=none; d=zohomail.com; s=zohoarc; b=c17Etl0JmZId1kqH2ymEQFRCh8p/Ydq9kKPN0qiJFpUCmd+vbqstcBCnq2Z0fuFeP8IMWV1jHDJLfJoE1rR66sHXi8VWXNd6Etc1otLVaIQD9+0znGaWZlP6Yn082QrZG3I9ileRNMUW584rbhO47qfWVWotXOJmu0yVNTl17s0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683309721; 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=4mqDuGq2Whjk3WsKzlVkaKWFuPGtBLN7iytaSFNgkrw=; b=QOa3G20PmDG3eEBQ5uWKTUnRkmS0MklJkFg+ZjTXzvfxDBGca7XlrnR4D9fQ6OL8xH7ZbgjgLXmGpXkOd/WhEVPQWbrKMeozj7DzwjqVZdBfhzwFOKDgjV82Yi76UFIGo5bXoO01XQWxfJ4qBa/YIhjoi+K6OnYM2usyEWKnfFA= 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 1683309721816119.66232397599731; Fri, 5 May 2023 11:02:01 -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-589--rbJvJ3FOm6g03FBhhDJhA-1; Fri, 05 May 2023 14:01:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06E8A1C07540; Fri, 5 May 2023 18:01:53 +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 E667540C6F41; Fri, 5 May 2023 18:01:52 +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 C8D071946A48; Fri, 5 May 2023 18:01:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CD2621946A4A for ; Fri, 5 May 2023 18:01:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BC6B82026D3C; Fri, 5 May 2023 18:01:50 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B6642026D16 for ; Fri, 5 May 2023 18:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683309719; 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=4mqDuGq2Whjk3WsKzlVkaKWFuPGtBLN7iytaSFNgkrw=; b=V78y/z98406qAOnkSldTQIhHzdTKAMex9Df3wrMigH7WP0j65p9MFakfrWkgy49LktHrOW hN9jUDTtv3CmiLb/1X+bxdUQiVy34VWDzRVaK4JC1me4MzHRKh867AnH6955gbJzK7WF8/ XHr1dszpA8LeHRiBw7qq9Irsee3XXyw= X-MC-Unique: -rbJvJ3FOm6g03FBhhDJhA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 3/5] qemu: Find helpers at runtime Date: Fri, 5 May 2023 20:01:44 +0200 Message-Id: <20230505180146.551086-4-abologna@redhat.com> In-Reply-To: <20230505180146.551086-1-abologna@redhat.com> References: <20230505180146.551086-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 3.1 on 10.11.54.2 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: 1683309723106100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Use the recently introduced virFindFileInPathFull() function to discover the path for qemu-bridge-helper and qemu-pr-helper at runtime. Note that it's still possible for the administrator to prevent this lookup and use arbitrary binaries by setting the appropriate keys in qemu.conf: this simply removes the need to perform the lookup at build time, and thus to have the helpers installed in the build environment. Signed-off-by: Andrea Bolognani Reviewed-by: Martin Kletzander --- src/qemu/qemu_interface.c | 15 +++++++++++++-- src/qemu/qemu_process.c | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index e395bfcc5b..e875de48ee 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -327,7 +327,14 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig *= cfg, int *tapfd, unsigned int flags) { + const char *const bridgeHelperDirs[] =3D { + "/usr/libexec", + "/usr/lib/qemu", + "/usr/lib", + NULL, + }; g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *bridgeHelperPath =3D NULL; char *errbuf =3D NULL, *cmdstr =3D NULL; int pair[2] =3D { -1, -1 }; =20 @@ -339,13 +346,17 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig = *cfg, return -1; } =20 - if (!virFileIsExecutable(cfg->bridgeHelperName)) { + bridgeHelperPath =3D virFindFileInPathFull(cfg->bridgeHelperName, brid= geHelperDirs); + + if (!bridgeHelperPath) { virReportSystemError(errno, _("'%1$s' is not a suitable bridge hel= per"), cfg->bridgeHelperName); return -1; } =20 - cmd =3D virCommandNew(cfg->bridgeHelperName); + VIR_DEBUG("Using qemu-bridge-helper: %s", bridgeHelperPath); + + cmd =3D virCommandNew(bridgeHelperPath); if (flags & VIR_NETDEV_TAP_CREATE_VNET_HDR) virCommandAddArgFormat(cmd, "--use-vnet"); virCommandAddArgFormat(cmd, "--br=3D%s", brname); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 952814d663..bb4cf35226 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2818,10 +2818,15 @@ qemuProcessStartPRDaemonHook(void *opaque) int qemuProcessStartManagedPRDaemon(virDomainObj *vm) { + const char *const prHelperDirs[] =3D { + "/usr/libexec", + NULL, + }; qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; g_autoptr(virQEMUDriverConfig) cfg =3D NULL; int errfd =3D -1; + g_autofree char *prHelperPath =3D NULL; g_autofree char *pidfile =3D NULL; g_autofree char *socketPath =3D NULL; pid_t cpid =3D -1; @@ -2832,12 +2837,16 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm) =20 cfg =3D virQEMUDriverGetConfig(driver); =20 - if (!virFileIsExecutable(cfg->prHelperName)) { + prHelperPath =3D virFindFileInPathFull(cfg->prHelperName, prHelperDirs= ); + + if (!prHelperPath) { virReportSystemError(errno, _("'%1$s' is not a suitable pr helper"= ), cfg->prHelperName); goto cleanup; } =20 + VIR_DEBUG("Using qemu-pr-helper: %s", prHelperPath); + if (!(pidfile =3D qemuProcessBuildPRHelperPidfilePath(vm))) goto cleanup; =20 @@ -2853,7 +2862,7 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm) goto cleanup; } =20 - if (!(cmd =3D virCommandNewArgList(cfg->prHelperName, + if (!(cmd =3D virCommandNewArgList(prHelperPath, "-k", socketPath, NULL))) goto cleanup; @@ -2881,7 +2890,7 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm) if (virPidFileReadPath(pidfile, &cpid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("pr helper %1$s didn't show up"), - cfg->prHelperName); + prHelperPath); goto cleanup; } =20 @@ -2899,7 +2908,7 @@ qemuProcessStartManagedPRDaemon(virDomainObj *vm) if (saferead(errfd, errbuf, sizeof(errbuf) - 1) < 0) { virReportSystemError(errno, _("pr helper %1$s died unexpectedly"), - cfg->prHelperName); + prHelperPath); } else { virReportError(VIR_ERR_OPERATION_FAILED, _("pr helper died and reported: %1$s"), errbuf); --=20 2.40.1 From nobody Tue Apr 23 17:10:58 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=1683309726; cv=none; d=zohomail.com; s=zohoarc; b=CB7HgmJmSH/i1HpE7YLCatnZUSK9DiEs77F3r26K2GA/KapLmRg+Y1b79QGwGA7hFS43vJWAT8uLP/xsvuwJS7nTWyWBXs056pcmLLCRtW4qJbENjsWc1MByKuZFGAo3rLLjmC8hEV+Cj04qytuvYR1opmlrPa7s4Bae06xU18A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683309726; 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=egErQcxZVQS34F4dawisik6FyrVE9or8v/0o2ZHODKs=; b=eRosNu24yP1QoG8uVE3y1oLgiNuUyaoSBbSqg2f0cSjozt0KcoFeI7TjWJkR/tlpsZJ+wA0eUn0ya9cJ1pL6oQQHjRheLRW2NdAvECZvsqVlrAbfCB6kHbyg5cWYvdi98bxO+TQtyz2qfV2ttTx52RgCrYUGvDadnRpTn4nm1QA= 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) 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 1683309726596910.0190171898823; Fri, 5 May 2023 11:02:06 -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-434-O1qYOhfVPbi9T6Z9hNTkBQ-1; Fri, 05 May 2023 14:01:59 -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 3990E1C07543; Fri, 5 May 2023 18:01:54 +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 227C1141511D; Fri, 5 May 2023 18:01:54 +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 3A18A1946A4C; Fri, 5 May 2023 18:01:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9B4BD1946A43 for ; Fri, 5 May 2023 18:01:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 811CA2026D25; Fri, 5 May 2023 18:01:51 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 105942026D16 for ; Fri, 5 May 2023 18:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683309724; 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=egErQcxZVQS34F4dawisik6FyrVE9or8v/0o2ZHODKs=; b=hQT929y9squMhYZ7U7EMdQZA5N7oHD5f27q2eY1avucHQE7l0l7J+b8hnwH9hds74goad7 NQUfocEwsFEpwt6/m1CHJKvwZta9OmYXyAnDJeQnwcVOX9V/k9odSgK+3NU6OMrS3pzP7t MHHHVNxwIw/BcmEq0ZsF3NIpReULJEc= X-MC-Unique: O1qYOhfVPbi9T6Z9hNTkBQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 4/5] meson: Stop looking for QEMU helpers Date: Fri, 5 May 2023 20:01:45 +0200 Message-Id: <20230505180146.551086-5-abologna@redhat.com> In-Reply-To: <20230505180146.551086-1-abologna@redhat.com> References: <20230505180146.551086-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 3.1 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: 1683309731576100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that we're performing the lookup at runtime, doing it at build time is no longer necessary. Signed-off-by: Andrea Bolognani Reviewed-by: Martin Kletzander --- meson.build | 24 ------------------------ src/qemu/qemu_conf.c | 4 ++++ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/meson.build b/meson.build index 24f52113fa..6e65e9eec3 100644 --- a/meson.build +++ b/meson.build @@ -1655,30 +1655,6 @@ if not get_option('driver_qemu').disabled() conf.set_quoted('QEMU_USER', qemu_user) conf.set_quoted('QEMU_GROUP', qemu_group) =20 - qemu_bridge_prog =3D find_program( - 'qemu-bridge-helper', - dirs: [ '/usr/libexec', '/usr/lib/qemu', '/usr/lib' ], - required: false - ) - if qemu_bridge_prog.found() - qemu_bridge_path =3D qemu_bridge_prog.full_path() - else - qemu_bridge_path =3D '/usr/libexec/qemu-bridge-helper' - endif - conf.set_quoted('QEMU_BRIDGE_HELPER', qemu_bridge_path) - - qemu_pr_prog =3D find_program( - 'qemu-pr-helper', - dirs: [ '/usr/bin', '/usr/libexec' ], - required: false - ) - if qemu_pr_prog.found() - qemu_pr_path =3D qemu_pr_prog.full_path() - else - qemu_pr_path =3D '/usr/bin/qemu-pr-helper' - endif - conf.set_quoted('QEMU_PR_HELPER', qemu_pr_path) - qemu_slirp_prog =3D find_program( 'slirp-helper', dirs: [ '/usr/bin', '/usr/libexec' ], diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index d9460d82e0..c76ae7ac93 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -97,6 +97,10 @@ VIR_ONCE_GLOBAL_INIT(virQEMUConfig); #endif =20 =20 +#define QEMU_BRIDGE_HELPER "qemu-bridge-helper" +#define QEMU_PR_HELPER "qemu-pr-helper" + + virQEMUDriverConfig *virQEMUDriverConfigNew(bool privileged, const char *root) { --=20 2.40.1 From nobody Tue Apr 23 17:10:58 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=1683309727; cv=none; d=zohomail.com; s=zohoarc; b=KtAszxKPdZO3JMX97fgfuYsVl9leUmLmqPVJne/ThS4pvGXskHZ6wfIi31TcGLCWNAq4qvh1VqbnDQHAGaTTLe4sR1Mv2YvEOo1WybtiwSQ59x2geGyAbZ8xpnaPysipSMbD794Pbq8/Fz+g7IhJ7JP3uOyV2+V1tN7wZ+NLa4k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683309727; 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=mSYCHN6oKlcz7SOmizlu37BVNl1/DVZYg8Jt7Za5e9s=; b=B9yjtmnRIDNXcAd+Z/OCeAtwmWItOg20t0kCmG513dBNAxzHDKdkUX3LZyqOSXWgruvjbRaYfaqDHxRu/qHvNMzSH2rfubj7gm3gtX6nQB/3sMhjEdqJt2gX9wQwiuZ6UIVRAIr2QWapLhLu5K5oVOP/IVx4lOCTvktKBqNX0Ow= 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) 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 1683309727569985.8673382032881; Fri, 5 May 2023 11:02:07 -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-204-LOilKDIpOUWVZZwP8V5jtg-1; Fri, 05 May 2023 14:01:59 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B43587DC1C; Fri, 5 May 2023 18:01:53 +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 7D10D40F177; Fri, 5 May 2023 18:01:53 +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 090AA1946A62; Fri, 5 May 2023 18:01:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 549881946A43 for ; Fri, 5 May 2023 18:01:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4617E2026D25; Fri, 5 May 2023 18:01:52 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.224.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C91482026D16 for ; Fri, 5 May 2023 18:01:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683309726; 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=mSYCHN6oKlcz7SOmizlu37BVNl1/DVZYg8Jt7Za5e9s=; b=Q3EsI8muyKitd6vXRBd10ZEbnLtVJN3n4f9QCTjfa3XsHWq5aYanhPz1IyKZJCGuI0GvUh SiG8zOp3s4S7SJ/sYMBdygKV5HHdy9kU58MtZZoyfKbbEkEgfRTp5v4tRYiUF+Wyta7g+i +6oma6M0Ag+SgUBzLsS0d4dVhFwbUJA= X-MC-Unique: LOilKDIpOUWVZZwP8V5jtg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Andrea Bolognani To: libvir-list@redhat.com Subject: [libvirt PATCH 5/5] qemu: Update documentation for qemu.conf keys Date: Fri, 5 May 2023 20:01:46 +0200 Message-Id: <20230505180146.551086-6-abologna@redhat.com> In-Reply-To: <20230505180146.551086-1-abologna@redhat.com> References: <20230505180146.551086-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 3.1 on 10.11.54.10 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: 1683309731683100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Reflect the new default value, and explain that a runtime lookup will be performed if the value is not an absolute path. Signed-off-by: Andrea Bolognani Reviewed-by: Martin Kletzander --- src/qemu/qemu.conf.in | 8 ++++++-- src/qemu/test_libvirtd_qemu.aug.in | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu.conf.in b/src/qemu/qemu.conf.in index 3895d42514..e1a9a5e56d 100644 --- a/src/qemu/qemu.conf.in +++ b/src/qemu/qemu.conf.in @@ -650,7 +650,9 @@ # is used to create interfaces when libvirtd is # running unprivileged. libvirt invokes the helper directly, instead # of using "-netdev bridge", for security reasons. -#bridge_helper =3D "/usr/libexec/qemu-bridge-helper" +# If this is not an absolute path, the program will be searched for +# in $PATH as well as a few additional directories. +#bridge_helper =3D "qemu-bridge-helper" =20 =20 # If enabled, libvirt will have QEMU set its process name to @@ -899,7 +901,9 @@ =20 # Path to the SCSI persistent reservations helper. This helper is # used whenever are enabled for SCSI LUN devices. -#pr_helper =3D "/usr/bin/qemu-pr-helper" +# If this is not an absolute path, the program will be searched for +# in $PATH as well as a few additional directories. +#pr_helper =3D "qemu-pr-helper" =20 # Path to the SLIRP networking helper. #slirp_helper =3D "/usr/bin/slirp-helper" diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qe= mu.aug.in index 1dbd692921..af99331886 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -75,7 +75,7 @@ module Test_libvirtd_qemu =3D { "auto_dump_bypass_cache" =3D "0" } { "auto_start_bypass_cache" =3D "0" } { "hugetlbfs_mount" =3D "/dev/hugepages" } -{ "bridge_helper" =3D "/usr/libexec/qemu-bridge-helper" } +{ "bridge_helper" =3D "qemu-bridge-helper" } { "set_process_name" =3D "1" } { "max_processes" =3D "0" } { "max_files" =3D "0" } @@ -107,7 +107,7 @@ module Test_libvirtd_qemu =3D { "1" =3D "mount" } } { "memory_backing_dir" =3D "/var/lib/libvirt/qemu/ram" } -{ "pr_helper" =3D "/usr/bin/qemu-pr-helper" } +{ "pr_helper" =3D "qemu-pr-helper" } { "slirp_helper" =3D "/usr/bin/slirp-helper" } { "dbus_daemon" =3D "/usr/bin/dbus-daemon" } { "swtpm_user" =3D "tss" } --=20 2.40.1