From nobody Sun Feb 8 05:41:01 2026 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 --- 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