From nobody Sun Feb 8 17:47:25 2026 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=1582293149; cv=none; d=zohomail.com; s=zohoarc; b=QYz7TtBSbV+3+neVspqX+CRtfk3wtC/sghOsMRyEwqJdw1DRS3r0z/wbQDXNagcwywvROS2W1MyjftS3UgmBwYY3PK+7dxp2KssS6JKxRyxRz8NJiZMVmmHtBr1acuf6YzQMgrzCBeJ/2CzWct6L4v8cxQioZEa6gSEg4K9ywJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582293149; 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=0dbdS7/pMB2Hb9FXhoKnledL44mZPwTBWSl1gYwH338=; b=NoRCzKXUjFERz713J+eBpc7HsWKc4MWXX/jXyUniPBTgc9vJ2u2LkQhvhI08eUUYL3yMVDZsQjANiQC3vDdQfuZ+A+HgOIRiiAF++0GW2OKuTW6bgg2141yUewpCXhem99p3hdJxMAhiBcJln6lZSgsbdQRF33URALDeerHZ2TM= 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 1582293149449669.0236106443883; Fri, 21 Feb 2020 05:52:29 -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-304-iTfAqKFNOeWLN_YrrJdjLw-1; Fri, 21 Feb 2020 08:52:26 -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 C16F618CA26D; Fri, 21 Feb 2020 13:52:20 +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 9C8EF84BCC; Fri, 21 Feb 2020 13:52:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4EFB51832DAA; Fri, 21 Feb 2020 13:52:20 +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 01LDptea032502 for ; Fri, 21 Feb 2020 08:51:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8FD5F5D9C5; Fri, 21 Feb 2020 13:51:55 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13CED5DA7C for ; Fri, 21 Feb 2020 13:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582293148; 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=0dbdS7/pMB2Hb9FXhoKnledL44mZPwTBWSl1gYwH338=; b=S9YZxCcznNGsm78BYm7POYdXaI6g5WediSDJSF6JQED0CkMT4k+QUSDgmf7nqy93k5GmkH dmzrbImsqXjsrpuLvCEubD7stX8+AYWRMHj7NQk5jV/oWfGjsXQ6SfvyAYCPHX6yg446Qk 5PlXdo75xyGsvDH4rVuC58mZn3P/ZqE= X-MC-Unique: iTfAqKFNOeWLN_YrrJdjLw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] util: storage: Store backing store format in virStorageSource Date: Fri, 21 Feb 2020 14:51:41 +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.11 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" We store the backing file string in the structure so we should also store the format so that callers can be simplified. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 35 +++++++++++++++++------------------ src/util/virstoragefile.h | 1 + 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index cc351e3f53..2d8fe59c25 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -935,15 +935,11 @@ virStorageFileGetEncryptionPayloadOffset(const struct= FileEncryptionInfo *info, static int virStorageFileGetMetadataInternal(virStorageSourcePtr meta, char *buf, - size_t len, - int *backingFormat) + size_t len) { - int dummy; + int format; size_t i; - if (!backingFormat) - backingFormat =3D &dummy; - VIR_DEBUG("path=3D%s, buf=3D%p, len=3D%zu, meta->format=3D%d", meta->path, buf, len, meta->format); @@ -1009,8 +1005,10 @@ virStorageFileGetMetadataInternal(virStorageSourcePt= r meta, VIR_FREE(meta->backingStoreRaw); if (fileTypeInfo[meta->format].getBackingStore !=3D NULL) { int store =3D fileTypeInfo[meta->format].getBackingStore(&meta->ba= ckingStoreRaw, - backingForm= at, + &format, buf, len); + meta->backingStoreRawFormat =3D format; + if (store =3D=3D BACKING_STORE_INVALID) return 0; @@ -1135,20 +1133,18 @@ virStorageFileGetMetadataFromBuf(const char *path, int *backingFormat) { virStorageSourcePtr ret =3D NULL; - int dummy; - - if (!backingFormat) - backingFormat =3D &dummy; if (!(ret =3D virStorageFileMetadataNew(path, format))) return NULL; - if (virStorageFileGetMetadataInternal(ret, buf, len, - backingFormat) < 0) { + if (virStorageFileGetMetadataInternal(ret, buf, len) < 0) { virObjectUnref(ret); return NULL; } + if (backingFormat) + *backingFormat =3D ret->backingStoreRawFormat; + return ret; } @@ -1211,9 +1207,12 @@ virStorageFileGetMetadataFromFD(const char *path, return NULL; } - if (virStorageFileGetMetadataInternal(meta, buf, len, backingFormat) <= 0) + if (virStorageFileGetMetadataInternal(meta, buf, len) < 0) return NULL; + if (backingFormat) + *backingFormat =3D meta->backingStoreRawFormat; + if (S_ISREG(sb.st_mode)) meta->type =3D VIR_STORAGE_TYPE_FILE; else if (S_ISBLK(sb.st_mode)) @@ -2293,6 +2292,7 @@ virStorageSourceCopy(const virStorageSource *src, def->volume =3D g_strdup(src->volume); def->relPath =3D g_strdup(src->relPath); def->backingStoreRaw =3D g_strdup(src->backingStoreRaw); + def->backingStoreRawFormat =3D src->backingStoreRawFormat; def->externalDataStoreRaw =3D g_strdup(src->externalDataStoreRaw); def->snapshot =3D g_strdup(src->snapshot); def->configFile =3D g_strdup(src->configFile); @@ -5000,7 +5000,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, unsigned int depth) { size_t headerLen; - int backingFormat; int rv; g_autofree char *buf =3D NULL; g_autoptr(virStorageSource) backingStore =3D NULL; @@ -5018,7 +5017,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, &buf, &headerLen, cycle= ) < 0) return -1; - if (virStorageFileGetMetadataInternal(src, buf, headerLen, &backingFor= mat) < 0) + if (virStorageFileGetMetadataInternal(src, buf, headerLen) < 0) return -1; if (src->backingStoreRaw) { @@ -5029,7 +5028,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr = src, if (rv =3D=3D 1) return 0; - backingStore->format =3D backingFormat; + backingStore->format =3D src->backingStoreRawFormat; if (backingStore->format =3D=3D VIR_STORAGE_FILE_AUTO) { /* Assuming the backing store to be raw can lead to failures. = We do @@ -5180,7 +5179,7 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr = src, if (!(tmp =3D virStorageSourceCopy(src, false))) return -1; - if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0) + if (virStorageFileGetMetadataInternal(tmp, buf, headerLen) < 0) return -1; *backing =3D g_steal_pointer(&tmp->backingStoreRaw); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 2a684fd746..ecba418bb3 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -330,6 +330,7 @@ struct _virStorageSource { /* Name of the child backing store recorded in metadata of the * current file. */ char *backingStoreRaw; + virStorageFileFormat backingStoreRawFormat; /* Name of the child data file recorded in metadata of the current fil= e. */ char *externalDataStoreRaw; --=20 2.24.1