From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977004; cv=none; d=zohomail.com; s=zohoarc; b=QPJpWxyuFYlr0TGCanKvMsIpZEMFgUbKXXKFO91xtgXf1Bnwgc5xeIQcGT0rP24gMWbqzx3dkvdZkok5dazcj3nuVRoISwFr7zmnX+WQoopYE9We600doclNiUEjXZXBk3DmhYEks3U/DDZA4urFQ+4brNnde4W2v1ayOYq82Gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977004; 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=JFaPQWAJ1ilvjhr1bfY9Z82VHOMg056s0TEkyxQqRwY=; b=YoTFwYuSsnO+Glv0AqzIvY2ek4j6kFo6ym4vr9dSX+51VNwCrtbx1mcobc8jvlk1uo1H1dYrCQBPIi4/LX3bdLayxgSZhpK4LUH57LAy5nGXa7XREzQRKea3tc1xiPaTgis1+YppmJRQO0RsXaptfRWG5MWslThmRGWCmgTqGEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977004417924.7789747982307; Thu, 2 Jan 2020 06:56:44 -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-294-nV8vC1S2O3OPpMpncOWGCA-1; Thu, 02 Jan 2020 09:56:41 -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 0268918CA245; Thu, 2 Jan 2020 14:56:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2E8A64435; Thu, 2 Jan 2020 14:56:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9524018089D7; Thu, 2 Jan 2020 14:56:34 +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 002EuPMQ004682 for ; Thu, 2 Jan 2020 09:56:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id A950A60C87; Thu, 2 Jan 2020 14:56:25 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1887F60BF4; Thu, 2 Jan 2020 14:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977003; 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=JFaPQWAJ1ilvjhr1bfY9Z82VHOMg056s0TEkyxQqRwY=; b=fhJfLiGGd02F9G3t1Hbe1apM0ZH//QAyVRuO/30pKGHrnocT3ZO8K9j90wh3ZUx1UpzFQ0 yEKlY+4A27xNNv0By9taEQIYdbwv9SP/BrSw9DFVz8AbLG7M/CmWtet/XiYstXNaX0ie7v 85DrYH+8phUxDrW59QTe9j1DSTXmSxU= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:35 +0000 Message-Id: <20200102145357.6724-2-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/23] build: set min version for CLang to 3.4 / XCode CLang to 5.1 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: nV8vC1S2O3OPpMpncOWGCA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We have a strong check for GCC >=3D 4.8, but don't validate any version number for CLang historically. This defines the min CLang to be 3.4 which is what is available for RHEL-7. macOS uses a different versioning scheme for CLang, based off XCode versions. There is a mapping recorded at https://en.wikipedia.org/wiki/Xcode#Toolchain_versions Here we see upstream CLang 3.4 corresponds to XCode 5.1 XCode 5.1 is available for macOS 10.8.4 or later which trivially satisfies our platform support matrix requirements. All these versions match what QEMU declares for its min GCC and CLang checks. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- config-post.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/config-post.h b/config-post.h index 7c07e05340..415cc8cc72 100644 --- a/config-post.h +++ b/config-post.h @@ -32,6 +32,20 @@ ((__GNUC__ << 16) + __GNUC_MINOR__ >=3D ((maj) << 16) + (min)) #endif =20 -#if !(__GNUC_PREREQ(4, 8) || defined(__clang__)) -# error "Libvirt requires GCC >=3D 4.8, or CLang" +#if defined(__clang_major__) && defined(__clang_minor__) +# ifdef __apple_build_version__ +# if __clang_major__ < 5 || (__clang_major__ =3D=3D 5 && __clang_minor__ = < 1) +# error You need at least XCode Clang v5.1 to compile QEMU +# endif +# else +# if __clang_major__ < 3 || (__clang_major__ =3D=3D 3 && __clang_minor__ = < 4) +# error You need at least Clang v3.4 to compile QEMU +# endif +# endif +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +# if __GNUC__ < 4 || (__GNUC__ =3D=3D 4 && __GNUC_MINOR__ < 8) +# error You need at least GCC v4.8 to compile QEMU +# endif +#else +# error You either need at least GCC 4.8 or Clang 3.4 or XCode Clang 5.1 t= o compile libvirt #endif --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577976998; cv=none; d=zohomail.com; s=zohoarc; b=QJnIoxPdmCT0TGZxLJDf2OwbRjonl32nikn0usy+k4E2TnfVWLFofMGazX+HW5tSrhc0jUdK6t6sU+p/mj08ZQ9zswnVrRZJ0bH2pebZz3rbeElBThiOhpviNEwXuL8BnGMlDyvk4UlV4Ynm31orVwiIR/cCIeVU5FfNtinZODs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577976998; 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=OmCFR+wa8vQ0DawfutonM7OfdJqNKReWp36pjMSgPBI=; b=USdMF5Rx2kA+hmLiLzWd2y7B33pvgYJZEQmaDIuBRPqoXcrFuYftnye1Zygm1TB6xsTcXFt8qJiV+PH8XDcAKDg0xAm/AH2sC0smX1yXQnamW2sb0i/A/3rhfb/KpP/pBoSJTGMxraKM9xpseVlpos+kjd875jax5FWmjXGpCoo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 15779769987171013.3581713649563; Thu, 2 Jan 2020 06:56:38 -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-266-htW6aLrwMO2LZbR_0pqmKw-1; Thu, 02 Jan 2020 09:56:35 -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 2F271800D4C; Thu, 2 Jan 2020 14:56:30 +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 0458760C85; Thu, 2 Jan 2020 14:56:30 +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 B98F118089CF; Thu, 2 Jan 2020 14:56: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 002EuQGj004688 for ; Thu, 2 Jan 2020 09:56:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 894DF60C85; Thu, 2 Jan 2020 14:56:26 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDB9D60BF4; Thu, 2 Jan 2020 14:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577976997; 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=OmCFR+wa8vQ0DawfutonM7OfdJqNKReWp36pjMSgPBI=; b=Bm3GT1aeFPW2zEcuB4MexbbDvRq2cHVPFOu9VAE/4kAVapkD5bqsitmqU/FMI13ICuc/0B j7QRIPQOlrGS75WgzSVKwx7By1ujVishjUwLAMIhHkpKlegf/MX7s91bWCwe8cxBWT12Cy 0vm48rxuie/nzEYJuCJFpWJbFM7FCYw= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:36 +0000 Message-Id: <20200102145357.6724-3-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/23] docs: expand macOS platform support coverage 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: htW6aLrwMO2LZbR_0pqmKw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We initially claimed to only support the most recent macOS release, which is currently 10.15. Our Travis CI, however, is validating 10.14.4 / XCode 10.3. For almost all of our other platforms, we support multiple releases to some degree. This change brings macOS in line with other long life distros, covering the most recent & most recent but one for a 2 year overlap. With this docs change our CI is now actually testing our minimum version. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- docs/platforms.html.in | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/platforms.html.in b/docs/platforms.html.in index a037074e1f..5c90f1dd7a 100644 --- a/docs/platforms.html.in +++ b/docs/platforms.html.in @@ -74,8 +74,17 @@

macOS

=20

- The project supports building with the current version of macOS, - with the current homebrew package set available. + The project aims to support the most recent major version + at all times. Support for the previous major version will + be dropped 2 years after the new major version is released. +

+ +

+ Note that to compile libvirt will require extra packages + to be made available on the macOS host. It is recommended + to use HomeBrew since this + is what libvirt CI tests with, however, MacPorts + is an alternative option that is likely to work.

=20

FreeBSD

