From nobody Mon Feb 9 06:26:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611590766; cv=none; d=zohomail.com; s=zohoarc; b=QukRrFxOCsvY8u9UbJGPwxyeaAuL8h7HAwzAAdg4lqy5UnyE+gHHuWMsMzvWt+qa8dltHaRndwIvJj7/ELkJrR0OB5YXNA5yCqDN9GPuo2bEuTlZq+0fKcx/3z9t4HwJvt9VccY+EwvRfcx7WQR/S/5Y7WVgi0EVsS2EDy5h3lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611590766; 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=G9+VZ2MnlbRyMfMAJc9gwqwNyEPKmoHGfptv8XsvLx8=; b=QCdEsWEV2o5bgXfIP2a2VXhH8d5eXh1Cu6A7w+B+KoXpwuBh9MuEmYWurK/7Sgdyq3E4N2qdBhxiq3LErPpcxi5y5Rv1CjFfz82pQCIBoONKWDe6mLVTjmm2gNgD8b7Hol95FCP+Ejbud07qWD0KaC2+RVLDMqmYDc27FHENS8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1611590766021442.48889455085987; Mon, 25 Jan 2021 08:06:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-8-KDJNJ0T6OmKmVtnVxH7UKA-1; Mon, 25 Jan 2021 11:05:52 -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 1FA9C19611A6; Mon, 25 Jan 2021 16:05:45 +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 EFFAD5D9DE; Mon, 25 Jan 2021 16:05:44 +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 BCF701809CA4; Mon, 25 Jan 2021 16:05:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10PG5WTh018208 for ; Mon, 25 Jan 2021 11:05:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id A69C85D9DC; Mon, 25 Jan 2021 16:05:32 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 072445D9DB for ; Mon, 25 Jan 2021 16:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611590765; 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=G9+VZ2MnlbRyMfMAJc9gwqwNyEPKmoHGfptv8XsvLx8=; b=XYr/RBfKbM+fgDnKIoEzqkoulvyDf4JvS3ehI/RbuZPxTlVbHO+ng7dj5ZtXP66cOS/Fl1 zDQoAy0c4nCpOglv/Nuz6icZL9XcqJ2ZuSj1YlgdJ3B44son43hvO0bfEcjBathU6aJMR1 zyQ5D2y2kyYcFOlBZoKbSDT+HvIksaQ= X-MC-Unique: KDJNJ0T6OmKmVtnVxH7UKA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/12] util: virstoragefile: Move virStorageIs[File|Relative] to storage_source Date: Mon, 25 Jan 2021 17:05:15 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are no other files using it. Move it and make the functions static. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 2 -- src/storage_file/storage_source.c | 42 ++++++++++++++++++++++++++++--- src/util/virstoragefile.c | 34 ------------------------- src/util/virstoragefile.h | 3 --- 4 files changed, 38 insertions(+), 43 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c03b769c37..0a2a54dfdf 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3218,8 +3218,6 @@ virStorageFileGetNPIVKey; virStorageFileGetSCSIKey; virStorageFileParseBackingStoreStr; virStorageFileParseChainIndex; -virStorageIsFile; -virStorageIsRelative; # util/virstring.h diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index 23d36507ea..df9fb6c055 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -45,6 +45,40 @@ VIR_LOG_INIT("storage_source"); +static bool +virStorageSourceBackinStoreStringIsFile(const char *backing) +{ + char *colon; + char *slash; + + if (!backing) + return false; + + colon =3D strchr(backing, ':'); + slash =3D strchr(backing, '/'); + + /* Reject anything that looks like a protocol (such as nbd: or + * rbd:); if someone really does want a relative file name that + * includes ':', they can always prefix './'. */ + if (colon && (!slash || colon < slash)) + return false; + return true; +} + + +static bool +virStorageSourceBackinStoreStringIsRelative(const char *backing) +{ + if (backing[0] =3D=3D '/') + return false; + + if (!virStorageSourceBackinStoreStringIsFile(backing)) + return false; + + return true; +} + + static virStorageSourcePtr virStorageSourceMetadataNew(const char *path, int format) @@ -185,7 +219,7 @@ virStorageSourceChainLookup(virStorageSourcePtr chain, { virStorageSourcePtr prev; const char *start =3D chain->path; - bool nameIsFile =3D virStorageIsFile(name); + bool nameIsFile =3D virStorageSourceBackinStoreStringIsFile(name); if (!parent) parent =3D &prev; @@ -1532,7 +1566,7 @@ virStorageSourceNewFromBackingAbsolute(const char *pa= th, *src =3D NULL; - if (virStorageIsFile(path)) { + if (virStorageSourceBackinStoreStringIsFile(path)) { def->type =3D VIR_STORAGE_TYPE_FILE; def->path =3D g_strdup(path); @@ -1604,7 +1638,7 @@ virStorageSourceNewFromChild(virStorageSourcePtr pare= nt, *child =3D NULL; - if (virStorageIsRelative(parentRaw)) { + if (virStorageSourceBackinStoreStringIsRelative(parentRaw)) { if (!(def =3D virStorageSourceNewFromBackingRelative(parent, paren= tRaw))) return -1; } else { @@ -1927,7 +1961,7 @@ virStorageSourceFetchRelativeBackingPath(virStorageSo= urcePtr src, if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0) return -1; - if (virStorageIsRelative(tmp->backingStoreRaw)) + if (virStorageSourceBackinStoreStringIsRelative(tmp->backingStoreRaw)) *relPath =3D g_steal_pointer(&tmp->backingStoreRaw); return 0; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 85ccd9f52c..d1e56db708 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -37,40 +37,6 @@ VIR_LOG_INIT("util.storagefile"); -bool -virStorageIsFile(const char *backing) -{ - char *colon; - char *slash; - - if (!backing) - return false; - - colon =3D strchr(backing, ':'); - slash =3D strchr(backing, '/'); - - /* Reject anything that looks like a protocol (such as nbd: or - * rbd:); if someone really does want a relative file name that - * includes ':', they can always prefix './'. */ - if (colon && (!slash || colon < slash)) - return false; - return true; -} - - -bool -virStorageIsRelative(const char *backing) -{ - if (backing[0] =3D=3D '/') - return false; - - if (!virStorageIsFile(backing)) - return false; - - return true; -} - - #ifdef WITH_UDEV /* virStorageFileGetSCSIKey * @path: Path to the SCSI device diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2c1a250f20..455a978a8d 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -33,9 +33,6 @@ int virStorageFileParseBackingStoreStr(const char *str, unsigned int *chainIndex) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); -bool virStorageIsFile(const char *path); -bool virStorageIsRelative(const char *backing); - int virStorageFileGetSCSIKey(const char *path, char **key, bool ignoreError); --=20 2.29.2