From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1573650445; cv=none; d=zoho.com; s=zohoarc; b=aEsbsl9QPcvOA5u0WdL0mCyHrvgL8VqbMOxYAbSjlWeAP3G3ehpV42gHHKp2hD6CewGWflSWz5fyqgdmukccxJTlTty5IW2UIwRKbm59lM7+Fst6fPxdqf+HYcqRKCSBiwZ9Zu9beYCBZa8ed57FfeIz3oEpoJ/EQGFKUcjBxrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650445; 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=p0xIq/t+kLYOcUjaRcnuSnfDQdlNwErn4+/AWJHVMbE=; b=UVwf4HnyvBlSi/mOXhvzT8989U48pVWpn6IpYw1yx23z/lrGJURh7BM+3FP9WLVUlTr44ZMEUOIZjBzam9wmyIkkCzShRmdYS8JpB9qpWsPqqD+oc/SXVSNPo6flfo+ezRfTYbT7VkmRApv6OF44WFd8O4zvtFygfrHjlXjGqKw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1573650445755333.7925171367449; Wed, 13 Nov 2019 05:07:25 -0800 (PST) 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-396-JI-kst0kPLuE5mNxWuHYuw-1; Wed, 13 Nov 2019 08:07:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 042F518A23E1; Wed, 13 Nov 2019 13:07:18 +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 C86FB60BE0; Wed, 13 Nov 2019 13:07:17 +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 6FCC765D1C; Wed, 13 Nov 2019 13:07:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7Eim007063 for ; Wed, 13 Nov 2019 08:07:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 63A3BBA45; Wed, 13 Nov 2019 13:07:14 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E168B60CCC for ; Wed, 13 Nov 2019 13:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650444; 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=p0xIq/t+kLYOcUjaRcnuSnfDQdlNwErn4+/AWJHVMbE=; b=PxpdKo6f/JuHCwPCNIM1gz+9x+TgGCSH7/v513RVj9KYDlFAzXc6nVhWPaShCKttAofW8I 0lQHyud3bR8PYJbZrAZldpMruU9NVzk9hrkLYvaniRtBLW7MyRSu585NdWJU/f4cyFHOYK YA6OuAXWeoZGn+RAh03hlG8UQq9sdeM= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:02 +0100 Message-Id: <79c66466b1f2429481ea4654c7990023c00c6eb8.1573649215.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/8] qemu: domain: Use g_file_read_link instead of virFileReadLink 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.12 X-MC-Unique: JI-kst0kPLuE5mNxWuHYuw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In an effort to remove as much gnulib usage as possible let's reimplement virFileReadLink. Since it's used in two places only I opted to open-code it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 842b70dc26..40a617845a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13170,12 +13170,13 @@ qemuDomainCreateDeviceRecursive(const char *devic= e, } if (isLink) { + g_autoptr(GError) gerr =3D NULL; + /* We are dealing with a symlink. Create a dangling symlink and de= scend * down one level which hopefully creates the symlink's target. */ - if (virFileReadLink(device, &target) < 0) { - virReportSystemError(errno, - _("unable to resolve symlink %s"), - device); + if (!(target =3D g_file_read_link(device, &gerr))) { + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to resolve symlink %s: %s"), device, = gerr->message); goto cleanup; } @@ -14164,10 +14165,11 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDrive= rPtr driver, data.target =3D target; } else if (isLink) { - if (virFileReadLink(file, &target) < 0) { - virReportSystemError(errno, - _("unable to resolve symlink %s"), - file); + g_autoptr(GError) gerr =3D NULL; + + if (!(target =3D g_file_read_link(file, &gerr))) { + virReportError(VIR_ERR_SYSTEM_ERROR, + _("failed to resolve symlink %s: %s"), file, ge= rr->message); return ret; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573650486; cv=none; d=zoho.com; s=zohoarc; b=TtgofxhafrcWC5+K95Zf7HzVTmwrgiFTujy2Zsikp4TmpFdUzvPgmt5GUXXlD+Dy1GzGuzJUF33uw4ONJFYxk4DkHfDrI5GAV6ZldWrzL53Rdkqni3ADuc/ugk3ppQKh29mV/E+vn2dLhRYFkbQ4QMf0GD2YciA0GwOFmyD6WGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650486; 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=LCmUXesRxP7jR19Av8tNRKOCAg4e0YZAmRwG2yzoQT4=; b=GSGnEt60FSiA7/n2dUQ/VeYUDa1Mo1RYnGqEoIxk9I3TXSu+ehEqDrKq63YMpukuy68ZOqAFTziNxXJaSWcsj5t9zVBY0bVY730lrVLzl325N/mSL1YiyYs9iC9WQY+qN57XfWJReqFoK8klWCQNqEmFIyVHcsYMUXleUj3k6cU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1573650486174544.9699969617221; Wed, 13 Nov 2019 05:08:06 -0800 (PST) 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-163-zJUPgbIvMhO8x2yipMgefQ-1; Wed, 13 Nov 2019 08:07:31 -0500 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 F13C8107ACCD; Wed, 13 Nov 2019 13:07:22 +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 C4B7C891C; Wed, 13 Nov 2019 13:07:22 +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 7CCEF1832DEA; Wed, 13 Nov 2019 13:07:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7FTc007071 for ; Wed, 13 Nov 2019 08:07:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3235260CCC; Wed, 13 Nov 2019 13:07:15 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEFD160BE0 for ; Wed, 13 Nov 2019 13:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650485; 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=LCmUXesRxP7jR19Av8tNRKOCAg4e0YZAmRwG2yzoQT4=; b=fCQndNcfLTzXAWmHqYma0cs5Un/Ix65vgTDIVtB2AvLP3QDp7aF6ExM6xyS23HO+akKU4m +J8wWJ3+Wcs5RiYNHpcz8dp9YTjeO1rrIQdM2kbuhvxjL3XZfYxoWxGLybxPXhRcpHgWKK zTCTrLBbW9A3GPMIuHmZIFFjcufUMl8= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:03 +0100 Message-Id: <40c541763391b41e351dddf702016aeb13613f55.1573649216.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] util: file: Remove virFileReadLink 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 X-MC-Unique: zJUPgbIvMhO8x2yipMgefQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function is unused so we can remove it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virfile.c | 13 ------------- src/util/virfile.h | 3 --- 3 files changed, 17 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4d0d03c580..c706553e37 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1978,7 +1978,6 @@ virFileReadBufQuiet; virFileReadHeaderFD; virFileReadHeaderQuiet; virFileReadLimFD; -virFileReadLink; virFileReadValueBitmap; virFileReadValueInt; virFileReadValueScaledInt; diff --git a/src/util/virfile.c b/src/util/virfile.c index ced0ea70b7..b1aeaa5851 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -81,7 +81,6 @@ #include "virutil.h" #include "c-ctype.h" -#include "areadlink.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -1625,18 +1624,6 @@ virFileIsLink(const char *linkpath) return S_ISLNK(st.st_mode) !=3D 0; } -/* - * Read where symlink is pointing to. - * - * Returns 0 on success (@linkpath is a successfully read link), - * -1 with errno set upon error. - */ -int -virFileReadLink(const char *linkpath, char **resultpath) -{ - return (*resultpath =3D areadlink(linkpath)) ? 0 : -1; -} - /* * Finds a requested executable file in the PATH env. e.g.: * "qemu-img" will return "/usr/bin/qemu-img" diff --git a/src/util/virfile.h b/src/util/virfile.h index a570529330..9a8709b52c 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -176,9 +176,6 @@ int virFileResolveAllLinks(const char *linkpath, int virFileIsLink(const char *linkpath) ATTRIBUTE_NONNULL(1) G_GNUC_WARN_UNUSED_RESULT; -int virFileReadLink(const char *linkpath, char **resultpath) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; - char *virFindFileInPath(const char *file); char *virFileFindResource(const char *filename, --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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=1573650460; cv=none; d=zoho.com; s=zohoarc; b=Zhzkl335TqGxVBESr+pYDD5QkMnC/uXmToZGJ76cDi3ZEmEBvFY/zETd9cqNQ52l0fQeOd3mgqxI2/HgRNIKyO+gskl2pezzlmaSU0soivNB9mmST67FMw5UVyPybo4THki0PYjekgEiTebuIgSEE5YFKDnXU7UuVWRazdtMhH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650460; 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=PA0krRx2dmcDBiyKNec8ShfigmBBREcmj5T7d6h0mr4=; b=RFi62mx6OrNqIsHqO3fVMbwPlOLQPsb2qxLNPgkBMY+QS8UHV66BODBzxlb39r7yZJE6fD4hxOmA3OujeYwj89VLoGnkd2TqFqEbks8pLkzsYcMJ3uKGiUEeacV3OXhi1aJ6S5bvfu+bD4imfBETiYURrTfKppMgRoUWcsEb5nM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1573650460542459.3719359583388; Wed, 13 Nov 2019 05:07:40 -0800 (PST) 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-37-4Y3rfF3zOpKbl3vjyBOYdg-1; Wed, 13 Nov 2019 08:07:33 -0500 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 6C38B107ACE4; Wed, 13 Nov 2019 13:07:26 +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 402355DA7C; Wed, 13 Nov 2019 13:07:26 +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 F2A011832DF1; Wed, 13 Nov 2019 13:07:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7G84007078 for ; Wed, 13 Nov 2019 08:07:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3D0560CCC; Wed, 13 Nov 2019 13:07:15 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D23560BE0 for ; Wed, 13 Nov 2019 13:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650458; 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=PA0krRx2dmcDBiyKNec8ShfigmBBREcmj5T7d6h0mr4=; b=dKODOTCDwPdEwR2mKIegZdwtFTbU7Rad7wbI+jOyyeV+4KHPts437YvrlEA3rip20Krnx4 ULK4ALKgkGB0mfvIvOk84JLTZLNnCuG610s1AKFdVTNhL+JeO2/dmMzAXtlbhZBlK6zwBa y8Hos/r74lt7U95vB8AEq9Z1dEboLr0= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:04 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] qemu: tpm: Use g_autofree in qemuTPMEmulatorGetPid 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 X-MC-Unique: 4Y3rfF3zOpKbl3vjyBOYdg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 62b9f803bd..40136c4410 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -277,15 +277,13 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, { int ret; g_autofree char *swtpm =3D virTPMGetSwtpm(); - char *pidfile =3D qemuTPMEmulatorCreatePidFilename(swtpmStateDir, - shortName); + g_autofree char *pidfile =3D qemuTPMEmulatorCreatePidFilename(swtpmSta= teDir, + shortName); if (!pidfile) return -ENOMEM; ret =3D virPidFileReadPathIfAlive(pidfile, pid, swtpm); - VIR_FREE(pidfile); - return ret; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573650450; cv=none; d=zoho.com; s=zohoarc; b=brSyHsnboXdAPtVOTLykLIKWDpelAOcHRMuXxUm0R3eAqLxN5l/xGr0Yb4TOS0sy+TpBYu8oLRXn1ORYHtbuMLHN+M5Q7Ic4p0CIOM2gIe0Jy/QnviW19nYUIJfcNU8dm0UrIsMPq5dktfciwb7WYfF9ujWiHRS4Wt2VEsHVuzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650450; 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=xsLf4BS5Lv3y7IfYHYEgv4UJnAwIjSuiMan9yrwmnSA=; b=kOMo5+c8/JCVBku64eG4jEzqYPGU1nmAFT8iIqoDz3TB5ULRqGh9X7buDmzJAAVWLyt6veWgtATcvhSVB460SREshJ3toS0Yw4JAGVCNGfCDyB8HWrdmLbdUZ4gmzYFBIu9jReBkZ64+CsErDKf6brrmloIBJkKSDv9HFZ7ny/c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 157365045004989.40747177808646; Wed, 13 Nov 2019 05:07:30 -0800 (PST) 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-410-PlBh2gSHNx2thEoe52fBgg-1; Wed, 13 Nov 2019 08:07:26 -0500 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 477BB801E54; Wed, 13 Nov 2019 13:07:20 +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 220E21B5B5; Wed, 13 Nov 2019 13:07:20 +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 8EECC65D1E; Wed, 13 Nov 2019 13:07:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7G1K007083 for ; Wed, 13 Nov 2019 08:07:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id C21A3BA45; Wed, 13 Nov 2019 13:07:16 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AFC060CCC for ; Wed, 13 Nov 2019 13:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650448; 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=xsLf4BS5Lv3y7IfYHYEgv4UJnAwIjSuiMan9yrwmnSA=; b=GSygfUw/6erb7SkM5UZzLSwYTmJmIUtaSktzN/F9k0YbZK9HW660PMBB/aTB7p10KSSBcb Zw9LaUnsm/l5NQqS4HC9f7nZedFxiPT49zNu9h9BQWpr4o4FHHAY0CccnmREkydXBEGHzK t+Ts+xwg6djzB97c0k26kCTuj9hlTpA= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] qemu: tpm: Sanitize error values in qemuTPMEmulatorGetPid 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 X-MC-Unique: PlBh2gSHNx2thEoe52fBgg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The callers don't care about the actual return value, so return -1 rather than errno. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_tpm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 40136c4410..2f92542470 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -266,7 +266,7 @@ qemuTPMEmulatorCreatePidFilename(const char *swtpmState= Dir, * @shortName: short name of the domain * @pid: pointer to pid * - * Return -errno upon error, or zero on successful reading of the pidfile. + * Return -1 upon error, or zero on successful reading of the pidfile. * If the PID was not still alive, zero will be returned, and @pid will be * set to -1; */ @@ -275,16 +275,16 @@ qemuTPMEmulatorGetPid(const char *swtpmStateDir, const char *shortName, pid_t *pid) { - int ret; g_autofree char *swtpm =3D virTPMGetSwtpm(); g_autofree char *pidfile =3D qemuTPMEmulatorCreatePidFilename(swtpmSta= teDir, shortName); if (!pidfile) - return -ENOMEM; + return -1; - ret =3D virPidFileReadPathIfAlive(pidfile, pid, swtpm); + if (virPidFileReadPathIfAlive(pidfile, pid, swtpm) < 0) + return -1; - return ret; + return 0; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573650462; cv=none; d=zoho.com; s=zohoarc; b=mW5fz3ppcZB7NhG8e3tUIvdbGidKdqYyhJnTaM2WWoTlbro8T1Tku49DqIPe7cNBrTh1SiAf33wk3cOfNINYJT1/4JK+2MIzFQBkhNKlIhjndqWUslDLv5oGenqGl8mhiRHLmO/5qLj4uSM8ARk5kugEGVCVzpduo9IE8soXGLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650462; 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=Jz+olsPTrQGniQSIteNmUpwHJV5L/iaeYiwC4NsT9LU=; b=QlRYYYOD554E69rkviqrNSY7FleSuS/Uc3Wac+mTWWhGRft3cvuwvXVMCKhhn3Q77jHdKvApLE/zVqzL1AftFxNU8L7TkJmsSka2/GGG0Yy0qFpwSkUT+Tyi4uvLAL+/EdbfbE74/2pmE9GHqIVUlYFkPMGtqgp0JjPy6od508w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 157365046270868.8439973565338; Wed, 13 Nov 2019 05:07:42 -0800 (PST) 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-176-YoTdRtcxOgOz2sBCvqJMlw-1; Wed, 13 Nov 2019 08:07:35 -0500 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 301B3800686; Wed, 13 Nov 2019 13:07:30 +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 00CD5601B8; Wed, 13 Nov 2019 13:07:29 +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 B28C04BB78; Wed, 13 Nov 2019 13:07:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7Hef007090 for ; Wed, 13 Nov 2019 08:07:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8F42B60CCC; Wed, 13 Nov 2019 13:07:17 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 195AC60BE0 for ; Wed, 13 Nov 2019 13:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650461; 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=Jz+olsPTrQGniQSIteNmUpwHJV5L/iaeYiwC4NsT9LU=; b=B/PnBaFzmUptm8ccQPXwpLFhG6bNvM58GZF+NVpp87rqD6KF/EbGqC1VQ4IPZ1ovsQuLZO N2KvpFPBMcQb7TYQ1twcTzVty1K70IcZn+aVs9ipG2H5QOz6R4RiVOE7PaOTgSuvIedNAa tqtoM9eOPBF9Y2/65ch6K2KKGbWDwrc= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:06 +0100 Message-Id: <91824dfdd7b12f42def109955d5ea188dd5c3882.1573649216.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] qemu: gpu: Sanitize error values in qemuVhostUserGPUGetPid 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 X-MC-Unique: YoTdRtcxOgOz2sBCvqJMlw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The caller doesn't care about the actual return value, so return -1 rather than errno. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_vhost_user_gpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c index 37e424eac3..51244f9b35 100644 --- a/src/qemu/qemu_vhost_user_gpu.c +++ b/src/qemu/qemu_vhost_user_gpu.c @@ -61,7 +61,7 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir, * @alias: video device alias * @pid: pointer to pid * - * Return -errno upon error, or zero on successful reading of the pidfile. + * Return -1 upon error, or zero on successful reading of the pidfile. * If the PID was not still alive, zero will be returned, and @pid will be * set to -1; */ @@ -74,11 +74,13 @@ qemuVhostUserGPUGetPid(const char *binPath, { g_autofree char *pidfile =3D NULL; - pidfile =3D qemuVhostUserGPUCreatePidFilename(stateDir, shortName, ali= as); - if (!pidfile) - return -ENOMEM; + if (!(pidfile =3D qemuVhostUserGPUCreatePidFilename(stateDir, shortNam= e, alias))) + return -1; + + if (virPidFileReadPathIfAlive(pidfile, pid, binPath) < 0) + return -1; - return virPidFileReadPathIfAlive(pidfile, pid, binPath); + return 0; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1573650463; cv=none; d=zoho.com; s=zohoarc; b=Zm62TD1oUM9SAWmR2SXFZxt9Bs8ckXgr/yTy7lo5pqWMdTl93N+9SsCV4SJzvkSQAQi15Nryab4l1k+/A0OFbj2FJaeKwF9zd1MKeKP6z6AEtSThVByL1vWZAd13NXp1k8cvCzQQdsj+mYZUmJpvwNQFAvdG9Eert9FAyjW7OOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650463; 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=F66B4xPxA8FvBT/3KD5hYr5uegPcvFFgbb5MiqIdeho=; b=d0enOCHHn63yuAd0zfx9hszfe1BfEa3/vd3egcDrqIB8GRFb7rfWHVPnFmIRM474584vWCZfIk4oowvxFxXqKHavizzGb0di9RhjMGAHPMdKl8L0OhzAG6YPf2FNb+c3XLkUCIpZoMCaLKPqelUPbunaoxepsgu81F9lKp9W7wc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573650463454481.4164435590477; Wed, 13 Nov 2019 05:07:43 -0800 (PST) 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-363-N8gfiBhpOru2rxD1Ls9SeQ-1; Wed, 13 Nov 2019 08:07:40 -0500 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 E0E67100550E; Wed, 13 Nov 2019 13:07:33 +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 B9EF150FD1; Wed, 13 Nov 2019 13:07:33 +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 71ADC65D1F; Wed, 13 Nov 2019 13:07:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7Ioj007102 for ; Wed, 13 Nov 2019 08:07:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5BEA2BA45; Wed, 13 Nov 2019 13:07:18 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAD2460CCC for ; Wed, 13 Nov 2019 13:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650462; 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=F66B4xPxA8FvBT/3KD5hYr5uegPcvFFgbb5MiqIdeho=; b=NfXwl7ddyGDWMWurB5NcY1nW5DhxltzAhDlx2Db+/G4BqWh+HVO/ONj6EsvxuDYnp7/cah Dvm2fB2EvmBE5F4Hp5V3/VKd45FO9x3YiqE5+5jc7Rn9WV5GR/ucRO9l+FcCVlIH5QzfyQ 28LmSmMNnEvTlCThVw94ZpYE9I3CO58= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:07 +0100 Message-Id: <71bacfb5e16bebbef65c9272cf2e555bbfe73aec.1573649216.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/8] util: pidfile: Sanitize return values of virPidFileReadIfAlive 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 X-MC-Unique: N8gfiBhpOru2rxD1Ls9SeQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Return -1 on failure rather than -errno since none of the callers actually cares about the return value. This specifically fixes returns of -ENOMEM in cases of bad usage, which would report wrong error anyways. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virpidfile.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 3e78735c9c..b1b8e54993 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -282,7 +282,7 @@ int virPidFileReadPathIfAlive(const char *path, * and its executable path resolves to @binpath. This adds * protection against recycling of previously reaped pids. * - * Returns -errno upon error, or zero on successful + * Returns -1 upon error, or zero on successful * reading of the pidfile. If the PID was not still * alive, zero will be returned, but @pid will be * set to -1. @@ -295,12 +295,15 @@ int virPidFileReadIfAlive(const char *dir, g_autofree char *pidfile =3D NULL; if (name =3D=3D NULL || dir =3D=3D NULL) - return -EINVAL; + return -1; if (!(pidfile =3D virPidFileBuildPath(dir, name))) - return -ENOMEM; + return -1; + + if (virPidFileReadPathIfAlive(pidfile, pid, binpath) < 0) + return -1; - return virPidFileReadPathIfAlive(pidfile, pid, binpath); + return 0; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573650454; cv=none; d=zoho.com; s=zohoarc; b=P7qvjlbM3P5e0h4NMqGhsXnUwiIg9osZ3YpF8OoJsJJrctB+qtFyrG40xNSvqY2YcoaW+XnwLu4RdBS79l/+sj2aFb+zOt10hwfDr2hYuYNUyv8BjZ5ZJhB5dpPSbvksWoZ5bAUQz7FpAB+Z+DEZ7sb0ePrmg83mT0gy43BeXQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650454; 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=rFwmH1zVwu2iEulIEcL9P/achOWyeqR4vWXurQExirc=; b=Ak6D2dZlgpwyhJzwycPwoS3fZ5gks+ZPoYaNwAUftiQWJ8fRH3Zbt1u5BH1pDmEAGh18ABPKmDZlXhaId8EuDBXy7NsK6xKbbMBN2AdPZZrn74bddc9yMSmsIQt3arTG/8OEsR7C3MEjjX/jmXaSxOhgrMXScUK+c4iskxnAEXo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1573650454658367.86070989322184; Wed, 13 Nov 2019 05:07:34 -0800 (PST) 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-284-047CMdd1MbmqwOQW-vpv8A-1; Wed, 13 Nov 2019 08:07:32 -0500 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 577FC107ACC6; Wed, 13 Nov 2019 13:07:24 +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 2EF704DA0D; Wed, 13 Nov 2019 13:07:24 +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 E13291832DEE; Wed, 13 Nov 2019 13:07:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7JXj007114 for ; Wed, 13 Nov 2019 08:07:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2932160CCC; Wed, 13 Nov 2019 13:07:19 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A800660BE0 for ; Wed, 13 Nov 2019 13:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650453; 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=rFwmH1zVwu2iEulIEcL9P/achOWyeqR4vWXurQExirc=; b=GvCVJoy6jIjUPPWin3h2Wl7qMNRKR52zSUp/NWA5XLmWEqKOB4nbW5Y5oFDobKMb1gQEve xAfa4U1+4YwaaLNZFBniG62becZTn1UR1G/zADgUxFtx+Ejx1XMHO/6x62MMq8nB9trjOg DxxSbRPGNqz+TiE2a/Yo+d0hIc5x0p8= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:08 +0100 Message-Id: <6746a2314a06ecde4defe0c7793a2f821aab06d0.1573649216.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] util: pidfile: Sanitize return values of virPidFileReadPathIfAlive 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 X-MC-Unique: 047CMdd1MbmqwOQW-vpv8A-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The callers don't actually use the returned errno for reporting errors. Additionally virFileResolveAllLinks returns -1 rather than -errno on error thus you'd get a spurious EPERM even on other errors. Don't try to return errno in this case. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virpidfile.c | 50 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index b1b8e54993..4a800b6528 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -182,7 +182,7 @@ int virPidFileRead(const char *dir, * If @binpath is NULL the check for the executable path * is skipped. * - * Returns -errno upon error, or zero on successful + * Returns -1 upon error, or zero on successful * reading of the pidfile. If the PID was not still * alive, zero will be returned, but @pid will be * set to -1. @@ -191,8 +191,8 @@ int virPidFileReadPathIfAlive(const char *path, pid_t *pid, const char *binPath) { - int ret; - bool isLink; + int rc; + bool isLink =3D false; size_t procLinkLen; const char deletedText[] =3D " (deleted)"; size_t deletedTextLen =3D strlen(deletedText); @@ -205,16 +205,15 @@ int virPidFileReadPathIfAlive(const char *path, /* only set this at the very end on success */ *pid =3D -1; - if ((ret =3D virPidFileReadPath(path, &retPid)) < 0) - return ret; + if (virPidFileReadPath(path, &retPid) < 0) + return -1; #ifndef WIN32 /* Check that it's still alive. Safe to skip this sanity check on * mingw, which lacks kill(). */ if (kill(retPid, 0) < 0) { - ret =3D 0; - retPid =3D -1; - goto cleanup; + *pid =3D -1; + return 0; } #endif @@ -222,23 +221,24 @@ int virPidFileReadPathIfAlive(const char *path, /* we only knew the pid, and that pid is alive, so we can * return it. */ - ret =3D 0; - goto cleanup; + *pid =3D retPid; + return 0; } procPath =3D g_strdup_printf("/proc/%lld/exe", (long long)retPid); - if ((ret =3D virFileIsLink(procPath)) < 0) - return ret; + if ((rc =3D virFileIsLink(procPath)) < 0) + return -1; - isLink =3D ret; + if (rc =3D=3D 1) + isLink =3D true; if (isLink && virFileLinkPointsTo(procPath, binPath)) { /* the link in /proc/$pid/exe is a symlink to a file * that has the same inode as the file at binpath. */ - ret =3D 0; - goto cleanup; + *pid =3D retPid; + return 0; } /* Even if virFileLinkPointsTo returns a mismatch, it could be @@ -248,24 +248,22 @@ int virPidFileReadPathIfAlive(const char *path, * part, and see if it has the same canonicalized name as binpath. */ if (!(procLink =3D areadlink(procPath))) - return -errno; + return -1; procLinkLen =3D strlen(procLink); if (procLinkLen > deletedTextLen) procLink[procLinkLen - deletedTextLen] =3D 0; - if ((ret =3D virFileResolveAllLinks(binPath, &resolvedBinPath)) < 0) - return ret; - if ((ret =3D virFileResolveAllLinks(procLink, &resolvedProcLink)) < 0) - return ret; + if (virFileResolveAllLinks(binPath, &resolvedBinPath) < 0) + return -1; + if (virFileResolveAllLinks(procLink, &resolvedProcLink) < 0) + return -1; - ret =3D STREQ(resolvedBinPath, resolvedProcLink) ? 0 : -1; + if (STRNEQ(resolvedBinPath, resolvedProcLink)) + return -1; - cleanup: - /* return the originally set pid of -1 unless we proclaim success */ - if (ret =3D=3D 0) - *pid =3D retPid; - return ret; + *pid =3D retPid; + return 0; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 20:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1573650486; cv=none; d=zoho.com; s=zohoarc; b=EUTzfaR4uTR4kaub3+iHAS0sg1Sde+MXYNZQwpVrLpwf3rmgtR0RRpbM7Og6WUL6SbL21RIrVo9NHeewCC/hcE7VgBdRzUomNAOSTTW4eX/CMpw4IU9hcgbIpaoGD4xzJxi9z3nvvssf7JJVP9DcQIuiEvf7HVJn5xT6aIdSRvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573650486; 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=7ZfPnZVG0yqY7wEmSeyFUBbf2DoIkMaQEdngKnsstYw=; b=CbFykc5ffkw08UjbzDNgrIC67plFtpoKR5MufOWq30OhIqIBHGEDHytbFHNx5xpy2uj2zGKcAyo9zo/cjYqhi9UtuxFRNjiJ1jvHPttOgLiE6/nT2CFmlHoevvOMahELnd+5PE1+53Rjci26TAtH4Lh5NFHS7FBP1p7WFlFZOMA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1573650485996958.5624183175472; Wed, 13 Nov 2019 05:08:05 -0800 (PST) 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-103-9RiEGFQvO3iywe3zF8Ln2w-1; Wed, 13 Nov 2019 08:07:45 -0500 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 8D2B68048EC; Wed, 13 Nov 2019 13:07:39 +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 677AD60472; Wed, 13 Nov 2019 13:07:39 +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 244F51832DE7; Wed, 13 Nov 2019 13:07:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xADD7Jvi007120 for ; Wed, 13 Nov 2019 08:07:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id EAB5E61075; Wed, 13 Nov 2019 13:07:19 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7520A60BE0 for ; Wed, 13 Nov 2019 13:07:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573650484; 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=7ZfPnZVG0yqY7wEmSeyFUBbf2DoIkMaQEdngKnsstYw=; b=YxNtmMV3TNC/qN3rgB5fm2JDVqnLe/ZvE95f3UrvGvU63GFl7KWlaAYIa15BvU8I6ZfzgL m81DNhrJ79CtWjKQldmLtxjkNOCJJf7oggtAp5yOr3T1CGAjMFQOwvLc7tNT5hcwmXd9AW 9D+yFBoCD7reF0oS+59REWOBRQBcFiA= From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 13 Nov 2019 14:07:09 +0100 Message-Id: <7d8bd59a428e23adbf6b65691f2ebb6ae4559c4b.1573649216.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] util: pidfile: Replace 'areadlink' by 'g_file_read_link' 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 X-MC-Unique: 9RiEGFQvO3iywe3zF8Ln2w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use the glib function rather than gnulib. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virpidfile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 4a800b6528..5d1a820cd1 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -35,7 +35,6 @@ #include "virlog.h" #include "virerror.h" #include "c-ctype.h" -#include "areadlink.h" #include "virstring.h" #include "virprocess.h" @@ -247,7 +246,7 @@ int virPidFileReadPathIfAlive(const char *path, * "$procpath (deleted)". Read that link, remove the " (deleted)" * part, and see if it has the same canonicalized name as binpath. */ - if (!(procLink =3D areadlink(procPath))) + if (!(procLink =3D g_file_read_link(procPath, NULL))) return -1; procLinkLen =3D strlen(procLink); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list