--=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577976998; cv=none; d=zohomail.com; s=zohoarc; b=jnShGI2J3OA9wAX7au4pRSK9AgjJq4sXVtm3I3QnkFWCapP5LuF0OxOyv97PmRx9cz6gZH3sHKPXuvpSthiZCeQzWQaDP6WbfKsHgpHoH/n8TFp9sBD7g+ZMA57hnnwBQ/o/V8kL9K92zIQIy7CHxuQDdrIcv4AGZnsxe9JnFA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577976998; 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=DrBefkJGT5bZ7Xal2EJobLnV2wf+sdDhziwgR0Ur8Ro=; b=OgoyzffmOtrSO6VvxvgsN5IXJ596PGMvVgIgQYC7MGo6tpPERKx3fG/K20Xs4g5gIh4tQVUuY1dH88gGo6LGh723dxv3DC7LeaME5Myzxbj2FVHXVK+L2Az1+D54KnrKhIrsR6Rlzt1JFvT33Q/vurANUd9jd3r0nf65VfqNXDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 157797699874159.68989821535024; Thu, 2 Jan 2020 06:56:38 -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-248-9TytPopKObKKRaTEGqhZfw-1; Thu, 02 Jan 2020 09:56:35 -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 492D710054E3; Thu, 2 Jan 2020 14:56: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 281C95D9C9; Thu, 2 Jan 2020 14:56:30 +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 D97CC81E2F; Thu, 2 Jan 2020 14:56: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 002EuRH7004728 for ; Thu, 2 Jan 2020 09:56:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 692C660C85; Thu, 2 Jan 2020 14:56:27 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDE3060BF4; Thu, 2 Jan 2020 14:56:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577976997; 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=DrBefkJGT5bZ7Xal2EJobLnV2wf+sdDhziwgR0Ur8Ro=; b=MHhCWZ0NWqB/U5F/YjQChE9bx8v9UEQAX6HhobMs+2YWO7AuA/S3dVINjkgCAXyY6takbj A9WfsASMxM9Ma8aCPMyh9ErbA2PXgKI/VcE20ocHTcwNWtMscvyVIP08GxGXPe8+Flm4Po JT/nuB71oDyzWB0xk1KVkm8ae1QO2TI= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:37 +0000 Message-Id: <20200102145357.6724-4-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/23] travis: add macOS Xcode 11.3 testing 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: 9TytPopKObKKRaTEGqhZfw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Ideally we would test macOS 10.15 as the newest release, however, that is not available in Travis yet. We can at least test newer XCode versions though to get toolchain validation. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index f129706456..e1e8cb4f80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,6 +75,21 @@ matrix: # macOS, but doing 'install' and 'dist' gives us some useful cover= age - mkdir build && cd build - ../autogen.sh --prefix=3D$(pwd)/install-root && make -j3 && make= -j3 install && make -j3 dist + - compiler: clang + language: c + os: osx + osx_image: xcode11.3 + env: + - PATH=3D"/usr/local/opt/gettext/bin:/usr/local/opt/ccache/libexec= :/usr/local/opt/rpcgen/bin:$PATH" + - PKG_CONFIG_PATH=3D"/usr/local/opt/libxml2/lib/pkgconfig" + before_script: + # Hack to blow away py2 + - brew link --overwrite python + script: + # We can't run 'distcheck' or 'syntax-check' because they fail on + # macOS, but doing 'install' and 'dist' gives us some useful cover= age + - mkdir build && cd build + - ../autogen.sh --prefix=3D$(pwd)/install-root && make -j3 && make= -j3 install && make -j3 dist =20 git: submodules: true --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977028; cv=none; d=zohomail.com; s=zohoarc; b=Wg30nyFN/uvWmQZZCNMBM5kTG05M9xcQrgCpaZZpfMijLxZR6f8riyb1M1k+KQNCzgmx7xGhCPN9es4bVDhfo0WdjbJa/ui8w1nc395dPhhqCxq14I36mH6eiRbifZhjOThaSu3+lrG4uTeO3xohTqj+HcjW5w33Y+e4YN1r/3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977028; 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=v1f4chY14aDtz+1oZGiCxKwPstLYayXWefoii7yGWzY=; b=PSoRh06atqyiRX8iPss9AGAMI4SzdpPZg6DzjEPZsi9C0+VvcVyXXd5IsfQk53nyD3MoMNGbjzeLZHkArdchF3crlHhJsGWlxnOlRw1EMS5cBxnIpcxf52lWZV2geGFM1THOyWaflMiWYZR53B7iWxmLhvOdnh+PzzOOAESOUcE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1577977028840256.1098577087471; Thu, 2 Jan 2020 06:57:08 -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-210-nPhXiPgbMDCxvPwIlFeJbw-1; Thu, 02 Jan 2020 09:56:45 -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 59301911AF; Thu, 2 Jan 2020 14:56:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 31EAC7E48D; Thu, 2 Jan 2020 14:56:35 +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 E3F4981E34; Thu, 2 Jan 2020 14:56:34 +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 002EuShq004733 for ; Thu, 2 Jan 2020 09:56:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4933660C85; Thu, 2 Jan 2020 14:56:28 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE73B60BF4; Thu, 2 Jan 2020 14:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977027; 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=v1f4chY14aDtz+1oZGiCxKwPstLYayXWefoii7yGWzY=; b=Fk5jjlH00MNWRu0elh6ls3DmCJcvesvMrYHJcFjDz4LR4oNV9RLGOvjwc8lVDqphng0K8Y iYsdui9/1VgkezAp3bRQcnCPnqgwizSeWTM4r52McCiktAh+KBGNkF5oPNV+DO5CLUWD0x UJ7pNrwRNijaf2BGig483JJhoNdK3X4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:38 +0000 Message-Id: <20200102145357.6724-5-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/23] util: add note about event file descriptors on Windows 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: nPhXiPgbMDCxvPwIlFeJbw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) When using GNULIB with Winsock, libvirt will never see the normal HANDLE objects, instead GNULIB guarantees that libvirt gets a C runtime file descriptor. The GNULIB poll impl also expects to get C runtime file descriptors rather than HANDLE objects. Document this behaviour so that it is clear to applications providing event loop implementations if they need Windows portability. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- build-aux/syntax-check.mk | 2 +- include/libvirt/libvirt-event.h | 4 ++++ src/util/virevent.c | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 19a11ce348..8de82e9872 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -2238,7 +2238,7 @@ exclude_file_name_regexp--sc_prohibit_strdup =3D \ ^(docs/|examples/|src/util/virstring\.c|tests/vir(netserverclient|cgroup= )mock.c|tests/commandhelper\.c|tools/nss/libvirt_nss_(leases|macs)\.c$$) =20 exclude_file_name_regexp--sc_prohibit_close =3D \ - (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/virfile\.c|src/libvirt-stream\= .c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/nss/libv= irt_nss_(leases|macs)\.c)$$) + (\.p[yl]$$|\.spec\.in$$|^docs/|^(src/util/vir(file|event)\.c|src/libvirt= -stream\.c|tests/(vir.+mock\.c|commandhelper\.c|qemusecuritymock\.c)|tools/= nss/libvirt_nss_(leases|macs)\.c)$$) =20 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF =3D \ (^tests/(virhostcpu|virpcitest)data/|docs/js/.*\.js|docs/fonts/.*\.woff|= \.diff|tests/virconfdata/no-newline\.conf$$) diff --git a/include/libvirt/libvirt-event.h b/include/libvirt/libvirt-even= t.h index 734dbdcbc1..facdc3a3ec 100644 --- a/include/libvirt/libvirt-event.h +++ b/include/libvirt/libvirt-event.h @@ -67,6 +67,10 @@ typedef void (*virEventHandleCallback)(int watch, int fd= , int events, void *opaq * listen for specific events. The same file handle can be registered * multiple times provided the requested event sets are non-overlapping * + * @fd will always be a C runtime file descriptor. On Windows + * the _get_osfhandle() method can be used if a HANDLE is required + * instead. + * * If the opaque user data requires free'ing when the handle * is unregistered, then a 2nd callback can be supplied for * this purpose. This callback needs to be invoked from a clean stack. diff --git a/src/util/virevent.c b/src/util/virevent.c index f6c797724e..fd5d8f5bf1 100644 --- a/src/util/virevent.c +++ b/src/util/virevent.c @@ -60,6 +60,13 @@ static virEventRemoveTimeoutFunc removeTimeoutImpl; * requires that an event loop has previously been registered with * virEventRegisterImpl() or virEventRegisterDefaultImpl(). * + * @fd must always always be a C runtime file descriptor. On Windows + * if the caller only has a HANDLE, the _open_osfhandle() method can + * be used to open an associated C runtime file descriptor for use + * with this API. After opening a runtime file descriptor, CloseHandle() + * must not be used, instead close() will close the runtime file + * descriptor and its original associated HANDLE. + * * Returns -1 if the file handle cannot be registered, otherwise a handle * watch number to be used for updating and unregistering for events. */ --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977006; cv=none; d=zohomail.com; s=zohoarc; b=gkxGDcsDb6wR0ZHhRY3hDMzMMK+6x8yIK2v2SKGdiqe+zr9ihZ0YLRh6LtpmWpHsW44WSx7YYbipjlbG9G+KghpLf9NeGtz3XQvC+sXv7or0RYIYFFcuntWdpXMy4lsJo4JV6z2BYZRaNNpih7zYNGiLTJIIlaZTPoc4fGQBzhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977006; 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=w0lxnurAgMnxYsGBIdeh4BD9OvrcI6aZ8rotvpwLaso=; b=PQRJeKg8kNBmEm35q5gA1andailoSWCA/o7Z6ecYoUEUh8CisYSPZgm+b1Y0VWeO3tNfpf+D4Yrh7lLKG+c5/IBJ/xhk0cjLphlrjUoAnP8J/OYAumhfRSM9xuAsG+J5uxFKulvfmz3M/YSTrd+NnyVFKqInr7Em+Kk7d4/DCbU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 15779770067012.332783042211986; Thu, 2 Jan 2020 06:56:46 -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-182-ZSHiNLvmPp6IwUfHEUfa-g-1; Thu, 02 Jan 2020 09:56:42 -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 5BF9F8024D6; Thu, 2 Jan 2020 14:56:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32E6F60BF4; Thu, 2 Jan 2020 14:56:35 +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 E383D81E33; Thu, 2 Jan 2020 14:56:34 +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 002EuTUS004738 for ; Thu, 2 Jan 2020 09:56:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2B88960C85; Thu, 2 Jan 2020 14:56:29 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E91E60BF4; Thu, 2 Jan 2020 14:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977005; 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=w0lxnurAgMnxYsGBIdeh4BD9OvrcI6aZ8rotvpwLaso=; b=QKkMpGbhPKau6MVbg88i1jKCpYGq5As6mFbHpxj5CCp4DfmZF/iYLzi56qmjJOKzlvJlhM y0Ml+yLcs1xgwvCfGqiT7AYwu60qykHZEC1GuMg+E3aFrMdeuGuxffmLgYT7ADyTldc6GK S8Oc80MFoj0BuCH4Qxu8u41BaHMKFzo= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:39 +0000 Message-Id: <20200102145357.6724-6-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/23] src: always pull in glib/gstdio.h header 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: ZSHiNLvmPp6IwUfHEUfa-g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The gstdio.h header defines some low level wrappers for things like fsync, stat, lstat, etc. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/internal.h | 4 +--- src/util/glibcompat.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/internal.h b/src/internal.h index 780f425d2c..686b7cfcc2 100644 --- a/src/internal.h +++ b/src/internal.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include "glibcompat.h" =20 #if STATIC_ANALYSIS # undef NDEBUG /* Don't let a prior NDEBUG definition cause trouble. */ @@ -63,8 +63,6 @@ #include "libvirt/libvirt-admin.h" #include "libvirt/virterror.h" =20 -#include "glibcompat.h" - /* Merely casting to (void) is not sufficient since the * introduction of the "warn_unused_result" attribute */ diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index 9c5fef09bf..2bbbe57612 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -19,6 +19,7 @@ #pragma once =20 #include +#include =20 char *vir_g_strdup_printf(const char *msg, ...) G_GNUC_PRINTF(1, 2); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977011; cv=none; d=zohomail.com; s=zohoarc; b=j1kh+9zt4Zmc09Z7jEpr4PHd3QtdxBR0+kOElcV2F1eVF5cMcFiPVKEfJU61Fwkbk64J3mTwVR8t7TYQlcieWKA00FdPun8tOehxUVydBE0OmdV/T3ErGLrGliIiUM5T+Nu/L6UcymZ3cnUa91eK3Ud7s2H1gzcRK3Fzwtjtn1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977011; 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=kMw/q5G1ZN6tuuWA5NC2y0z92zg1fBqVHb14lvX/QMs=; b=K0sYlvTH5pjfjWGH8Hpwk909C8fWfB94YGn+jU9Ru88Vf/yyEqK2L11FmyNttlwJIp+sG7hPHxAnrmEwe3l8QVft7wbJgCajbkt8wyM58tWJh/+WpP/61+QhHNNnxoI8erPtd+5ZY6j+AUFS759Jt13vlNGBc1QHWqTIFzNriNU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 157797701116141.19854498113682; Thu, 2 Jan 2020 06:56:51 -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-12-DF1ms5D-Pv61gE2nFXzrbw-1; Thu, 02 Jan 2020 09:56:45 -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 B817018CA253; Thu, 2 Jan 2020 14:56:38 +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 8CF075DA76; Thu, 2 Jan 2020 14:56:38 +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 13F3F81E34; Thu, 2 Jan 2020 14:56:38 +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 002EuUWT004758 for ; Thu, 2 Jan 2020 09:56:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2F60E60C87; Thu, 2 Jan 2020 14:56:30 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7132760BF4; Thu, 2 Jan 2020 14:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977009; 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=kMw/q5G1ZN6tuuWA5NC2y0z92zg1fBqVHb14lvX/QMs=; b=VerF79VbiAmQ5HoGZSjgVUAmOQYsXCFGH61hF/9zDCpxG+qqv28Iq0CzNDBJvgK2YPAJ3a oWqgDTxfU2/JKPmICeZoj20WMQ20x6KawU35LV0bX63eTNNI8bXHLjlSzXKJqsiS8o4ywE R2LRDekCxLaFBueFmbDogQ8qHJ2GaK4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:40 +0000 Message-Id: <20200102145357.6724-7-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/23] src: switch to use g_setenv/g_unsetenv 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: DF1ms5D-Pv61gE2nFXzrbw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Eliminate direct use of normal setenv/unsetenv calls in favour of GLib's wrapper. This eliminates two gnulib modules Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/security/virt-aa-helper.c | 4 +-- src/util/virsystemd.c | 4 +-- src/vbox/vbox_XPCOMCGlue.c | 4 +-- tests/libxlxml2domconfigtest.c | 4 +-- tests/lxcxml2xmltest.c | 2 +- tests/qemudomaincheckpointxml2xmltest.c | 2 +- tests/qemudomainsnapshotxml2xmltest.c | 2 +- tests/qemufirmwaretest.c | 2 +- tests/qemuhotplugtest.c | 2 +- tests/qemumemlocktest.c | 2 +- tests/qemusecuritytest.c | 4 +-- tests/qemuvhostusertest.c | 2 +- tests/qemuxml2argvtest.c | 24 ++++++------- tests/qemuxml2xmltest.c | 4 +-- tests/securityselinuxhelper.c | 4 +-- tests/testutils.c | 8 ++--- tests/testutils.h | 4 +-- tests/testutilsqemu.c | 4 +-- tests/vircgrouptest.c | 16 ++++----- tests/virfiletest.c | 4 +-- tests/virhostdevtest.c | 2 +- tests/virnettlscontexttest.c | 2 +- tests/virnettlssessiontest.c | 2 +- tests/virpcitest.c | 2 +- tests/virportallocatortest.c | 2 +- tests/virsystemdtest.c | 46 ++++++++++++------------- tests/virtimetest.c | 4 +-- tools/virt-login-shell-helper.c | 12 +++---- 28 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index f623ff965f..feb03b0aa9 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1447,11 +1447,11 @@ main(int argc, char **argv) =20 /* clear the environment */ environ =3D NULL; - if (setenv("PATH", "/sbin:/usr/sbin", 1) !=3D 0) + if (g_setenv("PATH", "/sbin:/usr/sbin", 1) =3D=3D FALSE) vah_error(ctl, 1, _("could not set PATH")); =20 /* ensure the traditional IFS setting */ - if (setenv("IFS", " \t\n", 1) !=3D 0) + if (g_setenv("IFS", " \t\n", 1) =3D=3D FALSE) vah_error(ctl, 1, _("could not set IFS")); =20 if (!(progname =3D strrchr(argv[0], '/'))) diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 2acb54d41e..96d43e5440 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -854,8 +854,8 @@ virSystemdGetListenFDs(void) return 0; } =20 - unsetenv("LISTEN_PID"); - unsetenv("LISTEN_FDS"); + g_unsetenv("LISTEN_PID"); + g_unsetenv("LISTEN_FDS"); =20 VIR_DEBUG("Got %u file descriptors", nfds); =20 diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c index f48a78a923..4151d20909 100644 --- a/src/vbox/vbox_XPCOMCGlue.c +++ b/src/vbox/vbox_XPCOMCGlue.c @@ -104,9 +104,9 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignor= eMissing, */ if (setAppHome) { if (dir !=3D NULL) { - setenv("VBOX_APP_HOME", dir, 1 /* always override */); + g_setenv("VBOX_APP_HOME", dir, 1 /* always override */); } else { - unsetenv("VBOX_APP_HOME"); + g_unsetenv("VBOX_APP_HOME"); } } =20 diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c index 35f0ce8f7d..f3b8c8bffd 100644 --- a/tests/libxlxml2domconfigtest.c +++ b/tests/libxlxml2domconfigtest.c @@ -160,8 +160,8 @@ mymain(void) * results. In order to detect things that just work by a blind * chance, we need to set an virtual timezone that no libvirt * developer resides in. */ - if (setenv("TZ", "VIR00:30", 1) < 0) { - perror("setenv"); + if (g_setenv("TZ", "VIR00:30", 1) =3D=3D FALSE) { + perror("g_setenv"); return EXIT_FAILURE; } =20 diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 7b05f7d016..f7457e719a 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -75,7 +75,7 @@ mymain(void) /* Unset or set all envvars here that are copied in lxcdBuildCommandLi= ne * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected * values for these envvars */ - setenv("PATH", "/bin", 1); + g_setenv("PATH", "/bin", 1); =20 DO_TEST("systemd"); DO_TEST("hostdev"); diff --git a/tests/qemudomaincheckpointxml2xmltest.c b/tests/qemudomainchec= kpointxml2xmltest.c index 4d6904a592..b27c0e362a 100644 --- a/tests/qemudomaincheckpointxml2xmltest.c +++ b/tests/qemudomaincheckpointxml2xmltest.c @@ -175,7 +175,7 @@ mymain(void) /* Unset or set all envvars here that are copied in qemudBuildCommandL= ine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected * values for these envvars */ - setenv("PATH", "/bin", 1); + g_setenv("PATH", "/bin", 1); =20 /* Test a normal user redefine */ DO_TEST_OUT("redefine", 0); diff --git a/tests/qemudomainsnapshotxml2xmltest.c b/tests/qemudomainsnapsh= otxml2xmltest.c index 6bff5d14f5..ebdfea7eca 100644 --- a/tests/qemudomainsnapshotxml2xmltest.c +++ b/tests/qemudomainsnapshotxml2xmltest.c @@ -160,7 +160,7 @@ mymain(void) /* Unset or set all envvars here that are copied in qemudBuildCommandL= ine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected * values for these envvars */ - setenv("PATH", "/bin", 1); + g_setenv("PATH", "/bin", 1); =20 DO_TEST_OUT("all_parameters", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", TEST_INTERNAL); diff --git a/tests/qemufirmwaretest.c b/tests/qemufirmwaretest.c index 906d594ace..dffe47c386 100644 --- a/tests/qemufirmwaretest.c +++ b/tests/qemufirmwaretest.c @@ -70,7 +70,7 @@ testFWPrecedence(const void *opaque G_GNUC_UNUSED) =20 fakehome =3D g_strdup(abs_srcdir "/qemufirmwaredata/home/user/.config"= ); =20 - setenv("XDG_CONFIG_HOME", fakehome, 1); + g_setenv("XDG_CONFIG_HOME", fakehome, 1); =20 if (qemuFirmwareFetchConfigs(&fwList, false) < 0) return -1; diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index 6ab2d9b0f4..e7fe8da0b7 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -603,7 +603,7 @@ mymain(void) abort(); } =20 - setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c index 7de0d72410..455306b0c2 100644 --- a/tests/qemumemlocktest.c +++ b/tests/qemumemlocktest.c @@ -67,7 +67,7 @@ mymain(void) abort(); } =20 - setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 if (qemuTestDriverInit(&driver) < 0) { VIR_FREE(fakerootdir); diff --git a/tests/qemusecuritytest.c b/tests/qemusecuritytest.c index 380c3fed8c..bf34eb2f71 100644 --- a/tests/qemusecuritytest.c +++ b/tests/qemusecuritytest.c @@ -111,7 +111,7 @@ testDomain(const void *opaque) =20 /* Mocking is enabled only when this env variable is set. * See mock code for explanation. */ - if (setenv(ENVVAR, "1", 0) < 0) + if (g_setenv(ENVVAR, "1", 0) =3D=3D FALSE) return -1; =20 if (qemuSecuritySetAllLabel(data->driver, vm, NULL, false) < 0) @@ -124,7 +124,7 @@ testDomain(const void *opaque) =20 ret =3D 0; cleanup: - unsetenv(ENVVAR); + g_unsetenv(ENVVAR); freePaths(); return ret; } diff --git a/tests/qemuvhostusertest.c b/tests/qemuvhostusertest.c index cc1e523841..6ff7923099 100644 --- a/tests/qemuvhostusertest.c +++ b/tests/qemuvhostusertest.c @@ -68,7 +68,7 @@ testVUPrecedence(const void *opaque G_GNUC_UNUSED) =20 fakehome =3D g_strdup(abs_srcdir "/qemuvhostuserdata/home/user/.config= "); =20 - setenv("XDG_CONFIG_HOME", fakehome, 1); + g_setenv("XDG_CONFIG_HOME", fakehome, 1); =20 if (qemuVhostUserFetchConfigs(&vuList, false) < 0) return -1; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index bfbed5c31d..cc34d0caee 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -618,15 +618,15 @@ mymain(void) abort(); } =20 - setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 /* Set the timezone because we are mocking the time() function. * If we don't do that, then localtime() may return unpredictable * results. In order to detect things that just work by a blind * chance, we need to set an virtual timezone that no libvirt * developer resides in. */ - if (setenv("TZ", "VIR00:30", 1) < 0) { - perror("setenv"); + if (g_setenv("TZ", "VIR00:30", 1) =3D=3D FALSE) { + perror("g_setenv"); return EXIT_FAILURE; } =20 @@ -797,15 +797,15 @@ mymain(void) /* Unset or set all envvars here that are copied in qemudBuildCommandL= ine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected * values for these envvars */ - setenv("PATH", "/bin", 1); - setenv("USER", "test", 1); - setenv("LOGNAME", "test", 1); - setenv("HOME", "/home/test", 1); - unsetenv("TMPDIR"); - unsetenv("LD_PRELOAD"); - unsetenv("LD_LIBRARY_PATH"); - unsetenv("QEMU_AUDIO_DRV"); - unsetenv("SDL_AUDIODRIVER"); + g_setenv("PATH", "/bin", 1); + g_setenv("USER", "test", 1); + g_setenv("LOGNAME", "test", 1); + g_setenv("HOME", "/home/test", 1); + g_unsetenv("TMPDIR"); + g_unsetenv("LD_PRELOAD"); + g_unsetenv("LD_LIBRARY_PATH"); + g_unsetenv("QEMU_AUDIO_DRV"); + g_unsetenv("SDL_AUDIODRIVER"); =20 DO_TEST("minimal", NONE); DO_TEST("minimal-sandbox", diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 34c2ec8c5f..6463cf81e2 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -147,7 +147,7 @@ mymain(void) abort(); } =20 - setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 /* Required for tpm-emulator tests */ @@ -234,7 +234,7 @@ mymain(void) /* Unset or set all envvars here that are copied in qemudBuildCommandL= ine * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected * values for these envvars */ - setenv("PATH", "/bin", 1); + g_setenv("PATH", "/bin", 1); =20 DO_TEST("minimal", NONE); DO_TEST_CAPS_LATEST("genid"); diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index 8b90ddada9..50d4f40dc5 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -145,7 +145,7 @@ int setcon_raw(const char *context) errno =3D EINVAL; return -1; } - return setenv("FAKE_SELINUX_CONTEXT", context, 1); + return g_setenv("FAKE_SELINUX_CONTEXT", context, 1); } =20 int setcon(const char *context) @@ -224,7 +224,7 @@ int security_disable(void) return -1; } =20 - return setenv("FAKE_SELINUX_DISABLED", "1", 1); + return g_setenv("FAKE_SELINUX_DISABLED", "1", 1); } =20 int security_getenforce(void) diff --git a/tests/testutils.c b/tests/testutils.c index 6efc877d0c..5bc108a6c3 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -127,7 +127,7 @@ virTestRun(const char *title, /* Some test are fragile about environ settings. If that's * the case, don't poison it. */ if (getenv("VIR_TEST_MOCK_PROGNAME")) - setenv("VIR_TEST_MOCK_TESTNAME", title, 1); + g_setenv("VIR_TEST_MOCK_TESTNAME", title, 1); =20 if (testCounter =3D=3D 0 && !virTestGetVerbose()) fprintf(stderr, " "); @@ -176,7 +176,7 @@ virTestRun(const char *title, fprintf(stderr, "!"); } =20 - unsetenv("VIR_TEST_MOCK_TESTNAME"); + g_unsetenv("VIR_TEST_MOCK_TESTNAME"); return ret; } =20 @@ -836,7 +836,7 @@ virTestSetEnvPath(void) } =20 if (new_path && - setenv("PATH", new_path, 1) < 0) + g_setenv("PATH", new_path, 1) < 0) goto cleanup; =20 ret =3D 0; @@ -870,7 +870,7 @@ int virTestMain(int argc, if (STRPREFIX(progname, "lt-")) progname +=3D 3; =20 - setenv("VIR_TEST_MOCK_PROGNAME", progname, 1); + g_setenv("VIR_TEST_MOCK_PROGNAME", progname, 1); =20 virFileActivateDirOverrideForProg(argv[0]); =20 diff --git a/tests/testutils.h b/tests/testutils.h index dcb7cc4c04..74785b7fb8 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -121,7 +121,7 @@ int virTestMain(int argc, #ifdef __APPLE__ # define PRELOAD_VAR "DYLD_INSERT_LIBRARIES" # define FORCE_FLAT_NAMESPACE \ - setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1); + g_setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1); # define MOCK_EXT ".dylib" #else # define PRELOAD_VAR "LD_PRELOAD" @@ -143,7 +143,7 @@ int virTestMain(int argc, } else { \ newenv =3D g_strdup_printf("%s:%s", lib, preload); \ } \ - setenv(PRELOAD_VAR, newenv, 1); \ + g_setenv(PRELOAD_VAR, newenv, 1); \ FORCE_FLAT_NAMESPACE \ execv(argv[0], argv); \ } \ diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index d077f8cd2d..4ca72446da 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -260,10 +260,10 @@ qemuTestSetHostCPU(virQEMUDriverPtr driver, cpu =3D cpuPower8; } =20 - unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU"); + g_unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU"); if (cpu) { if (cpu->model) - setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1); + g_setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1); } if (driver) { if (cpu) diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 5e9f619a84..cde07518ef 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -187,7 +187,7 @@ testCgroupDetectMounts(const void *args) virBuffer buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 - setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1); + g_setenv("VIR_CGROUP_MOCK_FILENAME", data->file, 1); =20 parsed =3D g_strdup_printf("%s/vircgroupdata/%s.parsed", abs_srcdir, d= ata->file); =20 @@ -215,7 +215,7 @@ testCgroupDetectMounts(const void *args) result =3D 0; =20 cleanup: - unsetenv("VIR_CGROUP_MOCK_FILENAME"); + g_unsetenv("VIR_CGROUP_MOCK_FILENAME"); VIR_FREE(parsed); virCgroupFree(&group); virBufferFreeAndReset(&buf); @@ -994,13 +994,13 @@ initFakeFS(const char *mode, abort(); } =20 - setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 if (mode) - setenv("VIR_CGROUP_MOCK_MODE", mode, 1); + g_setenv("VIR_CGROUP_MOCK_MODE", mode, 1); =20 if (filename) - setenv("VIR_CGROUP_MOCK_FILENAME", filename, 1); + g_setenv("VIR_CGROUP_MOCK_FILENAME", filename, 1); =20 return fakerootdir; } @@ -1012,9 +1012,9 @@ cleanupFakeFS(char *fakerootdir) virFileDeleteTree(fakerootdir); =20 VIR_FREE(fakerootdir); - unsetenv("LIBVIRT_FAKE_ROOT_DIR"); - unsetenv("VIR_CGROUP_MOCK_MODE"); - unsetenv("VIR_CGROUP_MOCK_FILENAME"); + g_unsetenv("LIBVIRT_FAKE_ROOT_DIR"); + g_unsetenv("VIR_CGROUP_MOCK_MODE"); + g_unsetenv("VIR_CGROUP_MOCK_FILENAME"); } =20 static int diff --git a/tests/virfiletest.c b/tests/virfiletest.c index 781c640e2b..4d69df5b56 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -327,7 +327,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED) =20 mtabFile =3D g_strdup_printf(abs_srcdir "/virfiledata/%s", data->mtabF= ile); =20 - if (setenv("LIBVIRT_MTAB", mtabFile, 1) < 0) { + if (g_setenv("LIBVIRT_MTAB", mtabFile, 1) =3D=3D FALSE) { fprintf(stderr, "Unable to set env variable\n"); goto cleanup; } @@ -343,7 +343,7 @@ testFileIsSharedFSType(const void *opaque G_GNUC_UNUSED) ret =3D 0; cleanup: VIR_FREE(mtabFile); - unsetenv("LIBVIRT_MTAB"); + g_unsetenv("LIBVIRT_MTAB"); return ret; #endif } diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index ffd7ce1aab..1c648f466a 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -603,7 +603,7 @@ mymain(void) abort(); } =20 - setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 # define DO_TEST(fnc) \ do { \ diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c index 6c01336420..2210c8cc91 100644 --- a/tests/virnettlscontexttest.c +++ b/tests/virnettlscontexttest.c @@ -111,7 +111,7 @@ mymain(void) { int ret =3D 0; =20 - setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); + g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); =20 testTLSInit(KEYFILE); =20 diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c index 997cf5a372..59924c7037 100644 --- a/tests/virnettlssessiontest.c +++ b/tests/virnettlssessiontest.c @@ -239,7 +239,7 @@ mymain(void) { int ret =3D 0; =20 - setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); + g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); =20 testTLSInit(KEYFILE); =20 diff --git a/tests/virpcitest.c b/tests/virpcitest.c index 68fe9c8345..922f241d54 100644 --- a/tests/virpcitest.c +++ b/tests/virpcitest.c @@ -334,7 +334,7 @@ mymain(void) abort(); } =20 - setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); + g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); =20 # define DO_TEST(fnc) \ do { \ diff --git a/tests/virportallocatortest.c b/tests/virportallocatortest.c index 8e62fc4519..4e50cd74b3 100644 --- a/tests/virportallocatortest.c +++ b/tests/virportallocatortest.c @@ -171,7 +171,7 @@ mymain(void) if (virTestRun("Test alloc reuse", testAllocReuse, NULL) < 0) ret =3D -1; =20 - setenv("LIBVIRT_TEST_IPV4ONLY", "really", 1); + g_setenv("LIBVIRT_TEST_IPV4ONLY", "really", 1); =20 if (virTestRun("Test IPv4-only alloc all", testAllocAll, NULL) < 0) ret =3D -1; diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index b5624241bb..583d7efd65 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -236,7 +236,7 @@ static int testCreateNoSystemd(const void *opaque G_GNU= C_UNUSED) }; int rv; =20 - setenv("FAIL_NO_SERVICE", "1", 1); + g_setenv("FAIL_NO_SERVICE", "1", 1); =20 if ((rv =3D virSystemdCreateMachine("demo", "qemu", @@ -246,11 +246,11 @@ static int testCreateNoSystemd(const void *opaque G_G= NUC_UNUSED) false, 0, NULL, NULL, 0)) =3D=3D 0) { - unsetenv("FAIL_NO_SERVICE"); + g_unsetenv("FAIL_NO_SERVICE"); fprintf(stderr, "%s", "Unexpected create machine success\n"); return -1; } - unsetenv("FAIL_NO_SERVICE"); + g_unsetenv("FAIL_NO_SERVICE"); =20 if (rv !=3D -2) { fprintf(stderr, "%s", "Unexpected create machine error\n"); @@ -270,7 +270,7 @@ static int testCreateSystemdNotRunning(const void *opaq= ue G_GNUC_UNUSED) }; int rv; =20 - setenv("FAIL_NOT_REGISTERED", "1", 1); + g_setenv("FAIL_NOT_REGISTERED", "1", 1); =20 if ((rv =3D virSystemdCreateMachine("demo", "qemu", @@ -280,11 +280,11 @@ static int testCreateSystemdNotRunning(const void *op= aque G_GNUC_UNUSED) false, 0, NULL, NULL, 0)) =3D=3D 0) { - unsetenv("FAIL_NOT_REGISTERED"); + g_unsetenv("FAIL_NOT_REGISTERED"); fprintf(stderr, "%s", "Unexpected create machine success\n"); return -1; } - unsetenv("FAIL_NOT_REGISTERED"); + g_unsetenv("FAIL_NOT_REGISTERED"); =20 if (rv !=3D -2) { fprintf(stderr, "%s", "Unexpected create machine error\n"); @@ -304,7 +304,7 @@ static int testCreateBadSystemd(const void *opaque G_GN= UC_UNUSED) }; int rv; =20 - setenv("FAIL_BAD_SERVICE", "1", 1); + g_setenv("FAIL_BAD_SERVICE", "1", 1); =20 if ((rv =3D virSystemdCreateMachine("demo", "qemu", @@ -314,11 +314,11 @@ static int testCreateBadSystemd(const void *opaque G_= GNUC_UNUSED) false, 0, NULL, NULL, 0)) =3D=3D 0) { - unsetenv("FAIL_BAD_SERVICE"); + g_unsetenv("FAIL_BAD_SERVICE"); fprintf(stderr, "%s", "Unexpected create machine success\n"); return -1; } - unsetenv("FAIL_BAD_SERVICE"); + g_unsetenv("FAIL_BAD_SERVICE"); =20 if (rv !=3D -1) { fprintf(stderr, "%s", "Unexpected create machine error\n"); @@ -445,7 +445,7 @@ static int testPMSupportHelper(const void *opaque) const struct testPMSupportData *data =3D opaque; =20 for (i =3D 0; i < 4; i++) { - setenv("RESULT_SUPPORT", results[i], 1); + g_setenv("RESULT_SUPPORT", results[i], 1); if ((rv =3D data->tested(&result)) < 0) { fprintf(stderr, "%s", "Unexpected canSuspend error\n"); return -1; @@ -455,12 +455,12 @@ static int testPMSupportHelper(const void *opaque) fprintf(stderr, "Unexpected result for answer '%s'\n", results= [i]); goto error; } - unsetenv("RESULT_SUPPORT"); + g_unsetenv("RESULT_SUPPORT"); } =20 return 0; error: - unsetenv("RESULT_SUPPORT"); + g_unsetenv("RESULT_SUPPORT"); return -1; } =20 @@ -470,14 +470,14 @@ static int testPMSupportHelperNoSystemd(const void *o= paque) bool result; const struct testPMSupportData *data =3D opaque; =20 - setenv("FAIL_NO_SERVICE", "1", 1); + g_setenv("FAIL_NO_SERVICE", "1", 1); =20 if ((rv =3D data->tested(&result)) =3D=3D 0) { - unsetenv("FAIL_NO_SERVICE"); + g_unsetenv("FAIL_NO_SERVICE"); fprintf(stderr, "%s", "Unexpected canSuspend success\n"); return -1; } - unsetenv("FAIL_NO_SERVICE"); + g_unsetenv("FAIL_NO_SERVICE"); =20 if (rv !=3D -2) { fprintf(stderr, "%s", "Unexpected canSuspend error\n"); @@ -493,14 +493,14 @@ static int testPMSupportSystemdNotRunning(const void = *opaque) bool result; const struct testPMSupportData *data =3D opaque; =20 - setenv("FAIL_NOT_REGISTERED", "1", 1); + g_setenv("FAIL_NOT_REGISTERED", "1", 1); =20 if ((rv =3D data->tested(&result)) =3D=3D 0) { - unsetenv("FAIL_NOT_REGISTERED"); + g_unsetenv("FAIL_NOT_REGISTERED"); fprintf(stderr, "%s", "Unexpected canSuspend success\n"); return -1; } - unsetenv("FAIL_NOT_REGISTERED"); + g_unsetenv("FAIL_NOT_REGISTERED"); =20 if (rv !=3D -2) { fprintf(stderr, "%s", "Unexpected canSuspend error\n"); @@ -567,13 +567,13 @@ testActivation(bool useNames) g_snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP); g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid()); =20 - setenv("LISTEN_FDS", nfdstr, 1); - setenv("LISTEN_PID", pidstr, 1); + g_setenv("LISTEN_FDS", nfdstr, 1); + g_setenv("LISTEN_PID", pidstr, 1); =20 if (useNames) - setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1); + g_setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), 1); else - unsetenv("LISTEN_FDNAMES"); + g_unsetenv("LISTEN_FDNAMES"); =20 map[0].name =3D "demo-unix.socket"; map[0].family =3D AF_UNIX; @@ -640,7 +640,7 @@ testActivationEmpty(const void *opaque G_GNUC_UNUSED) { virSystemdActivationPtr act; =20 - unsetenv("LISTEN_FDS"); + g_unsetenv("LISTEN_FDS"); =20 if (virSystemdGetActivation(NULL, 0, &act) < 0) return -1; diff --git a/tests/virtimetest.c b/tests/virtimetest.c index 1eb321858b..4860bf758f 100644 --- a/tests/virtimetest.c +++ b/tests/virtimetest.c @@ -79,8 +79,8 @@ testTimeLocalOffset(const void *args) const testTimeLocalOffsetData *data =3D args; long actual; =20 - if (setenv("TZ", data->zone, 1) < 0) { - perror("setenv"); + if (g_setenv("TZ", data->zone, 1) =3D=3D FALSE) { + perror("g_setenv"); return -1; } tzset(); diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index ace8733968..87735833d9 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -382,13 +382,13 @@ main(int argc, char **argv) } =20 clearenv(); - setenv("PATH", "/bin:/usr/bin", 1); - setenv("SHELL", shcmd, 1); - setenv("USER", name, 1); - setenv("LOGNAME", name, 1); - setenv("HOME", homedir, 1); + g_setenv("PATH", "/bin:/usr/bin", 1); + g_setenv("SHELL", shcmd, 1); + g_setenv("USER", name, 1); + g_setenv("LOGNAME", name, 1); + g_setenv("HOME", homedir, 1); if (term) - setenv("TERM", term, 1); + g_setenv("TERM", term, 1); =20 if (execv(shcmd, (char *const*) shargv) < 0) { virReportSystemError(errno, _("Unable to exec shell %s"), --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977013; cv=none; d=zohomail.com; s=zohoarc; b=inmpHSROY1wWQzLmPCUyMIrFw1BwotAQJ392/ibhx7yiTeXJRoGd1nSb3GJmdrTmI1TL/SxDS4Dc01T2jP7u5Se7J/nV/MIM/fff87UhzdyuxAHtrGPiZT75mqqiv5a8cDFrzynW4lSzdQkBbwmrKEUrN5ji1BPYP3iJdzigzSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977013; 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=4Js4jyGFoz8dchapul9bgNdp5m4a64PDClbnhFqKELM=; b=Jibw8mIblWUgOVgMXrjPLHsMJkl6BPh0J3zUrdemVsw0YSy535Rtk8kaa0Cb/77WdSjYgyne0qJ/ZqydOdUY42fZew1lZVjdXUp2hN38Qw/q8lH3NFwcWUfLz6B5IlI1rce2UPhDtCJaTYZdQeTHgNn9DR/BTP7K2P+M2Vd8XDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977013430961.2282785723298; Thu, 2 Jan 2020 06:56:53 -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-360-7pla9W_INwSyJK0X1sSR7g-1; Thu, 02 Jan 2020 09:56:50 -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 07BAF911BD; Thu, 2 Jan 2020 14:56: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 D3B1B19C5B; Thu, 2 Jan 2020 14:56:38 +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 8F57518089D8; Thu, 2 Jan 2020 14:56:38 +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 002EuVZN004767 for ; Thu, 2 Jan 2020 09:56:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 10B2360C85; Thu, 2 Jan 2020 14:56:31 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74AF960BF4; Thu, 2 Jan 2020 14:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977012; 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=4Js4jyGFoz8dchapul9bgNdp5m4a64PDClbnhFqKELM=; b=GqW3Ju70xZSqm2gXE6DD9gT77bVYDAiGcAmI7th6zt0iQNvig8miqqKsXT2q8Vt+q93vHQ O5WPk2Z5AZJCmtT9s1/QqJaYaOVmVoQcjJWGRVHrwAP9JxYNIbEtkOtt3zM9KA7WVD9UPq iPFngSvQARPJ0s+nk068D8RkkNzPyN0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:41 +0000 Message-Id: <20200102145357.6724-8-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/23] util: add compat wrapper for g_fsync 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: 7pla9W_INwSyJK0X1sSR7g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) g_fsync isn't available until 2.63 so we need a compat wrapper temporarily. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/libvirt_private.syms | 1 + src/util/glibcompat.c | 13 +++++++++++++ src/util/glibcompat.h | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a7b1ef23bc..d3184dbf5c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1504,6 +1504,7 @@ virSecurityManagerVerify; =20 =20 # util/glibcompat.h +vir_g_fsync; vir_g_strdup_printf; vir_g_strdup_vprintf; =20 diff --git a/src/util/glibcompat.c b/src/util/glibcompat.c index 3f830840cf..4ebefb4478 100644 --- a/src/util/glibcompat.c +++ b/src/util/glibcompat.c @@ -19,11 +19,13 @@ #include =20 #include +#include =20 #include "glibcompat.h" =20 #undef g_strdup_printf #undef g_strdup_vprintf +#undef g_fsync =20 /* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf() * abort on OOM. It's fixed in glib's upstream. Provide our own @@ -51,3 +53,14 @@ vir_g_strdup_vprintf(const char *msg, va_list args) abort(); return ret; } + + +gint +vir_g_fsync(gint fd) +{ +#ifdef G_OS_WIN32 + return _commit(fd); +#else + return fsync(fd); +#endif +} diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h index 2bbbe57612..d6b83f4b93 100644 --- a/src/util/glibcompat.h +++ b/src/util/glibcompat.h @@ -25,8 +25,13 @@ char *vir_g_strdup_printf(const char *msg, ...) G_GNUC_PRINTF(1, 2); char *vir_g_strdup_vprintf(const char *msg, va_list args) G_GNUC_PRINTF(1, 0); +gint vir_g_fsync(gint fd); =20 #if !GLIB_CHECK_VERSION(2, 64, 0) # define g_strdup_printf vir_g_strdup_printf # define g_strdup_vprintf vir_g_strdup_vprintf #endif + +#if !GLIB_CHECK_VERSION(2, 63, 0) +# define g_fsync vir_g_fsync +#endif --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977013; cv=none; d=zohomail.com; s=zohoarc; b=PFa52X4eyegbMCYfR5wWigMR/6O+bSbHsgfdc7KjNJ0cXRAGjLtNd+/dzRLOLsFUtHVAsKH0GnPqdYqA+Bxd/i4/pjxoIPBBPA4I+uLLfH9DszU22LMrL24cMI6HlMeH9O7o27rOQincouI04okCBibNpehCLghVDu89BBQT3+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977013; 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=rMfowP4yOPrOTSNu8tpe0PLwWl4kijGccEWKyBDPlT0=; b=jZhAsg87bW2FR4J7a4VqBA7VlLbSqYd0tpfpyerKEjSOndHcoQKanGxZFk1kOEHupb3MUIWOs8ByTZ+eBpHbKpxaTyLTKrV+fRjEwmnWW4aalVxZjk6N8z05UwUsYtSKGgkXsT1AP7YqdJL7c1+yxkYFe/2MMd+NSqzHbL3niic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977013873915.8439993307685; Thu, 2 Jan 2020 06:56:53 -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-358-KtBZ-sTdOWyYSUDWEIXHpw-1; Thu, 02 Jan 2020 09:56:49 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2AD371005510; Thu, 2 Jan 2020 14:56:43 +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 0646F7A4DB; Thu, 2 Jan 2020 14:56:43 +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 B5A0881E36; Thu, 2 Jan 2020 14:56:42 +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 002EuVkx004775 for ; Thu, 2 Jan 2020 09:56:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id E611560C88; Thu, 2 Jan 2020 14:56:31 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 560D560BF4; Thu, 2 Jan 2020 14:56:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977012; 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=rMfowP4yOPrOTSNu8tpe0PLwWl4kijGccEWKyBDPlT0=; b=G4viqB75jzuK98bvDKfES88nMoIphm1rKurLkEaAFRFhrk9uE9PljMOkTxE1NyS/DKIMhT ZSrbQSiIUTHhTDv98Kd9rcFr7IvKlVJlK0xcgRGTDwpJoMEjVAbymuMyZM5R9pNcXwYwpN iXpfK0vCqRjVvXHSV9OZquJ/UEpMqPA= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:42 +0000 Message-Id: <20200102145357.6724-9-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/23] src: use g_fsync for portability X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: KtBZ-sTdOWyYSUDWEIXHpw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The g_fsync() API provides the same Windows portability as GNULIB does for fsync(). Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/nwfilter/nwfilter_dhcpsnoop.c | 2 +- src/storage/storage_util.c | 2 +- src/util/virfile.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 9514dfd75c..9a71d13d57 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1772,7 +1772,7 @@ virNWFilterSnoopLeaseFileWrite(int lfd, const char *i= fkey, goto cleanup; } =20 - ignore_value(fsync(lfd)); + ignore_value(g_fsync(lfd)); =20 cleanup: VIR_FREE(lbuf); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index f2d8810813..c1a6b44f4b 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -384,7 +384,7 @@ createRawFile(int fd, virStorageVolDefPtr vol, } } =20 - if (fsync(fd) < 0) { + if (g_fsync(fd) < 0) { ret =3D -errno; virReportSystemError(errno, _("cannot sync data to file '%s'"), vol->target.path); diff --git a/src/util/virfile.c b/src/util/virfile.c index 0f0d607c59..1784895575 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -519,7 +519,7 @@ virFileRewrite(const char *path, goto cleanup; } =20 - if (fsync(fd) < 0) { + if (g_fsync(fd) < 0) { virReportSystemError(errno, _("cannot sync file '%s'"), newfile); goto cleanup; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977085; cv=none; d=zohomail.com; s=zohoarc; b=Bw3qGy7GSewr5PVLUf55U68lQ8u0uHvGuiWjtwsJoOIUu59/dJqA8LmROnvF6sTBIt9MIdWsHzrn1bU7ZqifnCk3g6Y2NK1nqlnoAH+x2DsDlu9+uAWA0f6NeYki6Rcd9ir8AxRpkYJcmhEOBCmq10hz0Ow5us0nwim1mWCyWfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977085; 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=6OURPRmkTK5RpdiIhSMvPsS/lqfX/GUwx8NCpV1R7Wk=; b=MKDsHGx4S37vHi1fr5t2k/mummS1q31JHWrkiUwdTY2Or9Gnn3E5y2SAezGs2B6oRetrqgbA4+jDTax0qV6/vHhwywOQvQ/WSCaJEscH8+XB6AS21WBUbJKc/WXIgyHIH4ueRNnDTPlSsO4UUePcyvxh6pAPuXc12CS4ishzKbw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977085744322.45873855181594; Thu, 2 Jan 2020 06:58: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-100-_ZVShEcLPRGeW0EKGy38vw-1; Thu, 02 Jan 2020 09:56:49 -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 0B9C9911B0; Thu, 2 Jan 2020 14:56:42 +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 DC7A6271A3; Thu, 2 Jan 2020 14:56:41 +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 99FE6180880C; Thu, 2 Jan 2020 14:56:41 +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 002EuWjY004791 for ; Thu, 2 Jan 2020 09:56:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id C77BE60C87; Thu, 2 Jan 2020 14:56:32 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3757760BF4; Thu, 2 Jan 2020 14:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977084; 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=6OURPRmkTK5RpdiIhSMvPsS/lqfX/GUwx8NCpV1R7Wk=; b=Y+EJkGSnMO6gKak6gHMZMxwLPCd7WGa8L8U68mvZYj7s30NNT5hoT1xYYDQ8/ge8UdMxz8 JEzeDkPoEuf4njPxFDBZeBwYaCcTNW418h1cRc9pD941mHY+tPs1NHXrGyBnUPsk740FXA SphwwK1b4Qg0kupHwPKIuJ0DIH2jpZ4= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:43 +0000 Message-Id: <20200102145357.6724-10-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/23] util: introduce virFileDataSync 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: _ZVShEcLPRGeW0EKGy38vw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) A wrapper that calls g_fsync on Win32/macOS and fdatasync elsewhere. g_fsync is a stronger flush than we need but it satisfies the caller's requirements & matches the approach gnulib takes. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/libvirt_private.syms | 1 + src/storage/storage_util.c | 4 ++-- src/util/iohelper.c | 2 +- src/util/virfile.c | 11 +++++++++++ src/util/virfile.h | 2 ++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d3184dbf5c..951ba7f0ca 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1976,6 +1976,7 @@ virFileChownFiles; virFileClose; virFileComparePaths; virFileCopyACLs; +virFileDataSync; virFileDeleteTree; virFileDirectFdFlag; virFileExists; diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index c1a6b44f4b..45ffd2206e 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -216,7 +216,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, } while ((amtleft -=3D interval) > 0); } =20 - if (fdatasync(fd) < 0) { + if (virFileDataSync(fd) < 0) { ret =3D -errno; virReportSystemError(errno, _("cannot sync data to file '%s'"), vol->target.path); @@ -2539,7 +2539,7 @@ storageBackendWipeLocal(const char *path, remaining -=3D written; } =20 - if (fdatasync(fd) < 0) { + if (virFileDataSync(fd) < 0) { virReportSystemError(errno, _("cannot sync data to volume with path '%s'"= ), path); diff --git a/src/util/iohelper.c b/src/util/iohelper.c index a102a95abb..d864bbeaed 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -154,7 +154,7 @@ runIO(const char *path, int fd, int oflags) } =20 /* Ensure all data is written */ - if (fdatasync(fdout) < 0) { + if (virFileDataSync(fdout) < 0) { if (errno !=3D EINVAL && errno !=3D EROFS) { /* fdatasync() may fail on some special FDs, e.g. pipes */ virReportSystemError(errno, _("unable to fsync %s"), fdoutname= ); diff --git a/src/util/virfile.c b/src/util/virfile.c index 1784895575..c79fe86403 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -4432,3 +4432,14 @@ virFileGetXAttr(const char *path, =20 return ret; } + + +int +virFileDataSync(int fd) +{ +#if defined(__APPLE__) || defined(WIN32) + return g_fsync(fd); +#else + return fdatasync(fd); +#endif +} diff --git a/src/util/virfile.h b/src/util/virfile.h index 264b12c03d..c73f5252e4 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -372,3 +372,5 @@ int virFileSetXAttr(const char *path, int virFileRemoveXAttr(const char *path, const char *name) G_GNUC_NO_INLINE; + +int virFileDataSync(int fd); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977016; cv=none; d=zohomail.com; s=zohoarc; b=mCVGQXB2curlHkAPbSrOX7UAQ9844TyXEvdgDTMZ2k1bFuQnfAKntQUsUAVS6i8fFlzAbm14Hz+VG4tECPHb84IQ+MgnyZu2hW0Xuo0JKUHfhlF3k5TRPtXfixRcsI8XKWpbFBGyFNd0rOshzQgNo02ya6BzAon4pCuRxhWyMZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977016; 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=Q2aEG8LUhjM4P/igOhUDrzv62txnb9guQPu2TOhFM7w=; b=dBIn002Kmx4aHqt4GsTI2isBHNRi2ZendRXwtYZoPgZN4OVHavtAix66YdwbBXn8OmbxxvPRkubddUdYyNLBhLOAFo7uFbVfdevG6+8swcYUD3M2N/dtt0DBCSGhGR12jcHsUhkRrcKj+A+pb1n8K405y1p/PExCD87ZyFw1lFI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977016036609.5304614782488; Thu, 2 Jan 2020 06:56:56 -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-311-vXLBgUvTMmuJwgYzNwQz8Q-1; Thu, 02 Jan 2020 09:56:53 -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 6EB25800D50; Thu, 2 Jan 2020 14:56:46 +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 4024B5DA82; Thu, 2 Jan 2020 14:56:46 +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 EEEF781E3E; Thu, 2 Jan 2020 14:56:45 +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 002EuZo1004807 for ; Thu, 2 Jan 2020 09:56:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6B28560C88; Thu, 2 Jan 2020 14:56:35 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFA2160C85; Thu, 2 Jan 2020 14:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977015; 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=Q2aEG8LUhjM4P/igOhUDrzv62txnb9guQPu2TOhFM7w=; b=WeoQ6oXUYeXhEXFdCsLHHoT0vA4MEQitgjQtMR+uMEreymQQ6ns3Oz5KUSQJVQsCrRkKiZ Ovuw2TjBBCV9inag0cKwXr1V/wUahNGXLCqLAh8piX3dzmbdGyhB5R25Y5Koc1Xyi5G9xK 6mHvPtXWrknveI9DkVPGNlVFLzvGGyM= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:44 +0000 Message-Id: <20200102145357.6724-11-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/23] src: use g_lstat() instead of lstat() 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: vXLBgUvTMmuJwgYzNwQz8Q-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The GLib g_lstat() function provides a portable impl for Win32. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/qemu/qemu_domain.c | 8 ++++---- src/security/security_dac.c | 2 +- src/storage/storage_util.c | 2 +- src/util/vircgroupv1.c | 4 ++-- src/util/virfile.c | 12 ++++++------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ff87720fd1..187aaf5737 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -14232,7 +14232,7 @@ qemuDomainCreateDeviceRecursive(const char *device, { char *devicePath =3D NULL; char *target =3D NULL; - struct stat sb; + GStatBuf sb; int ret =3D -1; bool isLink =3D false; bool isDev =3D false; @@ -14250,7 +14250,7 @@ qemuDomainCreateDeviceRecursive(const char *device, return ret; } =20 - if (lstat(device, &sb) < 0) { + if (g_lstat(device, &sb) < 0) { if (errno =3D=3D ENOENT && allow_noent) { /* Ignore non-existent device. */ return 0; @@ -15106,7 +15106,7 @@ struct qemuDomainAttachDeviceMknodData { virDomainObjPtr vm; const char *file; const char *target; - struct stat sb; + GStatBuf sb; void *acl; #ifdef WITH_SELINUX char *tcon; @@ -15284,7 +15284,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverP= tr driver, data.vm =3D vm; data.file =3D file; =20 - if (lstat(file, &data.sb) < 0) { + if (g_lstat(file, &data.sb) < 0) { virReportSystemError(errno, _("Unable to access %s"), file); return ret; diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 411aa1b159..ccd3874897 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -2365,7 +2365,7 @@ virSecurityDACGetProcessLabelInternal(pid_t pid, =20 path =3D g_strdup_printf("/proc/%d", (int)pid); =20 - if (lstat(path, &sb) < 0) { + if (g_lstat(path, &sb) < 0) { virReportSystemError(errno, _("unable to get uid and gid for PID %d via p= rocfs"), pid); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 45ffd2206e..58225c09f5 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1522,7 +1522,7 @@ virStorageBackendVolOpen(const char *path, struct sta= t *sb, char *base =3D last_component(path); bool noerror =3D (flags & VIR_STORAGE_VOL_OPEN_NOERROR); =20 - if (lstat(path, sb) < 0) { + if (g_lstat(path, sb) < 0) { if (errno =3D=3D ENOENT) { if (noerror) { VIR_WARN("ignoring missing file '%s'", path); diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index 4f6b89cf2e..d2ec7106db 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -223,7 +223,7 @@ virCgroupV1ResolveMountLink(const char *mntDir, g_autofree char *linkSrc =3D NULL; g_autofree char *tmp =3D NULL; char *dirName; - struct stat sb; + GStatBuf sb; =20 tmp =3D g_strdup(mntDir); =20 @@ -241,7 +241,7 @@ virCgroupV1ResolveMountLink(const char *mntDir, linkSrc =3D g_strdup_printf("%s/%s", tmp, typeStr); *dirName =3D '/'; =20 - if (lstat(linkSrc, &sb) < 0) { + if (g_lstat(linkSrc, &sb) < 0) { if (errno =3D=3D ENOENT) { VIR_WARN("Controller %s co-mounted at %s is missing symlink at= %s", typeStr, tmp, linkSrc); diff --git a/src/util/virfile.c b/src/util/virfile.c index c79fe86403..97f86a46e9 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1002,11 +1002,11 @@ int virFileDeleteTree(const char *dir) =20 while ((direrr =3D virDirRead(dh, &de, dir)) > 0) { g_autofree char *filepath =3D NULL; - struct stat sb; + GStatBuf sb; =20 filepath =3D g_strdup_printf("%s/%s", dir, de->d_name); =20 - if (lstat(filepath, &sb) < 0) { + if (g_lstat(filepath, &sb) < 0) { virReportSystemError(errno, _("Cannot access '%s'"), filepath); goto cleanup; @@ -1555,7 +1555,7 @@ virFileResolveLinkHelper(const char *linkpath, bool intermediatePaths, char **resultpath) { - struct stat st; + GStatBuf st; =20 *resultpath =3D NULL; =20 @@ -1563,7 +1563,7 @@ virFileResolveLinkHelper(const char *linkpath, * directories, if linkpath is absolute and the basename is * already a non-symlink. */ if (IS_ABSOLUTE_FILE_NAME(linkpath) && !intermediatePaths) { - if (lstat(linkpath, &st) < 0) + if (g_lstat(linkpath, &st) < 0) return -1; =20 if (!S_ISLNK(st.st_mode)) { @@ -1613,9 +1613,9 @@ virFileResolveAllLinks(const char *linkpath, char **r= esultpath) int virFileIsLink(const char *linkpath) { - struct stat st; + GStatBuf st; =20 - if (lstat(linkpath, &st) < 0) + if (g_lstat(linkpath, &st) < 0) return -errno; =20 return S_ISLNK(st.st_mode) !=3D 0; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977147; cv=none; d=zohomail.com; s=zohoarc; b=dmO7YsMeouAydtt1bIi/KXHH8ZkMFcGMXmHsp3CxIAPqD9k4hIEh/y93AjdIXYzyFdwzjz9X8s07RIapnDbHZYZI8/15KABirdw8TWkxwUQW2xo6HkRCAyTMlVNop3PJS3lHouuN3eV49Ql3OWjEcfbt2wFjGAQZDvGuaPtdiAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977147; 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=rpkf805tYuIgk1r3GALgCZw5imIMdZOfTjvNZNoqyNE=; b=Mtgi5o1QFlSfBd2xpZHD8S6QJg06FK59roq029HscdjwxkoSr29GWXkAXxQQz9SLN7WgXs+C2jArQ4IZJy9ro8wdBOxAyRKeEuqTfqQyyTD7B9Jvpliu7ks4p5K0GL3b5lysJwTxdiAnOIUy3th8KLHp6eGfPux1HFzofMDfrFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977147908179.14969285712687; Thu, 2 Jan 2020 06:59:07 -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-391-93vs5Ua6PiqWzLV-MvJIGA-1; Thu, 02 Jan 2020 09:56:56 -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 23A5D18CA243; Thu, 2 Jan 2020 14:56:50 +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 EE1747D96B; Thu, 2 Jan 2020 14:56:49 +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 A59201803C32; Thu, 2 Jan 2020 14:56:49 +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 002EuaBw004812 for ; Thu, 2 Jan 2020 09:56:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4D25960C85; Thu, 2 Jan 2020 14:56:36 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1E6A60BF4; Thu, 2 Jan 2020 14:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977144; 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=rpkf805tYuIgk1r3GALgCZw5imIMdZOfTjvNZNoqyNE=; b=FaCHABDCeglDL0ZIbJtc0wJYbSDzFYcznp5kzWBuvWUmI+qE+XgsdvGs7+DakYHflZpl6T d/AgXAazWs7w5PJN8dsMczMiPrhmIboKscxJOqylQWVWeqJON9vghSVjozDMXA0pLwnGWX SFhF02xEF/VDfcTdYsPG4sp5F7Qu7a8= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:45 +0000 Message-Id: <20200102145357.6724-12-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/23] src: switch from fnmatch to g_pattern_match_simple 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: 93vs5Ua6PiqWzLV-MvJIGA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The g_pattern_match function_simple is an acceptably close approximation of fnmatch for libvirt's needs. In contrast to fnmatch(), the '/' character can be matched by the wildcards, there are no '[...]' character ranges and '*' and '?' can not be escaped to include them literally in a pattern. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/qemu/qemu_firmware.c | 4 +--- src/remote/libvirtd.conf.in | 8 ++++++-- src/rpc/virnetsaslcontext.c | 11 +---------- src/rpc/virnettlscontext.c | 10 +--------- src/util/virlog.c | 5 ++--- tests/virconfdata/libvirtd.conf | 8 ++++++-- tests/virconfdata/libvirtd.out | 8 ++++++-- tools/virt-login-shell-helper.c | 5 ++--- 8 files changed, 25 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index f62ce90ac9..6a76d355f5 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -20,8 +20,6 @@ =20 #include =20 -#include - #include "qemu_firmware.h" #include "qemu_interop_config.h" #include "configmake.h" @@ -921,7 +919,7 @@ qemuFirmwareMatchesMachineArch(const qemuFirmware *fw, continue; =20 for (j =3D 0; j < fw->targets[i]->nmachines; j++) { - if (fnmatch(fw->targets[i]->machines[j], machine, 0) =3D=3D 0) + if (g_pattern_match_simple(fw->targets[i]->machines[j], machin= e)) return true; } } diff --git a/src/remote/libvirtd.conf.in b/src/remote/libvirtd.conf.in index f984ce0478..34741183cc 100644 --- a/src/remote/libvirtd.conf.in +++ b/src/remote/libvirtd.conf.in @@ -262,7 +262,9 @@ # # "C=3DGB,ST=3DLondon,L=3DLondon,O=3DRed Hat,CN=3D*" # -# See the POSIX fnmatch function for the format of the wildcards. +# See the g_pattern_match function for the format of the wildcards: +# +# https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-matching= .html # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks @@ -288,7 +290,9 @@ # # "*@EXAMPLE.COM" # -# See the POSIX fnmatch function for the format of the wildcards. +# See the g_pattern_match function for the format of the wildcards. +# +# https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-matching= .html # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c index 01ff41b778..e7ed8f4390 100644 --- a/src/rpc/virnetsaslcontext.c +++ b/src/rpc/virnetsaslcontext.c @@ -20,8 +20,6 @@ =20 #include =20 -#include - #include "virnetsaslcontext.h" #include "virnetmessage.h" =20 @@ -155,17 +153,10 @@ int virNetSASLContextCheckIdentity(virNetSASLContextP= tr ctxt, } =20 while (*wildcards) { - int rv =3D fnmatch(*wildcards, identity, 0); - if (rv =3D=3D 0) { + if (g_pattern_match_simple(*wildcards, identity)) { ret =3D 1; goto cleanup; /* Successful match */ } - if (rv !=3D FNM_NOMATCH) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Malformed TLS whitelist regular expression '= %s'"), - *wildcards); - goto cleanup; - } =20 wildcards++; } diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c index 08944f6771..44f0dfce77 100644 --- a/src/rpc/virnettlscontext.c +++ b/src/rpc/virnettlscontext.c @@ -21,7 +21,6 @@ #include =20 #include -#include =20 #include #include @@ -361,15 +360,8 @@ virNetTLSContextCheckCertDNWhitelist(const char *dname, const char *const*wildcards) { while (*wildcards) { - int ret =3D fnmatch(*wildcards, dname, 0); - if (ret =3D=3D 0) /* Successful match */ + if (g_pattern_match_simple(*wildcards, dname)) return 1; - if (ret !=3D FNM_NOMATCH) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Malformed TLS whitelist regular expression '= %s'"), - *wildcards); - return -1; - } =20 wildcards++; } diff --git a/src/util/virlog.c b/src/util/virlog.c index 6bae56e2e3..aa98024e1c 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -36,7 +36,6 @@ #if HAVE_SYS_UN_H # include #endif -#include =20 #include "virerror.h" #include "virlog.h" @@ -488,7 +487,7 @@ virLogSourceUpdate(virLogSourcePtr source) size_t i; =20 for (i =3D 0; i < virLogNbFilters; i++) { - if (fnmatch(virLogFilters[i]->match, source->name, 0) =3D=3D 0= ) { + if (g_pattern_match_simple(virLogFilters[i]->match, source->na= me)) { priority =3D virLogFilters[i]->priority; break; } @@ -1338,7 +1337,7 @@ virLogFilterNew(const char *match, return NULL; } =20 - /* We must treat 'foo' as equiv to '*foo*' for fnmatch + /* We must treat 'foo' as equiv to '*foo*' for g_pattern_match * todo substring matches, so add 2 extra bytes */ if (VIR_ALLOC_N_QUIET(mdup, mlen + 3) < 0) diff --git a/tests/virconfdata/libvirtd.conf b/tests/virconfdata/libvirtd.c= onf index 602aa08d92..791d6c972b 100644 --- a/tests/virconfdata/libvirtd.conf +++ b/tests/virconfdata/libvirtd.conf @@ -183,7 +183,9 @@ tls_no_verify_certificate =3D 1 # # "C=3DGB,ST=3DLondon,L=3DLondon,O=3DRed Hat,CN=3D*" # -# See the POSIX fnmatch function for the format of the wildcards. +# See the g_pattern_match function for the format of the wildcards. +# +# https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-matching= .html # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks @@ -200,7 +202,9 @@ tls_allowed_dn_list =3D ["DN1", "DN2"] # # "*@EXAMPLE.COM" # -# See the POSIX fnmatch function for the format of the wildcards. +# See the g_pattern_match function for the format of the wildcards. +# +# https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-matching= .html # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks diff --git a/tests/virconfdata/libvirtd.out b/tests/virconfdata/libvirtd.out index d3f2bd20a7..cfdd23fd21 100644 --- a/tests/virconfdata/libvirtd.out +++ b/tests/virconfdata/libvirtd.out @@ -147,7 +147,9 @@ tls_no_verify_certificate =3D 1 # # "C=3DGB,ST=3DLondon,L=3DLondon,O=3DRed Hat,CN=3D*" # -# See the POSIX fnmatch function for the format of the wildcards. +# See the g_pattern_match function for the format of the wildcards. +# +# https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-matching= .html # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks @@ -162,7 +164,9 @@ tls_allowed_dn_list =3D [ "DN1", "DN2" ] # # "*@EXAMPLE.COM" # -# See the POSIX fnmatch function for the format of the wildcards. +# See the g_pattern_match function for the format of the wildcards. +# +# https://developer.gnome.org/glib/stable/glib-Glob-style-pattern-matching= .html # # NB If this is an empty list, no client can connect, so comment out # entirely rather than using empty list to disable these checks diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index 87735833d9..e3aefc2c06 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -19,7 +19,6 @@ */ #include =20 -#include #include #include #include @@ -67,14 +66,14 @@ static int virLoginShellAllowedUser(virConfPtr conf, for (i =3D 0; i < ngroups; i++) { if (!(gname =3D virGetGroupName(groups[i]))) continue; - if (fnmatch(entry, gname, 0) =3D=3D 0) { + if (g_pattern_match_simple(entry, gname)) { ret =3D 0; goto cleanup; } VIR_FREE(gname); } } else { - if (fnmatch(entry, name, 0) =3D=3D 0) { + if (g_pattern_match_simple(entry, name)) { ret =3D 0; goto cleanup; } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977013; cv=none; d=zohomail.com; s=zohoarc; b=UL+P0AisJfTPKfY45kPrDHxS+eZs6U4m+b59dVl6HUtg6BSl1Rgzspoh7V5MTdIXYZ3KfSRtjpJgbDwcbDPnTmBH3Zlc9oECkHLvZVGL+zY9bEKlSq/mbYTeFcfQbUax+GRw0JAmIRBD5xVZDRFZjybWHK9r5Ss0n/+R+4DNlNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977013; 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=h0xBMr9G0kxIg/HEEgsa93h3tRoOONlhR/oFOLzyzAc=; b=dQHiLEj0iFJp/wCF4k/sOmqmv7SUo9u0JDaWRC05CPaaUH7rjT68bMFdt3d7OEtZDHcFf3ubr2BOh/pXE1deZh27/sdJNnqaQr0sMu3oPDKD4JmJ2TT6Y5UalpG7XcpzwuchpCs+Chp3wh6QhVH/5fZMZWVO0+5a2MhlUBvBBlE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977013930175.74552031200744; Thu, 2 Jan 2020 06:56:53 -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-183-YUBHbhraO0CjiyM6tu1Rjg-1; Thu, 02 Jan 2020 09:56:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 376C818CA247; Thu, 2 Jan 2020 14:56:45 +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 0EFA07B9F8; Thu, 2 Jan 2020 14:56:45 +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 C36C581E3A; Thu, 2 Jan 2020 14:56:44 +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 002EubJr004817 for ; Thu, 2 Jan 2020 09:56:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2F96760C87; Thu, 2 Jan 2020 14:56:37 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9383B60BF4; Thu, 2 Jan 2020 14:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977012; 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=h0xBMr9G0kxIg/HEEgsa93h3tRoOONlhR/oFOLzyzAc=; b=i7GXiuKQhveZ211UBTGSvqBVmds02kki3y5Iu6AfAtDGMKQY3hTkzQK+gaPAVq+GJFv2zs 1tovCHuiqqWN7HesJdua1qsWrTMRnFqpI9J8sBL+AsMLH3gTQ0ATZ1Cq9xK9yXzdm8Q6Oj DrTEinp4aJY/IQp/HMXXKCus8R47ns0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:46 +0000 Message-Id: <20200102145357.6724-13-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/23] src: replace clock_gettime()/gettimeofday() with g_get_real_time() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: YUBHbhraO0CjiyM6tu1Rjg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) g_get_real_time() returns the time since epoch in microseconds. It uses gettimeofday() internally while libvirt used clock_gettime because it is declared async signal safe. In practice gettimeofday is also async signal safe *provided* the timezone parameter is NULL. This is indeed the case in g_get_real_time(). Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/conf/moment_conf.c | 7 ++---- src/libxl/libxl_driver.c | 21 +++++++++-------- src/qemu/qemu_backup.c | 5 ++-- src/test/test_driver.c | 51 ++++++++-------------------------------- src/util/virtime.c | 22 +---------------- tests/eventtest.c | 18 +++++--------- tools/virsh-domain.c | 10 ++++---- tools/vsh.c | 11 ++++----- tools/vsh.h | 1 - 9 files changed, 40 insertions(+), 106 deletions(-) diff --git a/src/conf/moment_conf.c b/src/conf/moment_conf.c index d02fcb89e2..fb6f7824cb 100644 --- a/src/conf/moment_conf.c +++ b/src/conf/moment_conf.c @@ -73,13 +73,10 @@ virDomainMomentDefDispose(void *obj) int virDomainMomentDefPostParse(virDomainMomentDefPtr def) { - struct timeval tv; - - gettimeofday(&tv, NULL); + def->creationTime =3D g_get_real_time() / (1000*1000); =20 if (!def->name) - def->name =3D g_strdup_printf("%lld", (long long)tv.tv_sec); + def->name =3D g_strdup_printf("%lld", def->creationTime); =20 - def->creationTime =3D tv.tv_sec; return 0; } diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index b2f191b2ac..f021ec9c5d 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -235,9 +235,9 @@ libxlTimeoutRegisterEventHook(void *priv, void *xl_priv) { libxlOSEventHookInfoPtr info; - struct timeval now; - struct timeval res; - static struct timeval zero; + gint64 now_us; + gint64 abs_us; + gint64 res_ms; int timeout; =20 if (VIR_ALLOC(info) < 0) @@ -246,15 +246,16 @@ libxlTimeoutRegisterEventHook(void *priv, info->ctx =3D priv; info->xl_priv =3D xl_priv; =20 - gettimeofday(&now, NULL); - timersub(&abs_t, &now, &res); - /* Ensure timeout is not overflowed */ - if (timercmp(&res, &zero, <)) { + now_us =3D g_get_real_time(); + abs_us =3D (abs_t.tv_sec * (1000LL*1000LL)) + abs_t.tv_usec; + if (now_us >=3D abs_us) { timeout =3D 0; - } else if (res.tv_sec > INT_MAX / 1000) { - timeout =3D INT_MAX; } else { - timeout =3D res.tv_sec * 1000 + (res.tv_usec + 999) / 1000; + res_ms =3D (abs_us - now_us) / 1000; + if (res_ms > INT_MAX) + timeout =3D INT_MAX; + else + timeout =3D res_ms; } info->id =3D virEventAddTimeout(timeout, libxlTimerCallback, info, libxlOSEventHookInfoFree); diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 294d5999a0..a039beaede 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -715,7 +715,6 @@ qemuBackupBegin(virDomainObjPtr vm, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(priv->dr= iver); g_autoptr(virDomainBackupDef) def =3D NULL; g_autofree char *suffix =3D NULL; - struct timeval tv; bool pull =3D false; virDomainMomentObjPtr chk =3D NULL; g_autoptr(virDomainCheckpointDef) chkdef =3D NULL; @@ -749,8 +748,8 @@ qemuBackupBegin(virDomainObjPtr vm, =20 suffix =3D g_strdup(chkdef->parent.name); } else { - gettimeofday(&tv, NULL); - suffix =3D g_strdup_printf("%lld", (long long)tv.tv_sec); + gint64 now_us =3D g_get_real_time(); + suffix =3D g_strdup_printf("%lld", (long long)now_us/(1000*1000)); } =20 if (def->type =3D=3D VIR_DOMAIN_BACKUP_TYPE_PULL) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2e4ecfd0ff..f8e08dcf07 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -2052,29 +2052,19 @@ testDomainGetHostname(virDomainPtr domain, static int testDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) { - struct timeval tv; virDomainObjPtr privdom; - int ret =3D -1; =20 if (!(privdom =3D testDomObjFromDomain(domain))) return -1; =20 - if (gettimeofday(&tv, NULL) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("getting time of day")); - goto cleanup; - } - info->state =3D virDomainObjGetState(privdom, NULL); info->memory =3D privdom->def->mem.cur_balloon; info->maxMem =3D virDomainDefGetMemoryTotal(privdom->def); info->nrVirtCpu =3D virDomainDefGetVcpus(privdom->def); - info->cpuTime =3D ((tv.tv_sec * 1000ll * 1000ll * 1000ll) + (tv.tv_us= ec * 1000ll)); - ret =3D 0; + info->cpuTime =3D g_get_real_time() * 1000; =20 - cleanup: virDomainObjEndAPI(&privdom); - return ret; + return 0; } =20 static int @@ -2933,7 +2923,6 @@ static int testDomainGetVcpus(virDomainPtr domain, size_t i; int hostcpus; int ret =3D -1; - struct timeval tv; unsigned long long statbase; virBitmapPtr allcpumap =3D NULL; =20 @@ -2948,13 +2937,7 @@ static int testDomainGetVcpus(virDomainPtr domain, =20 def =3D privdom->def; =20 - if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(errno, - "%s", _("getting time of day")); - goto cleanup; - } - - statbase =3D (tv.tv_sec * 1000UL * 1000UL) + tv.tv_usec; + statbase =3D g_get_real_time(); =20 hostcpus =3D VIR_NODEINFO_MAXCPUS(privconn->nodeInfo); if (!(allcpumap =3D virBitmapNew(hostcpus))) @@ -4963,7 +4946,6 @@ static int testDomainBlockStats(virDomainPtr domain, virDomainBlockStatsPtr stats) { virDomainObjPtr privdom; - struct timeval tv; unsigned long long statbase; int ret =3D -1; =20 @@ -4985,19 +4967,13 @@ static int testDomainBlockStats(virDomainPtr domain, goto error; } =20 - if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(errno, - "%s", _("getting time of day")); - goto error; - } - /* No significance to these numbers, just enough to mix it up*/ - statbase =3D (tv.tv_sec * 1000UL * 1000UL) + tv.tv_usec; + statbase =3D g_get_real_time(); stats->rd_req =3D statbase / 10; stats->rd_bytes =3D statbase / 20; stats->wr_req =3D statbase / 30; stats->wr_bytes =3D statbase / 40; - stats->errs =3D tv.tv_sec / 2; + stats->errs =3D statbase / (1000LL * 1000LL * 2); =20 ret =3D 0; error: @@ -5136,7 +5112,6 @@ testDomainInterfaceStats(virDomainPtr domain, virDomainInterfaceStatsPtr stats) { virDomainObjPtr privdom; - struct timeval tv; unsigned long long statbase; virDomainNetDefPtr net =3D NULL; int ret =3D -1; @@ -5151,22 +5126,16 @@ testDomainInterfaceStats(virDomainPtr domain, if (!(net =3D virDomainNetFind(privdom->def, device))) goto error; =20 - if (gettimeofday(&tv, NULL) < 0) { - virReportSystemError(errno, - "%s", _("getting time of day")); - goto error; - } - /* No significance to these numbers, just enough to mix it up*/ - statbase =3D (tv.tv_sec * 1000UL * 1000UL) + tv.tv_usec; + statbase =3D g_get_real_time(); stats->rx_bytes =3D statbase / 10; stats->rx_packets =3D statbase / 100; - stats->rx_errs =3D tv.tv_sec / 1; - stats->rx_drop =3D tv.tv_sec / 2; + stats->rx_errs =3D statbase / (1000LL * 1000LL * 1); + stats->rx_drop =3D statbase / (1000LL * 1000LL * 2); stats->tx_bytes =3D statbase / 20; stats->tx_packets =3D statbase / 110; - stats->tx_errs =3D tv.tv_sec / 3; - stats->tx_drop =3D tv.tv_sec / 4; + stats->tx_errs =3D statbase / (1000LL * 1000LL * 3); + stats->tx_drop =3D statbase / (1000LL * 1000LL * 4); =20 ret =3D 0; error: diff --git a/src/util/virtime.c b/src/util/virtime.c index 701b2f085a..54466b2f39 100644 --- a/src/util/virtime.c +++ b/src/util/virtime.c @@ -43,11 +43,6 @@ =20 VIR_LOG_INIT("util.time"); =20 -/* We prefer clock_gettime if available because that is officially - * async signal safe according to POSIX. Many platforms lack it - * though, so fallback to gettimeofday everywhere else - */ - /** * virTimeMillisNowRaw: * @now: filled with current time in milliseconds @@ -59,22 +54,7 @@ VIR_LOG_INIT("util.time"); */ int virTimeMillisNowRaw(unsigned long long *now) { -#ifdef HAVE_CLOCK_GETTIME - struct timespec ts; - - if (clock_gettime(CLOCK_REALTIME, &ts) < 0) - return -1; - - *now =3D (ts.tv_sec * 1000ull) + (ts.tv_nsec / (1000ull * 1000ull)); -#else - struct timeval tv; - - if (gettimeofday(&tv, NULL) < 0) - return -1; - - *now =3D (tv.tv_sec * 1000ull) + (tv.tv_usec / 1000ull); -#endif - + *now =3D g_get_real_time() / 1000; return 0; } =20 diff --git a/tests/eventtest.c b/tests/eventtest.c index fdd732f7fa..a16922874a 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -262,20 +262,14 @@ startJob(void) static int finishJob(const char *name, int handle, int timer) { + unsigned long long now_us; struct timespec waitTime; int rc; -#if HAVE_MACH_CLOCK_ROUTINES - clock_serv_t cclock; - mach_timespec_t mts; - - host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); - clock_get_time(cclock, &mts); - mach_port_deallocate(mach_task_self(), cclock); - waitTime.tv_sec =3D mts.tv_sec; - waitTime.tv_nsec =3D mts.tv_nsec; -#else - clock_gettime(CLOCK_REALTIME, &waitTime); -#endif + + now_us =3D g_get_real_time(); + waitTime.tv_sec =3D now_us / (1000*1000); + waitTime.tv_nsec =3D (now_us % ((now_us / (1000*1000)))) * 1000; + waitTime.tv_sec +=3D 5; rc =3D 0; while (!eventThreadJobDone && rc =3D=3D 0) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 9d4cdd26dd..9315755990 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4289,7 +4289,7 @@ virshWatchJob(vshControl *ctl, struct sigaction old_sig_action; struct pollfd pollfd[2] =3D {{.fd =3D pipe_fd, .events =3D POLLIN, .re= vents =3D 0}, {.fd =3D STDIN_FILENO, .events =3D POLLIN, = .revents =3D 0}}; - struct timeval start, curr; + unsigned long long start_us, curr_us; virDomainJobInfo jobinfo; int ret =3D -1; char retchar; @@ -4311,7 +4311,7 @@ virshWatchJob(vshControl *ctl, if (!vshTTYAvailable(ctl)) npollfd =3D 1; =20 - GETTIMEOFDAY(&start); + start_us =3D g_get_real_time(); while (1) { ret =3D poll((struct pollfd *)&pollfd, npollfd, 500); if (ret > 0) { @@ -4345,10 +4345,8 @@ virshWatchJob(vshControl *ctl, goto cleanup; } =20 - GETTIMEOFDAY(&curr); - if (timeout_ms && (((int)(curr.tv_sec - start.tv_sec) * 1000 + - (int)(curr.tv_usec - start.tv_usec) / 1000) > - timeout_ms)) { + curr_us =3D g_get_real_time(); + if (timeout_ms && ((curr_us - start_us)/1000) > timeout_ms) { /* suspend the domain when migration timeouts. */ vshDebug(ctl, VSH_ERR_DEBUG, "%s timeout", label); if (timeout_func) diff --git a/tools/vsh.c b/tools/vsh.c index b982aeb359..a2f33e01aa 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1286,11 +1286,10 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; =20 while (cmd) { - struct timeval before, after; + gint64 before, after; bool enable_timing =3D ctl->timing; =20 - if (enable_timing) - GETTIMEOFDAY(&before); + before =3D g_get_real_time(); =20 if ((cmd->def->flags & VSH_CMD_FLAG_NOCONNECT) || (hooks && hooks->connHandler && hooks->connHandler(ctl))) { @@ -1300,8 +1299,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd) ret =3D false; } =20 - if (enable_timing) - GETTIMEOFDAY(&after); + after =3D g_get_real_time(); =20 /* try to automatically catch disconnections */ if (!ret && @@ -1321,8 +1319,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd) return ret; =20 if (enable_timing) { - double diff_ms =3D (((after.tv_sec - before.tv_sec) * 1000.0) + - ((after.tv_usec - before.tv_usec) / 1000.0)); + double diff_ms =3D (after - before) / 1000.0; =20 vshPrint(ctl, _("\n(Time: %.3f ms)\n\n"), diff_ms); } else { diff --git a/tools/vsh.h b/tools/vsh.h index b6ac070f10..960cae8df0 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -31,7 +31,6 @@ =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 -#define GETTIMEOFDAY(T) gettimeofday(T, NULL) #define VSH_MAX_XML_FILE (10*1024*1024) #define VSH_MATCH(FLAG) (flags & (FLAG)) =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977023; cv=none; d=zohomail.com; s=zohoarc; b=PTyIC4mFXN/8FDJI4V/IwmqN5AoGmS4/LcLz7n4QuUJLbrNW2b6M1O/tkkxSdr8Nk3P6gYh+Y/IJw9ZJvGvJ54kQ1D2QkIcfJZ/1yc5PZR5E6eiC1ZT7SkI0cnfcpIRCENPvhQK75Ky9jldmAcmmALNAaw4598Ox7VJTR5p2aiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977023; 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=3IRaMUzoGryKeB6qXD3n4fdNalzXxd5BJU2E97NvaTc=; b=nfNBW8zC4qKZfJ10X3kZMnd8XVAckf7BjCvjRgKhqWA9GKWyFOMLnacM7UGzFqoLib9ElyeAoMM/w3fx1KHCLrkGHoT73UErXssw955xc62viEfBmepiQ174BzpNcI8l1/v7zYYYzAiOQwPfBmIjDURmJpL2oI0VLnm1Id/0cts= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977023389968.1585024758709; Thu, 2 Jan 2020 06:57:03 -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-308-JPRZHEQiP16N0SjioFALig-1; Thu, 02 Jan 2020 09:56:59 -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 72D0118CA248; Thu, 2 Jan 2020 14:56:53 +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 4BF7028993; Thu, 2 Jan 2020 14:56:53 +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 0907181E3A; Thu, 2 Jan 2020 14:56:53 +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 002EucvA004827 for ; Thu, 2 Jan 2020 09:56:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1158160C87; Thu, 2 Jan 2020 14:56:38 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75FF060BF4; Thu, 2 Jan 2020 14:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977022; 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=3IRaMUzoGryKeB6qXD3n4fdNalzXxd5BJU2E97NvaTc=; b=bny4uxtOI7+AHWQGYSxwf8nH4U/oryHnqaDQ4SX7YG+f8HbRoFOUQy3omuVH23LwCXIz+r BTuexl3otWU/rQWc4dJRiJhC87a2CKyC8qkRLWr1NCI79VsZxOkOsnpe7cnVAMmX94xc+o Jfnpxn+h5p1h/E0JcfklkVTD4p3e5h0= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:47 +0000 Message-Id: <20200102145357.6724-14-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/23] src: replace last_component() with g_path_get_basename() 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: JPRZHEQiP16N0SjioFALig-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The last_component() method is a GNULIB custom function that returns a pointer to the base name in the path. This is similar to g_path_get_basename() but without the malloc. The extra malloc is no trouble for libvirt's needs so we can use g_path_get_basename(). Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/conf/node_device_conf.c | 2 +- src/node_device/node_device_udev.c | 12 ++++++------ src/rpc/virnetsocket.c | 5 ++--- src/storage/storage_backend_disk.c | 9 ++++----- src/storage/storage_util.c | 3 +-- src/util/virmdev.c | 12 +++++++----- src/util/virnetdev.c | 5 ++--- src/util/virpci.c | 17 ++++++++--------- tests/testutils.c | 7 +++---- tests/testutils.h | 2 -- tests/virpcimock.c | 3 +-- 11 files changed, 35 insertions(+), 42 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index a02c8fe306..9b206abadc 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2448,7 +2448,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath, if (!(dir =3D mdir_name(sysfsPath))) return -1; =20 - rport =3D g_strdup(last_component(dir)); + rport =3D g_path_get_basename(dir); =20 if (!virFCIsCapableRport(rport)) goto cleanup; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index eedcd123a3..4b33dc25d8 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -23,7 +23,6 @@ #include #include =20 -#include "dirname.h" #include "node_device_conf.h" #include "node_device_event.h" #include "node_device_driver.h" @@ -602,10 +601,10 @@ udevProcessSCSIHost(struct udev_device *device G_GNUC= _UNUSED, virNodeDeviceDefPtr def) { virNodeDevCapSCSIHostPtr scsi_host =3D &def->caps->data.scsi_host; - char *filename =3D NULL; + g_autofree char *filename =3D NULL; char *str; =20 - filename =3D last_component(def->sysfs_path); + filename =3D g_path_get_basename(def->sysfs_path); =20 if (!(str =3D STRSKIP(filename, "host")) || virStrToLong_ui(str, NULL, 0, &scsi_host->host) < 0) { @@ -711,9 +710,10 @@ udevProcessSCSIDevice(struct udev_device *device G_GNU= C_UNUSED, int ret =3D -1; unsigned int tmp =3D 0; virNodeDevCapSCSIPtr scsi =3D &def->caps->data.scsi; - char *filename =3D NULL, *p =3D NULL; + g_autofree char *filename =3D NULL; + char *p =3D NULL; =20 - filename =3D last_component(def->sysfs_path); + filename =3D g_path_get_basename(def->sysfs_path); =20 if (virStrToLong_ui(filename, &p, 10, &scsi->host) < 0 || p =3D=3D NUL= L || virStrToLong_ui(p + 1, &p, 10, &scsi->bus) < 0 || p =3D=3D NULL || @@ -1038,7 +1038,7 @@ udevProcessMediatedDevice(struct udev_device *dev, goto cleanup; } =20 - data->type =3D g_strdup(last_component(canonicalpath)); + data->type =3D g_path_get_basename(canonicalpath); =20 uuidstr =3D udev_device_get_sysname(dev); if ((iommugrp =3D virMediatedDeviceGetIOMMUGroupNum(uuidstr)) < 0) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index f072afe857..16a527e399 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -55,7 +55,6 @@ #include "virprobe.h" #include "virprocess.h" #include "virstring.h" -#include "dirname.h" #include "passfd.h" =20 #if WITH_SSH2 @@ -668,7 +667,7 @@ int virNetSocketNewConnectUNIX(const char *path, remoteAddr.len =3D sizeof(remoteAddr.data.un); =20 if (spawnDaemon) { - const char *binname; + g_autofree char *binname =3D NULL; =20 if (spawnDaemon && !binary) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -677,7 +676,7 @@ int virNetSocketNewConnectUNIX(const char *path, goto cleanup; } =20 - if (!(binname =3D last_component(binary)) || binname[0] =3D=3D '\0= ') { + if (!(binname =3D g_path_get_basename(binary)) || binname[0] =3D= =3D '\0') { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot determine basename for binary '%s'"), binary); diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index 45d1257f3d..00e8b1aa13 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -22,7 +22,6 @@ #include #include =20 -#include "dirname.h" #include "virerror.h" #include "virlog.h" #include "storage_backend_disk.h" @@ -777,10 +776,10 @@ virStorageBackendDiskDeleteVol(virStoragePoolObjPtr p= ool, unsigned int flags) { char *part_num =3D NULL; - char *dev_name; + g_autofree char *dev_name =3D NULL; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); char *src_path =3D def->source.devices[0].path; - char *srcname =3D last_component(src_path); + g_autofree char *srcname =3D g_path_get_basename(src_path); bool isDevMapperDevice; g_autofree char *devpath =3D NULL; g_autoptr(virCommand) cmd =3D NULL; @@ -800,7 +799,7 @@ virStorageBackendDiskDeleteVol(virStoragePoolObjPtr poo= l, * in both places */ isDevMapperDevice =3D virIsDevMapperDevice(vol->target.path); if (isDevMapperDevice) { - dev_name =3D last_component(vol->target.path); + dev_name =3D g_path_get_basename(vol->target.path); } else { if (virFileResolveLink(vol->target.path, &devpath) < 0) { virReportSystemError(errno, @@ -808,7 +807,7 @@ virStorageBackendDiskDeleteVol(virStoragePoolObjPtr poo= l, vol->target.path); return -1; } - dev_name =3D last_component(devpath); + dev_name =3D g_path_get_basename(devpath); } =20 VIR_DEBUG("dev_name=3D%s, srcname=3D%s", dev_name, srcname); diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 58225c09f5..ebc262278d 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -26,7 +26,6 @@ #include #include #include -#include "dirname.h" #ifdef __linux__ # include # include @@ -1519,7 +1518,7 @@ virStorageBackendVolOpen(const char *path, struct sta= t *sb, unsigned int flags) { int fd, mode =3D 0; - char *base =3D last_component(path); + g_autofree char *base =3D g_path_get_basename(path); bool noerror =3D (flags & VIR_STORAGE_VOL_OPEN_NOERROR); =20 if (g_lstat(path, sb) < 0) { diff --git a/src/util/virmdev.c b/src/util/virmdev.c index cd52a91ffd..c2499c0a20 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -18,7 +18,6 @@ =20 #include =20 -#include "dirname.h" #include "virmdev.h" #include "virlog.h" #include "virerror.h" @@ -207,6 +206,7 @@ char * virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr) { g_autofree char *result_path =3D NULL; + g_autofree char *result_file =3D NULL; g_autofree char *iommu_path =3D NULL; g_autofree char *dev_path =3D virMediatedDeviceGetSysfsPath(uuidstr); char *vfio_path =3D NULL; @@ -226,7 +226,9 @@ virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr) return NULL; } =20 - vfio_path =3D g_strdup_printf("/dev/vfio/%s", last_component(result_pa= th)); + result_file =3D g_path_get_basename(result_path); + + vfio_path =3D g_strdup_printf("/dev/vfio/%s", result_file); =20 return vfio_path; } @@ -236,13 +238,13 @@ int virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr) { g_autofree char *vfio_path =3D NULL; - char *group_num_str =3D NULL; + g_autofree char *group_num_str =3D NULL; unsigned int group_num =3D -1; =20 if (!(vfio_path =3D virMediatedDeviceGetIOMMUGroupDev(uuidstr))) return -1; =20 - group_num_str =3D last_component(vfio_path); + group_num_str =3D g_path_get_basename(vfio_path); ignore_value(virStrToLong_ui(group_num_str, NULL, 10, &group_num)); =20 return group_num; @@ -501,7 +503,7 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, if (VIR_ALLOC(tmp) < 0) return -1; =20 - tmp->id =3D g_strdup(last_component(sysfspath)); + tmp->id =3D g_path_get_basename(sysfspath); =20 /* @name sysfs attribute is optional, so getting ENOENT is fine */ MDEV_GET_SYSFS_ATTR("name", &tmp->name, virFileReadValueString, true); diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 43d2fb06cf..03e276a972 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -18,7 +18,6 @@ =20 #include =20 -#include "dirname.h" #include "virnetdev.h" #include "viralloc.h" #include "virnetlink.h" @@ -1096,7 +1095,7 @@ virNetDevIsPCIDevice(const char *devpath) { char *subsys_link =3D NULL; char *abs_path =3D NULL; - char *subsys =3D NULL; + g_autofree char *subsys =3D NULL; bool ret =3D false; =20 subsys_link =3D g_strdup_printf("%s/subsystem", devpath); @@ -1111,7 +1110,7 @@ virNetDevIsPCIDevice(const char *devpath) goto cleanup; } =20 - subsys =3D last_component(abs_path); + subsys =3D g_path_get_basename(abs_path); ret =3D STRPREFIX(subsys, "pci"); =20 cleanup: diff --git a/src/util/virpci.c b/src/util/virpci.c index 99a8002743..06d855a95b 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -30,7 +30,6 @@ #include #include =20 -#include "dirname.h" #include "virlog.h" #include "vircommand.h" #include "virerror.h" @@ -265,7 +264,7 @@ virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, c= har **path, char **name) } /* path =3D "/sys/bus/pci/drivers/${drivername}" */ =20 - *name =3D g_strdup(last_component(*path)); + *name =3D g_path_get_basename(*path); /* name =3D "${drivername}" */ =20 ret =3D 0; @@ -1926,7 +1925,7 @@ virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddre= ssPtr addr) g_autofree char *devName =3D NULL; g_autofree char *devPath =3D NULL; g_autofree char *groupPath =3D NULL; - const char *groupNumStr; + g_autofree char *groupNumStr =3D NULL; unsigned int groupNum; =20 devName =3D g_strdup_printf(VIR_PCI_DEVICE_ADDRESS_FMT, addr->domain, = addr->bus, @@ -1943,7 +1942,7 @@ virPCIDeviceAddressGetIOMMUGroupNum(virPCIDeviceAddre= ssPtr addr) return -1; } =20 - groupNumStr =3D last_component(groupPath); + groupNumStr =3D g_path_get_basename(groupPath); if (virStrToLong_ui(groupNumStr, NULL, 10, &groupNum) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("device %s iommu_group symlink %s has " @@ -1979,7 +1978,7 @@ virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev) { g_autofree char *devPath =3D NULL; g_autofree char *groupPath =3D NULL; - char *groupDev =3D NULL; + g_autofree char *groupFile =3D NULL; =20 if (!(devPath =3D virPCIFile(dev->name, "iommu_group"))) return NULL; @@ -1995,9 +1994,9 @@ virPCIDeviceGetIOMMUGroupDev(virPCIDevicePtr dev) dev->name, devPath); return NULL; } - groupDev =3D g_strdup_printf("/dev/vfio/%s", last_component(groupPath)= ); + groupFile =3D g_path_get_basename(groupPath); =20 - return groupDev; + return g_strdup_printf("/dev/vfio/%s", groupFile); } =20 static int @@ -2207,7 +2206,7 @@ virPCIDeviceAddressPtr virPCIGetDeviceAddressFromSysfsLink(const char *device_link) { virPCIDeviceAddressPtr bdf =3D NULL; - char *config_address =3D NULL; + g_autofree char *config_address =3D NULL; g_autofree char *device_path =3D NULL; =20 if (!virFileExists(device_link)) { @@ -2223,7 +2222,7 @@ virPCIGetDeviceAddressFromSysfsLink(const char *devic= e_link) return NULL; } =20 - config_address =3D last_component(device_path); + config_address =3D g_path_get_basename(device_path); if (VIR_ALLOC(bdf) < 0) return NULL; =20 diff --git a/tests/testutils.c b/tests/testutils.c index 5bc108a6c3..7c4e5b4b2e 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -37,7 +37,6 @@ #include "virlog.h" #include "vircommand.h" #include "virrandom.h" -#include "dirname.h" #include "virprocess.h" #include "virstring.h" =20 @@ -57,8 +56,6 @@ static unsigned int testRegenerate =3D -1; static size_t testCounter; static virBitmapPtr testBitmap; =20 -char *progname; - virArch virTestHostArch =3D VIR_ARCH_X86_64; =20 virArch @@ -857,6 +854,8 @@ int virTestMain(int argc, size_t noutputs =3D 0; virLogOutputPtr output =3D NULL; virLogOutputPtr *outputs =3D NULL; + g_autofree char *baseprogname =3D NULL; + const char *progname; =20 if (getenv("VIR_TEST_FILE_ACCESS")) VIR_TEST_PRELOAD(VIR_TEST_MOCK("virtest")); @@ -866,7 +865,7 @@ int virTestMain(int argc, VIR_TEST_PRELOAD(lib); va_end(ap); =20 - progname =3D last_component(argv[0]); + progname =3D baseprogname =3D g_path_get_basename(argv[0]); if (STRPREFIX(progname, "lt-")) progname +=3D 3; =20 diff --git a/tests/testutils.h b/tests/testutils.h index 74785b7fb8..fbd0856d4b 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -36,8 +36,6 @@ # define fprintf virFilePrintf #endif =20 -extern char *progname; - /* Makefile.am provides these two definitions */ #if !defined(abs_srcdir) || !defined(abs_builddir) # error Fix Makefile.am diff --git a/tests/virpcimock.c b/tests/virpcimock.c index 6048118d5c..92b6f810d8 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -28,7 +28,6 @@ # include "viralloc.h" # include "virstring.h" # include "virfile.h" -# include "dirname.h" =20 static int (*real_access)(const char *path, int mode); static int (*real_open)(const char *path, int flags, ...); @@ -884,7 +883,7 @@ static int pci_driver_handle_change(int fd G_GNUC_UNUSED, const char *path) { int ret; - const char *file =3D last_component(path); + g_autofree char *file =3D g_path_get_basename(path); =20 if (STREQ(file, "bind")) ret =3D pci_driver_handle_bind(path); --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977160; cv=none; d=zohomail.com; s=zohoarc; b=J0VEHtbqNBjHpa9xhAkQJLTHiJ18qiHzaa6W8dHPlT/F2NvCGUGou4kj9Vhry2Q8qaWBNYDtXP7eaDSsaEoxGKBA20OckwJ7o/jQCL55+/R8JugOPnO00oglCqL33v4oWl782z4nsl2x1rlHOp41zwj/cqF0D5CBSnZQd3Mw5uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977160; 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=VDXmmMeSKBXHmq9tm8yawJdu8yFgV+3jViq5VRQ522Y=; b=M17+hIs9cE6/t8Z84HHb0p44tVdSB2g0M5dsHB+txw1ViIK6dktuRDXiogvlLLxc9dJvPs3fAVo6vgsy4CR2NZMZYWEQxX6hiqilddhiSbnD9+Ef0dbklkRJOAbivuFTuM8Xt2DGQW39tTy0BmM1WbNoiuQStBLaEe6hgimYN6U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1577977160693529.6816447248648; Thu, 2 Jan 2020 06:59:20 -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-387-vdGkj9oHPvGJPZgw-9N6Hw-1; Thu, 02 Jan 2020 09:56:56 -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 0B45018CA240; Thu, 2 Jan 2020 14:56:50 +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 D72F860FFB; Thu, 2 Jan 2020 14:56:49 +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 97ADF1804744; Thu, 2 Jan 2020 14:56:49 +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 002EulGp004860 for ; Thu, 2 Jan 2020 09:56:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id BA9DD6106F; Thu, 2 Jan 2020 14:56:47 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BBA260FC1; Thu, 2 Jan 2020 14:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977159; 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=VDXmmMeSKBXHmq9tm8yawJdu8yFgV+3jViq5VRQ522Y=; b=itYE2V+tCeUkeqLRZ6Wj4NZ6XJPmmpcXFIC91QTqiQb5hEWoeyQvdDd781u2h7EVFEOdEl r9LJB45gLoWqSSvD+NIFgVIKEhVS4mIdjO0GwfHyDRDlm830+1WQlfNjqIVdKwBHhcVauj XQX1/LC0f9WwYarG2+R1ApmcQAIAfjM= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:48 +0000 Message-Id: <20200102145357.6724-15-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/23] util: replace IS_ABSOLUTE_FILE_NAME with g_path_is_absolute 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: vdGkj9oHPvGJPZgw-9N6Hw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/qemu/qemu_domain.c | 6 ++---- src/util/virfile.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 187aaf5737..f545d0b888 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -77,8 +77,6 @@ # include #endif =20 -#include "dosname.h" - #define QEMU_QXL_VGAMEM_DEFAULT 16 * 1024 =20 #define VIR_FROM_THIS VIR_FROM_QEMU @@ -14340,7 +14338,7 @@ qemuDomainCreateDeviceRecursive(const char *device, * (want /dev/disk/by-id/../../sda) * /dev/stdout -> /proc/self/fd/1 (no change needed) */ - if (IS_RELATIVE_FILE_NAME(target)) { + if (!g_path_is_absolute(target)) { char *c =3D NULL, *tmp =3D NULL, *devTmp =3D NULL; =20 devTmp =3D g_strdup(device); @@ -15312,7 +15310,7 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverP= tr driver, return ret; } =20 - if (IS_RELATIVE_FILE_NAME(target)) { + if (!g_path_is_absolute(target)) { char *c =3D NULL, *tmp =3D NULL, *fileTmp =3D NULL; =20 fileTmp =3D g_strdup(file); diff --git a/src/util/virfile.c b/src/util/virfile.c index 97f86a46e9..1ce909b033 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1562,7 +1562,7 @@ virFileResolveLinkHelper(const char *linkpath, /* We don't need the full canonicalization of intermediate * directories, if linkpath is absolute and the basename is * already a non-symlink. */ - if (IS_ABSOLUTE_FILE_NAME(linkpath) && !intermediatePaths) { + if (g_path_is_absolute(linkpath) && !intermediatePaths) { if (g_lstat(linkpath, &st) < 0) return -1; =20 @@ -1640,7 +1640,7 @@ virFindFileInPath(const char *file) /* if we are passed an absolute path (starting with /), return a * copy of that path, after validating that it is executable */ - if (IS_ABSOLUTE_FILE_NAME(file)) { + if (g_path_is_absolute(file)) { if (!virFileIsExecutable(file)) return NULL; =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977028; cv=none; d=zohomail.com; s=zohoarc; b=hLvTe2V8E4ADkd9eKwF3YafG2EmJOGRbjCaYPu4Dkgyr/iCC1iMUCdACXpQqQ1QAl488C7EkGMQcimgsVrhZxuy6p20/RzqEoC7mpCMRZRqzJyQEOdCnKScHs6qx7XdEA+QbIIpMGPpW2b9/pqXFl2vIWgEeUri4ZECaXftseYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977028; 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=uEHpR2EjELXXg7ebgGHjg1e18WHZLUG0BU2quL2DQGI=; b=RGgaF2M9dm2TRrJIwzPpvNC4X/pNWDZWCpOfg94RVoQSaLDVC+GLY5wlc11LU57EZ8SF+mb9YPmOeQz6OA/OgywrkOPQtvSmRYBPww2QOYsp5Q1v4laDH2WRHxkmS/eubcStxWaCS3jdFZ81lg3oJUMroE/Guq1tVLCFdeTZ4IU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977028132653.117983812184; Thu, 2 Jan 2020 06:57:08 -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-84-rEDLbsQMNF6wgnxIyd60_Q-1; Thu, 02 Jan 2020 09:57:00 -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 6FBCA911EF; Thu, 2 Jan 2020 14:56:53 +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 45E7B95307; Thu, 2 Jan 2020 14:56:53 +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 050AA81E36; Thu, 2 Jan 2020 14:56:53 +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 002EuqUh004885 for ; Thu, 2 Jan 2020 09:56:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 61399952FE; Thu, 2 Jan 2020 14:56:52 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21B4660FFB; Thu, 2 Jan 2020 14:56:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977022; 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=uEHpR2EjELXXg7ebgGHjg1e18WHZLUG0BU2quL2DQGI=; b=Re7V1H+i8jsuHSODT4rzopzfEnoNnDawA31i8rxVeXfbGY9bKsFqn2R4/qaNYaHUbdb/HT lvlM+f8Zw8Si/ezPsj6H7ys9hB2UYy0WcxNFi28cX+9xZm9ijxRqyZhwP0VKYy4KBjAw87 HRZo9xsm/OC1itRCash3fU/7bFyCWQw= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:49 +0000 Message-Id: <20200102145357.6724-16-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/23] src: replace mdir_name() with g_path_get_dirname() 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: rEDLbsQMNF6wgnxIyd60_Q-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/conf/node_device_conf.c | 4 +--- src/locking/lock_driver_sanlock.c | 6 +----- src/qemu/qemu_driver.c | 7 ++----- src/qemu/qemu_tpm.c | 33 +++---------------------------- src/security/virt-aa-helper.c | 4 +--- src/util/virfile.c | 6 +----- src/util/virstoragefile.c | 13 ++---------- src/vmware/vmware_conf.c | 7 ++----- 8 files changed, 13 insertions(+), 67 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 9b206abadc..4cf5b6e3d7 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -30,7 +30,6 @@ #include "virstring.h" #include "node_device_conf.h" #include "device_conf.h" -#include "dirname.h" #include "virxml.h" #include "virbuffer.h" #include "viruuid.h" @@ -2445,8 +2444,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath, VIR_DEBUG("Checking if '%s' is an FC remote port", scsi_target->name); =20 /* /sys/devices/[...]/host0/rport-0:0-0/target0:0:0 -> rport-0:0-0 */ - if (!(dir =3D mdir_name(sysfsPath))) - return -1; + dir =3D g_path_get_dirname(sysfsPath); =20 rport =3D g_path_get_basename(dir); =20 diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index c8936c301c..088255a111 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -31,7 +31,6 @@ #include #include =20 -#include "dirname.h" #include "lock_driver.h" #include "virlog.h" #include "virerror.h" @@ -239,10 +238,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanl= ockDriverPtr driver) int perms =3D 0600; VIR_DEBUG("Lockspace %s does not yet exist", path); =20 - if (!(dir =3D mdir_name(path))) { - virReportOOMError(); - goto error; - } + dir =3D g_path_get_dirname(path); if (stat(dir, &st) < 0 || !S_ISDIR(st.st_mode)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to create lockspace %s: parent direct= ory" diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ec8faf384c..9dffeefce7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -99,7 +99,6 @@ #include "vircgroup.h" #include "virperf.h" #include "virnuma.h" -#include "dirname.h" #include "netdev_bandwidth_conf.h" #include "virqemu.h" #include "virdomainsnapshotobjlist.h" @@ -850,10 +849,8 @@ qemuStateInitialize(bool privileged, (int)cfg->group); goto error; } - if (!(channeldir =3D mdir_name(cfg->channelTargetDir))) { - virReportOOMError(); - goto error; - } + channeldir =3D g_path_get_dirname(cfg->channelTargetDir); + if (chown(channeldir, cfg->user, cfg->group) < 0) { virReportSystemError(errno, _("unable to set ownership of '%s' to %d:= %d"), diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 91ab5bca9e..28800a100c 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -40,7 +40,6 @@ #include "virstring.h" #include "virpidfile.h" #include "configmake.h" -#include "dirname.h" #include "qemu_tpm.h" #include "virtpm.h" #include "secret_util.h" @@ -83,26 +82,6 @@ qemuTPMCreateEmulatorStoragePath(const char *swtpmStorag= eDir, } =20 =20 -/* - * virtTPMGetTPMStorageDir: - * - * @storagepath: directory for swtpm's persistent state - * - * Derive the 'TPMStorageDir' from the storagepath by searching - * for the last '/'. - */ -static char * -qemuTPMGetTPMStorageDir(const char *storagepath) -{ - char *ret =3D mdir_name(storagepath); - - if (!ret) - virReportOOMError(); - - return ret; -} - - /* * qemuTPMEmulatorInitStorage * @@ -147,10 +126,7 @@ qemuTPMCreateEmulatorStorage(const char *storagepath, gid_t swtpm_group) { int ret =3D -1; - char *swtpmStorageDir =3D qemuTPMGetTPMStorageDir(storagepath); - - if (!swtpmStorageDir) - return -1; + char *swtpmStorageDir =3D g_path_get_dirname(storagepath); =20 if (qemuTPMEmulatorInitStorage(swtpmStorageDir) < 0) goto cleanup; @@ -183,12 +159,9 @@ qemuTPMCreateEmulatorStorage(const char *storagepath, static void qemuTPMDeleteEmulatorStorage(virDomainTPMDefPtr tpm) { - char *path =3D qemuTPMGetTPMStorageDir(tpm->data.emulator.storagepath); + g_autofree char *path =3D g_path_get_dirname(tpm->data.emulator.stora= gepath); =20 - if (path) { - ignore_value(virFileDeleteTree(path)); - VIR_FREE(path); - } + ignore_value(virFileDeleteTree(path)); } =20 =20 diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index feb03b0aa9..9c34ac92c2 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -33,7 +33,6 @@ #include "viralloc.h" #include "vircommand.h" #include "virlog.h" -#include "dirname.h" #include "driver.h" =20 #include "security_driver.h" @@ -754,8 +753,7 @@ vah_add_path(virBufferPtr buf, const char *path, const = char *perms, bool recursi */ pathdir =3D g_strdup(path); while (!virFileExists(pathdir)) { - if ((pathtmp =3D mdir_name(pathdir)) =3D=3D NULL) - goto cleanup; + pathtmp =3D g_path_get_dirname(pathdir); VIR_FREE(pathdir); pathdir =3D g_steal_pointer(&pathtmp); } diff --git a/src/util/virfile.c b/src/util/virfile.c index 1ce909b033..d5e4d0a289 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -37,7 +37,6 @@ #endif #include #include -#include #if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R # include #endif @@ -1886,10 +1885,7 @@ int virFileIsMountPoint(const char *file) int ret; struct stat sb1, sb2; =20 - if (!(parent =3D mdir_name(file))) { - virReportOOMError(); - return -1; - } + parent =3D g_path_get_dirname(file); =20 VIR_DEBUG("Comparing '%s' to '%s'", file, parent); =20 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e280a646b7..c9f3e5f865 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -36,7 +36,6 @@ #include "virstring.h" #include "virutil.h" #include "viruri.h" -#include "dirname.h" #include "virbuffer.h" #include "virjson.h" #include "virstorageencryption.h" @@ -1690,15 +1689,10 @@ virStorageFileChainLookup(virStorageSourcePtr chain, =20 if (nameIsFile && virStorageSourceIsLocalStorage(chain)) { if (*parent && virStorageSourceIsLocalStorage(*parent)) - parentDir =3D mdir_name((*parent)->path); + parentDir =3D g_path_get_dirname((*parent)->path); else parentDir =3D g_strdup("."); =20 - if (!parentDir) { - virReportOOMError(); - goto error; - } - int result =3D virFileRelLinkPointsTo(parentDir, name, chain->path); =20 @@ -2658,10 +2652,7 @@ virStorageSourceNewFromBackingRelative(virStorageSou= rcePtr parent, /* store relative name */ def->relPath =3D g_strdup(rel); =20 - if (!(dirname =3D mdir_name(parent->path))) { - virReportOOMError(); - return NULL; - } + dirname =3D g_path_get_dirname(parent->path); =20 if (STRNEQ(dirname, "/")) { def->path =3D g_strdup_printf("%s/%s", dirname, rel); diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 290e0e898d..0256f1832f 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -24,7 +24,6 @@ =20 #include "vircommand.h" #include "cpu/cpu.h" -#include "dirname.h" #include "viralloc.h" #include "virfile.h" #include "viruuid.h" @@ -270,8 +269,7 @@ vmwareExtractVersion(struct vmware_driver *driver) char *bin =3D NULL; char *vmwarePath =3D NULL; =20 - if ((vmwarePath =3D mdir_name(driver->vmrun)) =3D=3D NULL) - goto cleanup; + vmwarePath =3D g_path_get_dirname(driver->vmrun); =20 switch (driver->type) { case VMWARE_DRIVER_PLAYER: @@ -477,8 +475,7 @@ vmwareExtractPid(const char * vmxPath) char *tmp =3D NULL; int pid_value =3D -1; =20 - if ((vmxDir =3D mdir_name(vmxPath)) =3D=3D NULL) - goto cleanup; + vmxDir =3D g_path_get_dirname(vmxPath); =20 logFilePath =3D g_strdup_printf("%s/vmware.log", vmxDir); =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977085; cv=none; d=zohomail.com; s=zohoarc; b=lIWWkJG6Dst2FHaKdXUzSrYgtcAkKnFymMV/2drhVA1O060WQsXw1RzGf69d9J16RDNBaD1Yif3rL2NCfmzMdEiNXjr1hVMnHPfKBJsi3DVXm1kE6iICYGiqrfFY8B2BNSWCo22ZdtuECdmPa8g+XHOLdRDmWZJU34qEa/O8z94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977085; 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=dd6P11DW+JGOdCM//mppw87VjVVw4HBFjUj+vZQbyQA=; b=VIO+Me36JPFYzZ6LH7G0IMYq+q6XORiTQtSEjTkRiZEnPrfjv6XhTp/vZZzFaU7JShEBhWx2Ig0yQn4ebxrJmokxnuuHhxIYDnsOlvmE8zV61vG4rD2NOcUK6bcZEyzYnpz3bWexT+wy3iPMrad/6GQazz8TPYRAd274tFvPw9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1577977085989529.5702056261108; Thu, 2 Jan 2020 06:58: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-63-75SHAxOpPiuwDIYysgyVtQ-1; Thu, 02 Jan 2020 09:57:08 -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 C34FD8024CF; Thu, 2 Jan 2020 14:57:00 +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 9E11B2899B; Thu, 2 Jan 2020 14:57:00 +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 637D81803C42; Thu, 2 Jan 2020 14:57:00 +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 002EuxY0004920 for ; Thu, 2 Jan 2020 09:56:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 49163610D9; Thu, 2 Jan 2020 14:56:59 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id C18B2610C9; Thu, 2 Jan 2020 14:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977084; 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=dd6P11DW+JGOdCM//mppw87VjVVw4HBFjUj+vZQbyQA=; b=R2gtR882gNAzU+/A3Nm/wmkxD12ABr4OJlk1U7qxLpna6sNR5S2wHKXNevw7VpxzHS1KjU i+zJYdw93cVK0ceDzA/DG/XYzY8mtgLYGYLX/mynaCZFty08g06kngLw6p0DVmC9WpN0GX Z7bYo86f6rBlI41oxOZKwFCNHFK13+w= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:50 +0000 Message-Id: <20200102145357.6724-17-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/23] src: remove unused imports of dirname.h 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: 75SHAxOpPiuwDIYysgyVtQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) A few places were importing dirname.h without actually using it. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- build-aux/syntax-check.mk | 2 +- src/qemu/qemu_command.c | 1 - src/storage/storage_driver.c | 1 - tests/virstoragetest.c | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 8de82e9872..7e7c59c3df 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -611,7 +611,7 @@ sc_forbid_manual_xml_indent: # dirname and basename from are not required to be thread-safe sc_prohibit_libgen: @prohibit=3D'( (base|dir)name *\(|include .libgen\.h)' \ - halt=3D'use functions from gnulib "dirname.h", not ' \ + halt=3D'use functions from GLib, not ' \ $(_sc_search_regexp) =20 # raw xmlGetProp requires some nasty casts diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a8137b3a32..11d3c29297 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -31,7 +31,6 @@ #include "qemu_slirp.h" #include "qemu_block.h" #include "cpu/cpu.h" -#include "dirname.h" #include "viralloc.h" #include "virlog.h" #include "virarch.h" diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 72ba252543..6bbf52f729 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -48,7 +48,6 @@ #include "virsecret.h" #include "virstring.h" #include "viraccessapicheck.h" -//#include "dirname.h" #include "storage_util.h" =20 #define VIR_FROM_THIS VIR_FROM_STORAGE diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index b9d4a45cdd..0e274ad1b7 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -26,7 +26,6 @@ #include "virlog.h" #include "virstoragefile.h" #include "virstring.h" -#include "dirname.h" =20 #include "storage/storage_driver.h" =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977039; cv=none; d=zohomail.com; s=zohoarc; b=WuQ/ZFIGpePbIhekged/tHk6HAAwn91e9QdDfeFW3Bnn+75i5TZEPrvT3aAdnW7L2tcu1vHfv60jYlWquWKPC4rEncOPuWLAI+WSoqjiHkkP2OHOP6gS1lfSs3mn9SCcsI3+oa0uE32VaN1nOO7PF5+n95RwsKh2Zw3fOjDlT90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977039; 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=N7OAMBNgaj78m6Tr6uOtsdkVoXi/cRIkIReYj6Hq1Jw=; b=T9ekA7VJN9R+Cl5b1jMYGo7a5Ipz2YyXsvJTCHDRtlzahSzesOF+5Mkdfd2pxE0MuJ0H1By8WXL9Wy2rvxi/AwAjICPs2knKkrEZB9MTVFvXmYSLOEq0MAl73h4ybM75WbHhU0oB9DK286x6QwJ7oL3EQ0+4y+9jufpgERWGab8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977039340351.75403258034646; Thu, 2 Jan 2020 06:57:19 -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-323-WXQiUQRnMz-Uxkbg3sSKlA-1; Thu, 02 Jan 2020 09:57:16 -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 ECCCC18CA241; Thu, 2 Jan 2020 14:57:10 +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 C7A7D29159; Thu, 2 Jan 2020 14:57:10 +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 81AAB18034EB; Thu, 2 Jan 2020 14:57:10 +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 002Ev8xc004990 for ; Thu, 2 Jan 2020 09:57:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id ED0E095307; Thu, 2 Jan 2020 14:57:08 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E3C260BF4; Thu, 2 Jan 2020 14:56:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977038; 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=N7OAMBNgaj78m6Tr6uOtsdkVoXi/cRIkIReYj6Hq1Jw=; b=DMwfTWnZmvm/Rr6scsvftoPjJ3DSvhNqi9hBTpZmggMUDVebSY0hisaSdqReQoDFqAuehV yOnz7IDprIcMg4P6PSnYqWi2/iy6DhQZdzT7l0QLKRO6Mw9AY+ZdmpJxDyvO/nTNlCu+y6 ZKXWd2oUCFvEWGL4vqficC6jp9b4ePg= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:51 +0000 Message-Id: <20200102145357.6724-18-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/23] src: replace getcwd() with g_get_current_dir() 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: WXQiUQRnMz-Uxkbg3sSKlA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) commandhelper.c is not converted since this is a standalone program only run on UNIX, so can rely on getcwd(). Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/util/virfile.c | 5 +---- tools/vsh.c | 16 +++------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index d5e4d0a289..9787086f3d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3187,10 +3187,7 @@ virFileAbsPath(const char *path, char **abspath) if (path[0] =3D=3D '/') { *abspath =3D g_strdup(path); } else { - g_autofree char *buf =3D getcwd(NULL, 0); - - if (buf =3D=3D NULL) - return -1; + g_autofree char *buf =3D g_get_current_dir(); =20 *abspath =3D g_strdup_printf("%s/%s", buf, path); } diff --git a/tools/vsh.c b/tools/vsh.c index a2f33e01aa..a36b6bfe23 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -3296,21 +3296,11 @@ const vshCmdInfo info_pwd[] =3D { bool cmdPwd(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) { - char *cwd; - bool ret =3D true; - char ebuf[1024]; + g_autofree char *cwd =3D g_get_current_dir(); =20 - cwd =3D getcwd(NULL, 0); - if (!cwd) { - vshError(ctl, _("pwd: cannot get current directory: %s"), - virStrerror(errno, ebuf, sizeof(ebuf))); - ret =3D false; - } else { - vshPrint(ctl, _("%s\n"), cwd); - VIR_FREE(cwd); - } + vshPrint(ctl, _("%s\n"), cwd); =20 - return ret; + return true; } =20 const vshCmdInfo info_quit[] =3D { --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977085; cv=none; d=zohomail.com; s=zohoarc; b=QoXLQN7Jout9l3I/jbveQhY9I3OkwnSb5q/j6nwx3e72ZU36jIjYc+F2pXr/cMf0fCuTQRl8Ln91BSyAMJS8xh6yG7iAY8HWzEru8Bnxh3nq7gMQhRwp6p+SvdAUDhqRdlVn6N4s88eHV3yxRTOvQ+4YtJT2WFOn58zcOejY1xo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977085; 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=n6nL737U5o75ZeV2Y0NazI/a2iWYjb3LcdU7uhst1fY=; b=amwvRuCU517gEa2SdqBSUzDFVmDniw8LQqOO0Z+nrAAIDbsxTe8cYBOaO2fPrJX1nKVOBdP3Mvr4Ju0xRy9hREeacv/N6c48SzXJnw+YfAX/015iSu/HMmL7+GwKnGPtNZ1XDr5hfxm8Hx8gEVBm01OOKTyTYD81OZ1y+nnIxKU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1577977085661988.4446563069516; Thu, 2 Jan 2020 06:58: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-61-IAtOkjiZOCCHrrQ4npr8Qg-1; Thu, 02 Jan 2020 09:57:24 -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 B0461800D4C; Thu, 2 Jan 2020 14:57:18 +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 8AA0F7DB2E; Thu, 2 Jan 2020 14:57:18 +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 4999D18034EE; Thu, 2 Jan 2020 14:57:18 +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 002EvHMU005049 for ; Thu, 2 Jan 2020 09:57:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3FF7F95304; Thu, 2 Jan 2020 14:57:17 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD93360BF4; Thu, 2 Jan 2020 14:57:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977084; 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=n6nL737U5o75ZeV2Y0NazI/a2iWYjb3LcdU7uhst1fY=; b=OmE7d9Jo5vTnSXXd4FTUBJEtYOJYTrtrFvn1W+zdbR2jzz4hMrEkbXaE7l3bsa9zNRJ2XW Dcb2X5+nG/7+xkBJVdBPKyUFgXnnkNHOy/7UesmlSh1U/PDTd/k+KedRRn1P5kP489dRLG /KjEd6B1jwuJn2BIbNgg9lqcvz7Q060= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:52 +0000 Message-Id: <20200102145357.6724-19-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 18/23] util: use realpath/g_canonicalize_filename 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: IAtOkjiZOCCHrrQ4npr8Qg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The canonicalize_file_name(path) is equivalent to calling realpath(path, NULL). Passing NULL for the second arg of realpath is not standardized behaviour, however, Linux, FreeBSD > 6.4 and macOS > 10.5 all support this critical extension. This leaves Windows which doesn't provide realpath at all. The g_canonicalize_filename() function doesn't expand symlinks, so is not strictly equivalent to realpath() but is close enough for our Windows portability needs right now. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/util/virfile.c | 9 ++++++++- tests/virfilemock.c | 12 +++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 9787086f3d..4fc872ef1d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3256,7 +3256,14 @@ virFileSanitizePath(const char *path) char * virFileCanonicalizePath(const char *path) { - return canonicalize_file_name(path); /* exempt from syntax-check */ +#ifdef WIN32 + /* Does not resolve symlinks, only expands . & .. & repeated /. + * It will never fail, so sanitize errno to indicate success */ + errno =3D 0; + return g_canonicalize_filename(path, NULL); +#else + return realpath(path, NULL); /* exempt from syntax-check */ +#endif } =20 /** diff --git a/tests/virfilemock.c b/tests/virfilemock.c index 65685c6d26..802ee9b5f9 100644 --- a/tests/virfilemock.c +++ b/tests/virfilemock.c @@ -24,6 +24,7 @@ #if HAVE_LINUX_MAGIC_H # include #endif +#include =20 #include "virmock.h" #include "virstring.h" @@ -33,7 +34,7 @@ =20 static FILE *(*real_setmntent)(const char *filename, const char *type); static int (*real_statfs)(const char *path, struct statfs *buf); -static char *(*real_canonicalize_file_name)(const char *path); +static char *(*real_realpath)(const char *path, char *resolved); =20 =20 static void @@ -44,7 +45,7 @@ init_syms(void) =20 VIR_MOCK_REAL_INIT(setmntent); VIR_MOCK_REAL_INIT(statfs); - VIR_MOCK_REAL_INIT(canonicalize_file_name); + VIR_MOCK_REAL_INIT(realpath); } =20 =20 @@ -116,7 +117,7 @@ statfs_mock(const char *mtab, /* We don't need to do this in callers because real statfs(2) * does that for us. However, in mocked implementation we * need to do this. */ - if (!(canonPath =3D canonicalize_file_name(path))) + if (!(canonPath =3D realpath(path, NULL))) return -1; =20 while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) { @@ -178,7 +179,7 @@ statfs(const char *path, struct statfs *buf) =20 =20 char * -canonicalize_file_name(const char *path) +realpath(const char *path, char *resolved) { =20 init_syms(); @@ -187,6 +188,7 @@ canonicalize_file_name(const char *path) const char *p; char *ret; =20 + assert(resolved =3D=3D NULL); if ((p =3D STRSKIP(path, "/some/symlink"))) ret =3D g_strdup_printf("/gluster%s", p); else @@ -195,5 +197,5 @@ canonicalize_file_name(const char *path) return ret; } =20 - return real_canonicalize_file_name(path); + return real_realpath(path, resolved); } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977059; cv=none; d=zohomail.com; s=zohoarc; b=TIFfYZ838O892sHUbc3GKrytkvWd54VRTp82emTKySagAaWSc5LsEGoPM5ofz1NpUzISyZM6H6j9Q0gOYYXW5FDzZ90dueuuSF5es5SLHj4Mx12cYZqj3CY4OoDKikqABz40ZLKKxDvj0lmbmBwYy9cNRkjxPTo52ydQ5Pgv6qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977059; 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=n9v8pXkhYg/Iz7fWYYmcn22alldqBIJbFnRPkAeTDiA=; b=OEqZgHZFO31bSHaTk83jCTIAc0gFBiBJBILTA1HAHbmkkcsVDwTQU6DkZxUpHCQv9a8SfSRwLE2ut6ZIODix9gSuegtn+yj4MvsDw29oBkIlhwg1n34jhGpuMJIq1d2DRN1ah5UwdSUXKtZf2EHBXx79fMX0HJwsTrfmq0pi74o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977059624737.0855265059726; Thu, 2 Jan 2020 06:57:39 -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-ydJfSkxPOtyvXFVVn9dUeA-1; Thu, 02 Jan 2020 09:57:36 -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 70E26911EC; Thu, 2 Jan 2020 14:57:31 +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 4C66C29159; Thu, 2 Jan 2020 14:57:31 +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 074A518034F9; Thu, 2 Jan 2020 14:57:31 +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 002EvTe7005127 for ; Thu, 2 Jan 2020 09:57:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7B5A8952E5; Thu, 2 Jan 2020 14:57:29 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEA8860BF4; Thu, 2 Jan 2020 14:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977058; 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=n9v8pXkhYg/Iz7fWYYmcn22alldqBIJbFnRPkAeTDiA=; b=QYxg83MXhrc+r3BBpYqMtD23sAtDfShCULcAF6K0hfENOMZIorThuJTaxlQHEYQUfQ+I2/ GjpRA+pknZcaBIOM8KZeDP9vlu1INURjtxdSUlQv5y+4xTTmCApQ+bOD+HQnxcIgC2NsrH PHRBhvXXR0qRaVCfoqI9NvMy7zxx/lU= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:53 +0000 Message-Id: <20200102145357.6724-20-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/23] util: replace gethostname() with g_get_hostname() 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: ydJfSkxPOtyvXFVVn9dUeA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Note the glib function returns a const string because it caches the hostname using a one time thread initializer function. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/util/virlog.c | 17 ++++------------- src/util/virutil.c | 12 +++--------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index aa98024e1c..e46ae69471 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -60,7 +60,6 @@ VIR_LOG_INIT("util.log"); =20 static GRegex *virLogRegex; -static char virLogHostname[HOST_NAME_MAX+1]; =20 =20 #define VIR_LOG_DATE_REGEX "[0-9]{4}-[0-9]{2}-[0-9]{2}" @@ -253,8 +252,6 @@ virLogPriorityString(virLogPriority lvl) static int virLogOnceInit(void) { - int r; - if (virMutexInit(&virLogMutex) < 0) return -1; =20 @@ -263,19 +260,13 @@ virLogOnceInit(void) =20 virLogRegex =3D g_regex_new(VIR_LOG_REGEX, G_REGEX_OPTIMIZE, 0, NULL); =20 - /* We get and remember the hostname early, because at later time + /* GLib caches the hostname using a one time thread initializer. + * We want to prime this cache early though, because at later time * it might not be possible to load NSS modules via getaddrinfo() * (e.g. at container startup the host filesystem will not be * accessible anymore. - * Must not use virGetHostname though as that causes re-entrancy - * problems if it triggers logging codepaths */ - r =3D gethostname(virLogHostname, sizeof(virLogHostname)); - if (r =3D=3D -1) { - ignore_value(virStrcpyStatic(virLogHostname, "(unknown)")); - } else { - NUL_TERMINATE(virLogHostname); - } + (void)g_get_host_name(); =20 virLogUnlock(); return 0; @@ -471,7 +462,7 @@ virLogHostnameString(char **rawmsg, { char *hoststr; =20 - hoststr =3D g_strdup_printf("hostname: %s", virLogHostname); + hoststr =3D g_strdup_printf("hostname: %s", g_get_host_name()); =20 virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, hoststr); *rawmsg =3D hoststr; diff --git a/src/util/virutil.c b/src/util/virutil.c index 9620ff204d..a0fd7618ee 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -503,17 +503,11 @@ static char * virGetHostnameImpl(bool quiet) { int r; - char hostname[HOST_NAME_MAX+1], *result =3D NULL; + const char *hostname; + char *result =3D NULL; struct addrinfo hints, *info; =20 - r =3D gethostname(hostname, sizeof(hostname)); - if (r =3D=3D -1) { - if (!quiet) - virReportSystemError(errno, - "%s", _("failed to determine host name")); - return NULL; - } - NUL_TERMINATE(hostname); + hostname =3D g_get_host_name(); =20 if (STRPREFIX(hostname, "localhost") || strchr(hostname, '.')) { /* in this case, gethostname returned localhost (meaning we can't --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977071; cv=none; d=zohomail.com; s=zohoarc; b=KMH5+F4IkcdJcA3GrUWWaC3gbGZo0Qf5F+RV4lzIk2dv1GKQt91h8GuZEgqVTorsEznpCr7L9RSDpfozj7zA5xdW17Nxn++j9sLQi9YQ50J+FSC770F4EDILnwdWqnQfxBDD8WtMaQ1OGqSqamh9XVy3aV724FPu8r2ALHsY3rY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977071; 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=ev164FGD5d6Kl+ZjF6xdzdtcg102aFYqA1zaDhFz0Ek=; b=KySTAim3yS2Wr0fu/F04RbTtXTmqYLA7wHdyaaHpr9ucxnDiIkeTwdGyFop9yXPPq/nvblmZQw2egeDyvYAC35iFEHAiL9iGL7Skqd0aaYVQJc95WN7GrXlN2XD5ZUj61QFLOYGS52TWLIOVK2DJXP42id+iA/VVLgFsBHfKVyc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977071392785.4917769835546; Thu, 2 Jan 2020 06:57:51 -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-61-aUh5Kyn6MRSfIHrM5JKyqg-1; Thu, 02 Jan 2020 09:57:48 -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 EE95219057A5; Thu, 2 Jan 2020 14:57:42 +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 C686B60FC1; Thu, 2 Jan 2020 14:57:42 +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 80D8081E3E; Thu, 2 Jan 2020 14:57:42 +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 002Evfl4005258 for ; Thu, 2 Jan 2020 09:57:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6608460C87; Thu, 2 Jan 2020 14:57:41 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 174CA6106C; Thu, 2 Jan 2020 14:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977070; 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=ev164FGD5d6Kl+ZjF6xdzdtcg102aFYqA1zaDhFz0Ek=; b=TiNS7z2JnRY32nFrMye7mNf2ZyvA+INydGgF9k+gEMazExUS+Sv9S5IhMAgAEzhiBFRgvx mvEZLZhFLMutjzMlhmjY4JPNjT/cmLI4dDTysm+u9wF7tjODQjne/372puiVGrCS/i54xE cFOutIeAvk8zSRAHSbwH1ybpod1P7ZQ= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:54 +0000 Message-Id: <20200102145357.6724-21-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 20/23] src: replace WSAStartup with g_networking_init() 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: aUh5Kyn6MRSfIHrM5JKyqg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) g_networking_init() does the same as our custom code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- m4/virt-glib.m4 | 2 +- src/libvirt.c | 25 ++----------------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/m4/virt-glib.m4 b/m4/virt-glib.m4 index eb2c77b25b..03e51711c0 100644 --- a/m4/virt-glib.m4 +++ b/m4/virt-glib.m4 @@ -24,7 +24,7 @@ AC_DEFUN([LIBVIRT_ARG_GLIB], [ AC_DEFUN([LIBVIRT_CHECK_GLIB],[ GLIB_REQUIRED=3D2.48.0 =20 - LIBVIRT_CHECK_PKG([GLIB], [glib-2.0 gobject-2.0], [$GLIB_REQUIRED]) + LIBVIRT_CHECK_PKG([GLIB], [glib-2.0 gobject-2.0 gio-2.0], [$GLIB_REQUIRE= D]) =20 if test "$with_glib" =3D "no" ; then AC_MSG_ERROR([glib-2.0, gobject-2.0 >=3D $GLIB_REQUIRED are required f= or libvirt]) diff --git a/src/libvirt.c b/src/libvirt.c index c741ebe311..f1ffc97261 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -26,15 +26,12 @@ #include #include #include +#include =20 #include #include #include "getpass.h" =20 -#ifdef HAVE_WINSOCK2_H -# include -#endif - #ifdef WITH_CURL # include #endif @@ -211,21 +208,6 @@ static virConnectAuth virConnectAuthDefault =3D { */ virConnectAuthPtr virConnectAuthPtrDefault =3D &virConnectAuthDefault; =20 -#if HAVE_WINSOCK2_H -static int -virWinsockInit(void) -{ - WORD winsock_version, err; - WSADATA winsock_data; - - /* http://msdn2.microsoft.com/en-us/library/ms742213.aspx */ - winsock_version =3D MAKEWORD(2, 2); - err =3D WSAStartup(winsock_version, &winsock_data); - return err =3D=3D 0 ? 0 : -1; -} -#endif - - static bool virGlobalError; static virOnceControl virGlobalOnce =3D VIR_ONCE_CONTROL_INITIALIZER; =20 @@ -261,10 +243,7 @@ virGlobalInit(void) =20 VIR_DEBUG("register drivers"); =20 -#if HAVE_WINSOCK2_H - if (virWinsockInit() =3D=3D -1) - goto error; -#endif + g_networking_init(); =20 #ifdef HAVE_LIBINTL_H if (!bindtextdomain(PACKAGE, LOCALEDIR)) --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977209; cv=none; d=zohomail.com; s=zohoarc; b=BCErTUr8/fvLp9yDapIToXu8X/qI8IpQG/cJHoTqdIkJ032eYtC0OC3BqAdg14OMLYTm3NxO8El8VHKZVwRSRozEeOyfnMYPY7OUSIjk9AHeBihonDtcGQntJNEjgVojreiUfT3sWcGacTft+JCpu4eRUWYeEJKJSj7U7ujvCoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977209; 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=Vvp0SrGsccpE8eBgJlodg1/WeD4IK596QvHAaAap/Pc=; b=XWrPqC0SmyzViYsakkgCqmMmfTnfnyOgxEtnf6QxmdJ2qMkhDw+ZFr1yR9p7u7RPm3Yps+TuVvrBecgDLWFZz6N5bA4pjExPNIVeRHhsK7f41TAnk0B916ptQCLb1Hw767i39tOFaDncTvJbyriigIaZIJl0Th+Qn/SmRZZW7M4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977209914837.7284345689335; Thu, 2 Jan 2020 07:00:09 -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-239-7NKoKx0nMb6tinOFGbvyHA-1; Thu, 02 Jan 2020 09:57:57 -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 4459F80575D; Thu, 2 Jan 2020 14:57:51 +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 1828360C87; Thu, 2 Jan 2020 14:57:51 +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 C5EAD18034FC; Thu, 2 Jan 2020 14:57:50 +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 002EvnZP005292 for ; Thu, 2 Jan 2020 09:57:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id C9C2660C87; Thu, 2 Jan 2020 14:57:49 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D6DE952E5; Thu, 2 Jan 2020 14:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977204; 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=Vvp0SrGsccpE8eBgJlodg1/WeD4IK596QvHAaAap/Pc=; b=hjIly1sx0AX3YRkiyU+n762NzktEvsmSx4mt57lR/qColV1mFKXvZFnsZruDPbx2bvDw94 Xnxm72eNf9Bdjk0ZnAZKscK41nMnmhSEvQSUPCxOsFSjwaTB8EISSA9ORQvE8GQ1nDWX3M FHIwkNP5HYwT/172EZwRz8ztmQVeqPc= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:55 +0000 Message-Id: <20200102145357.6724-22-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 21/23] src: replace strptime()/timegm()/mktime() with GDateTime APIs set 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: 7NKoKx0nMb6tinOFGbvyHA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) All places where we use strptime/timegm()/mktime() are handling conversion of dates in a format compatible with ISO 8601, so we can use the GDateTime APIs to simplify code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- src/conf/domain_conf.c | 32 +++++-------------- src/esx/esx_vi_types.c | 71 +++++------------------------------------- src/vz/vz_sdk.c | 10 +++--- 3 files changed, 20 insertions(+), 93 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index afa072e17d..ee33b7caf0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13673,33 +13673,17 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, =20 validTo =3D virXMLPropString(node, "passwdValidTo"); if (validTo) { - char *tmp; - struct tm tm; - memset(&tm, 0, sizeof(tm)); - /* Expect: YYYY-MM-DDTHH:MM:SS (%d-%d-%dT%d:%d:%d) eg 2010-11-28T= 14:29:01 */ - if (/* year */ - virStrToLong_i(validTo, &tmp, 10, &tm.tm_year) < 0 || *tmp != =3D '-' || - /* month */ - virStrToLong_i(tmp+1, &tmp, 10, &tm.tm_mon) < 0 || *tmp !=3D '= -' || - /* day */ - virStrToLong_i(tmp+1, &tmp, 10, &tm.tm_mday) < 0 || *tmp !=3D = 'T' || - /* hour */ - virStrToLong_i(tmp+1, &tmp, 10, &tm.tm_hour) < 0 || *tmp !=3D = ':' || - /* minute */ - virStrToLong_i(tmp+1, &tmp, 10, &tm.tm_min) < 0 || *tmp !=3D '= :' || - /* second */ - virStrToLong_i(tmp+1, &tmp, 10, &tm.tm_sec) < 0 || *tmp !=3D '= \0') { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse password validity time '%s', ex= pect YYYY-MM-DDTHH:MM:SS"), - validTo); - VIR_FREE(def->passwd); + g_autoptr(GDateTime) then =3D NULL; + g_autoptr(GTimeZone) tz =3D g_time_zone_new_utc(); + + then =3D g_date_time_new_from_iso8601(validTo, tz); + if (!then) { + virReportError(VIR_ERR_INVALID_ARG, + _("password validity time '%s' values out of ra= nge"), validTo); return -1; } =20 - tm.tm_year -=3D 1900; /* Human epoch starts at 0 BC, not 1900BC */ - tm.tm_mon--; /* Humans start months at 1, computers at 0 */ - - def->validTo =3D timegm(&tm); + def->validTo =3D (int)g_date_time_to_unix(then); def->expires =3D true; } =20 diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 1deb5026b7..434313dfa4 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -1473,27 +1473,14 @@ int esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime, long long *secondsSinceEpoch) { - char value[64] =3D ""; - char *tmp; - struct tm tm; - int milliseconds; - char sign; - int tz_hours; - int tz_minutes; - int tz_offset =3D 0; + g_autoptr(GDateTime) then =3D NULL; + g_autoptr(GTimeZone) tz =3D NULL; =20 if (!dateTime || !secondsSinceEpoch) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); return -1; } =20 - if (virStrcpyStatic(value, dateTime->value) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("xsd:dateTime value '%s' too long for destination= "), - dateTime->value); - return -1; - } - /* * expected format: [-]CCYY-MM-DDTHH:MM:SS[.ssssss][((+|-)HH:MM|Z)] * typical example: 2010-04-05T12:13:55.316789+02:00 @@ -1502,66 +1489,22 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime= *dateTime, * * map negative years to 0, since the base for time_t is the year 1970. */ - if (*value =3D=3D '-') { + if (*(dateTime->value) =3D=3D '-') { *secondsSinceEpoch =3D 0; return 0; } =20 - tmp =3D strptime(value, "%Y-%m-%dT%H:%M:%S", &tm); + tz =3D g_time_zone_new_utc(); + then =3D g_date_time_new_from_iso8601(dateTime->value, tz); =20 - if (!tmp) { + if (!then) { virReportError(VIR_ERR_INTERNAL_ERROR, _("xsd:dateTime value '%s' has unexpected format"), dateTime->value); return -1; } =20 - if (*tmp !=3D '\0') { - /* skip .ssssss part if present */ - if (*tmp =3D=3D '.' && - virStrToLong_i(tmp + 1, &tmp, 10, &milliseconds) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("xsd:dateTime value '%s' has unexpected forma= t"), - dateTime->value); - return -1; - } - - /* parse timezone offset if present. if missing assume UTC */ - if (*tmp =3D=3D '+' || *tmp =3D=3D '-') { - sign =3D *tmp; - - if (virStrToLong_i(tmp + 1, &tmp, 10, &tz_hours) < 0 || - *tmp !=3D ':' || - virStrToLong_i(tmp + 1, NULL, 10, &tz_minutes) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("xsd:dateTime value '%s' has unexpected f= ormat"), - dateTime->value); - return -1; - } - - tz_offset =3D tz_hours * 60 * 60 + tz_minutes * 60; - - if (sign =3D=3D '-') - tz_offset =3D -tz_offset; - } else if (STREQ(tmp, "Z")) { - /* Z refers to UTC. tz_offset is already initialized to zero */ - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("xsd:dateTime value '%s' has unexpected forma= t"), - dateTime->value); - return -1; - } - } - - /* - * xsd:dateTime represents local time relative to the optional timezone - * given as offset. pretend the local time is in UTC and use timegm in - * order to avoid interference with the timezone to this computer. - * apply timezone correction afterwards, because it's simpler than - * handling all the possible over- and underflows when trying to apply - * it to the tm struct. - */ - *secondsSinceEpoch =3D timegm(&tm) - tz_offset; + *secondsSinceEpoch =3D g_date_time_to_unix(then); =20 return 0; } diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 59d7d31419..c98542c244 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4607,17 +4607,17 @@ int prlsdkSetMemsize(virDomainObjPtr dom, unsigned = int memsize) static long long prlsdkParseDateTime(const char *str) { - struct tm tm; - const char *tmp; + g_autoptr(GDateTime) then =3D NULL; + g_autoptr(GTimeZone) tz =3D g_time_zone_new_local(); =20 - tmp =3D strptime(str, "%Y-%m-%d %H:%M:%S", &tm); - if (!tmp || *tmp !=3D '\0') { + then =3D g_date_time_new_from_iso8601(str, tz); + if (!then) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected DateTime format: '%s'"), str); return -1; } =20 - return mktime(&tm); + return g_date_time_to_unix(then); } =20 static virDomainSnapshotObjListPtr --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977091; cv=none; d=zohomail.com; s=zohoarc; b=L9ZQBYt/CogjMVn51D2OLANIAccq34RtcmXdfLkic4LRDNyRu7NniHUctid1c0BHSBrGtZUZWH1LnqPfPszdaYZvGIpvhxSSjRQlh1/Nqkoc9eSbvaMoS5oCLdy1R6rsn80XqR8BMr1tPSaqHFjL19nV737LZAk3jAkcU2K4gQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977091; 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=GP85w87mgN40Dq+Habr7yZxzTQERcLRo3UYf5QK7074=; b=kRdfdPfzsGdosie3ULyMXkeus2MCe9Z5tII0TL+R7745Ths4GuKVE/ekKiO++TjYNTvAPSvplx3XI15GvlqpuAD8hVOh6e/xO2P2KcZ/HwRqZqsfydKm8dUXJYmFDs21wW9iADk8Spr37X11WuyFvCgcSlswAppNboUUs0K2Q1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977091903718.0086030285171; Thu, 2 Jan 2020 06:58:11 -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-407-4Uud0IXMM1a5T1mLRqSC4g-1; Thu, 02 Jan 2020 09:58:08 -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 984A61137850; Thu, 2 Jan 2020 14:58:02 +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 3452485EE6; Thu, 2 Jan 2020 14:58:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D9CE918034FF; Thu, 2 Jan 2020 14:58:01 +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 002Ew05Y005329 for ; Thu, 2 Jan 2020 09:58:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 56C2560FC1; Thu, 2 Jan 2020 14:58:00 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id C19BA6CE40; Thu, 2 Jan 2020 14:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977090; 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=GP85w87mgN40Dq+Habr7yZxzTQERcLRo3UYf5QK7074=; b=YO2xbl3Wj25mR1l8eskqSYjNOQYfiDfGk7OoGAg8o+WO+1uJqlAL2ocuDUAZGAN4kinSC9 C3WGUepjxLfnUTImsKTjWNCUBgJDjCTxqZPqp6FabCmcio14NxpqPLcqoKwgbscCf5SN+z EFhYk5RPCxSIn5BhCHNQc2qB3HDGzDk= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:56 +0000 Message-Id: <20200102145357.6724-23-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 22/23] bootstrap: remove now unused gnulib modules 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: 4Uud0IXMM1a5T1mLRqSC4g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) * canonicalize-lgpl: replaced by realpath()/g_canonicalize_filename() * clock-gettime: replaced by g_get_(real|monotonic)_time * dirname-lgpl: replaced by g_path_get_dirname() * fclose: we aren't affected by any portability problems it fixes * fdatasync: every platform we call fdatasync on has it present * fsync: replaced by g_fsync() * fnmatch: replaced by g_pattern_match() * getcwd-lgpl: replaced by g_get_current_dir() * gethostname: replaced by g_get_hostname() * gettimeofday: replaced by g_get_(real|monotonic)_time * setenv: replaced by g_setenv() * strptime: replaced by GDateTime * timegm: replaced by GDateTime * unsetenv: replaced by g_unsetenv() Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- bootstrap.conf | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 0a8b591418..3d9243fa01 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -20,27 +20,17 @@ gnulib_modules=3D' accept bind -canonicalize-lgpl chown -clock-time close connect configmake -dirname-lgpl environ -fclose fcntl fcntl-h -fdatasync -fnmatch -fsync getaddrinfo -getcwd-lgpl -gethostname getpass getpeername getsockname -gettimeofday intprops ioctl largefile @@ -61,23 +51,19 @@ posix-shell pthread_sigmask recv send -setenv setsockopt sigaction sigpipe socket stat-time strchrnul -strptime strtok_r sys_stat sys_wait termios time_r -timegm ttyname_r uname -unsetenv verify waitpid warnings --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 11:15:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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 (zohomail.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=1577977101; cv=none; d=zohomail.com; s=zohoarc; b=mbPeZEUYWduNWIM+VrObYLdg3m49jp7zsXMvuurQqbpNy4uSUQiaKhpUfKcDmMsQa5kDj7n4RUOglFbO3cAX5l6cM4akHEbFWh424rHBhXmtB1ppaJre9fOpIp0wVfs4mjHiUbfqJ+1HfFEx4GxWTFxvauiqlI+S/xvDUkmibAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977101; 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=kl9JeSjHQ+VChopMojpr82DBi/o3OU1oYp5hsTnKLZk=; b=lm1HafnsumqL7RoY/9PJ9teK6an5/pRh69thtXp9CbJre6wXyfHgEyIO7O7BqzMspmDke32thrmSqH/ThWc/TGa3bdnlLZk4B2XDnxNoNcEokZXM2K10idPhDjgNLLFs+dmiK/7kyF+st4fnncOK7VNrSoOSDRFtzm+ivgRQ/Vg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.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 1577977101696837.7752669066344; Thu, 2 Jan 2020 06:58:21 -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-17-V_iLsZXDMxWezBJab7Areg-1; Thu, 02 Jan 2020 09:58:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C29F9216C6; Thu, 2 Jan 2020 14:58:13 +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 D1F397A405; Thu, 2 Jan 2020 14:58:12 +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 81C67104909; Thu, 2 Jan 2020 14:58:12 +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 002EwAfr005396 for ; Thu, 2 Jan 2020 09:58:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id A8CDA60FC5; Thu, 2 Jan 2020 14:58:10 +0000 (UTC) Received: from catbus.gsslab.fab.redhat.com (dhcp-43.gsslab.fab.redhat.com [10.33.9.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DC2560FC1; Thu, 2 Jan 2020 14:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977100; 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=kl9JeSjHQ+VChopMojpr82DBi/o3OU1oYp5hsTnKLZk=; b=TsgP896pKvML9SvgHHKmtayCH2iWfifRWpAgz4SORrw/S6noF0LnE7PbjAmAP+JNOrmYwH LKpg1S/paH4a/mqA5v+4fm90KEKx0y93qy1grsOAJvEw2SgxUpAT8UgR+UCs/jgw4p8TRX pL+CkkoAOHI4p2ydwkoVDHT9Q9JL8yE= From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 14:53:57 +0000 Message-Id: <20200102145357.6724-24-berrange@redhat.com> In-Reply-To: <20200102145357.6724-1-berrange@redhat.com> References: <20200102145357.6724-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/23] bootstrap: annotate with info about desired replacement X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: V_iLsZXDMxWezBJab7Areg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Add a comment against each gnulib module suggesting strategy for replacement. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Fabiano Fid=C3=AAncio --- bootstrap.conf | 159 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 107 insertions(+), 52 deletions(-) diff --git a/bootstrap.conf b/bootstrap.conf index 3d9243fa01..ae9ecb4039 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -17,58 +17,113 @@ # . =20 # gnulib modules used by this package. -gnulib_modules=3D' -accept -bind -chown -close -connect -configmake -environ -fcntl -fcntl-h -getaddrinfo -getpass -getpeername -getsockname -intprops -ioctl -largefile -listen -localeconv -manywarnings -mgetgroups -net_if -netdb -nonblocking -openpty -passfd -physmem -pipe-posix -pipe2 -poll -posix-shell -pthread_sigmask -recv -send -setsockopt -sigaction -sigpipe -socket -stat-time -strchrnul -strtok_r -sys_stat -sys_wait -termios -time_r -ttyname_r -uname -verify -waitpid -warnings -wcwidth -' + +# NB the GSocket conversion is non-trivial due to the +# different FD vs HANDLE usage in gnulib vs glib. Need +# to find a way to duplicate a socket HANDLE before +# turning it into a FD, since closing an FD also closes +# the original HANDLE. + +# -> GSocket +gnulib_modules=3D"$gnulib_modules accept" +# -> GSocket +gnulib_modules=3D"$gnulib_modules bind" +# -> conditional build to avoid Win32 +gnulib_modules=3D"$gnulib_modules chown" +# -> GSocket +gnulib_modules=3D"$gnulib_modules close" +# -> GSocket +gnulib_modules=3D"$gnulib_modules connect" +# -> Meson +gnulib_modules=3D"$gnulib_modules configmake" +# -> eliminate usage in some manner +gnulib_modules=3D"$gnulib_modules environ" +# -> GSocket +gnulib_modules=3D"$gnulib_modules fcntl" +# -> conditional build avoid win32 +gnulib_modules=3D"$gnulib_modules fcntl-h" +# -> GSocket +gnulib_modules=3D"$gnulib_modules getaddrinfo" +# -> copy gnuliub win32 impl +gnulib_modules=3D"$gnulib_modules getpass" +# -> GSocket +gnulib_modules=3D"$gnulib_modules getpeername" +# -> GSocket +gnulib_modules=3D"$gnulib_modules getsockname" +# -> copy gnulib STRBUFLEN macro +gnulib_modules=3D"$gnulib_modules intprops" +# -> GSocket +gnulib_modules=3D"$gnulib_modules ioctl" +# -> Meson +gnulib_modules=3D"$gnulib_modules largefile" +# -> GSocket +gnulib_modules=3D"$gnulib_modules listen" +# -> custom configure check +gnulib_modules=3D"$gnulib_modules localeconv" +# -> Meson +gnulib_modules=3D"$gnulib_modules manywarnings" +# -> painful copy gnulib +gnulib_modules=3D"$gnulib_modules mgetgroups" +# -> GSocket +gnulib_modules=3D"$gnulib_modules net_if" +# -> GSocket +gnulib_modules=3D"$gnulib_modules netdb" +# -> GSocket +gnulib_modules=3D"$gnulib_modules nonblocking" +# -> Just add -lutil to cli +gnulib_modules=3D"$gnulib_modules openpty" +# -> GSocket +gnulib_modules=3D"$gnulib_modules passfd" +# -> open code / copy gnulib code +gnulib_modules=3D"$gnulib_modules physmem" +# -> open code / conditional comp +gnulib_modules=3D"$gnulib_modules pipe-posix" +# -> open code / conditional comp +gnulib_modules=3D"$gnulib_modules pipe2" +# -> GMainLoop +gnulib_modules=3D"$gnulib_modules poll" +# -> Meson +gnulib_modules=3D"$gnulib_modules posix-shell" +# -> open code conditional logic +gnulib_modules=3D"$gnulib_modules pthread_sigmask" +# -> GSocket +gnulib_modules=3D"$gnulib_modules recv" +# -> GSocket +gnulib_modules=3D"$gnulib_modules send" +# -> GSocket +gnulib_modules=3D"$gnulib_modules setsockopt" +# -> open code conditional logic +gnulib_modules=3D"$gnulib_modules sigaction" +# -> open code conditional logic +gnulib_modules=3D"$gnulib_modules sigpipe" +# -> GSocket +gnulib_modules=3D"$gnulib_modules socket" +# -> open code conditional or use GIO GFileInfo +gnulib_modules=3D"$gnulib_modules stat-time" +# -> remove use or open-code it. possibly add to glib +gnulib_modules=3D"$gnulib_modules strchrnul" +# -> g_strsplit +gnulib_modules=3D"$gnulib_modules strtok_r" +# -> remove sys/stat.h include from any win32 code paths +gnulib_modules=3D"$gnulib_modules sys_stat" +# -> remove sys/wait.h include from any win32 code paths +gnulib_modules=3D"$gnulib_modules sys_wait" +# -> remove from any win32 code paths +gnulib_modules=3D"$gnulib_modules termios" +# -> GDateTime ? +gnulib_modules=3D"$gnulib_modules time_r" +# -> obsolete - exists on Linux, MacOS >=3D ?? & FreeBSD >=3D 6 +gnulib_modules=3D"$gnulib_modules ttyname_r" +# -> g_get_os_info in GLib 2.64 but can't use that yet +gnulib_modules=3D"$gnulib_modules uname" +# -> G_STATIC_ASSERT +gnulib_modules=3D"$gnulib_modules verify" +# -> remove from Win32 code paths +gnulib_modules=3D"$gnulib_modules waitpid" +# -> Meson +gnulib_modules=3D"$gnulib_modules warnings" +# -> open code impl +gnulib_modules=3D"$gnulib_modules wcwidth" =20 SKIP_PO=3Dtrue =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list