|
|
fbe740 |
From 80cb87e61c8e48d2714c9369c14a880352114d20 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <80cb87e61c8e48d2714c9369c14a880352114d20@dist-git>
|
|
|
fbe740 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Date: Fri, 28 Feb 2020 10:24:37 +0100
|
|
|
fbe740 |
Subject: [PATCH] util: storage: Store backing store format in virStorageSource
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
We store the backing file string in the structure so we should also
|
|
|
fbe740 |
store the format so that callers can be simplified.
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit 62539c5f7d6a994b9cbd677564e7206cab1c5a45)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1798148
|
|
|
fbe740 |
Message-Id: <6f884591ac16f32370925bdb7746c655c7c87302.1582881363.git.pkrempa@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/util/virstoragefile.c | 35 +++++++++++++++++------------------
|
|
|
fbe740 |
src/util/virstoragefile.h | 1 +
|
|
|
fbe740 |
2 files changed, 18 insertions(+), 18 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
|
fbe740 |
index 391e2ce86f..d594ee3695 100644
|
|
|
fbe740 |
--- a/src/util/virstoragefile.c
|
|
|
fbe740 |
+++ b/src/util/virstoragefile.c
|
|
|
fbe740 |
@@ -935,15 +935,11 @@ virStorageFileGetEncryptionPayloadOffset(const struct FileEncryptionInfo *info,
|
|
|
fbe740 |
static int
|
|
|
fbe740 |
virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
fbe740 |
char *buf,
|
|
|
fbe740 |
- size_t len,
|
|
|
fbe740 |
- int *backingFormat)
|
|
|
fbe740 |
+ size_t len)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
- int dummy;
|
|
|
fbe740 |
+ int format;
|
|
|
fbe740 |
size_t i;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (!backingFormat)
|
|
|
fbe740 |
- backingFormat = &dummy;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
VIR_DEBUG("path=%s, buf=%p, len=%zu, meta->format=%d",
|
|
|
fbe740 |
meta->path, buf, len, meta->format);
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -1009,8 +1005,10 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
fbe740 |
VIR_FREE(meta->backingStoreRaw);
|
|
|
fbe740 |
if (fileTypeInfo[meta->format].getBackingStore != NULL) {
|
|
|
fbe740 |
int store = fileTypeInfo[meta->format].getBackingStore(&meta->backingStoreRaw,
|
|
|
fbe740 |
- backingFormat,
|
|
|
fbe740 |
+ &format,
|
|
|
fbe740 |
buf, len);
|
|
|
fbe740 |
+ meta->backingStoreRawFormat = format;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
if (store == BACKING_STORE_INVALID)
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -1135,20 +1133,18 @@ virStorageFileGetMetadataFromBuf(const char *path,
|
|
|
fbe740 |
int *backingFormat)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
virStorageSourcePtr ret = NULL;
|
|
|
fbe740 |
- int dummy;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- if (!backingFormat)
|
|
|
fbe740 |
- backingFormat = &dummy;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (!(ret = virStorageFileMetadataNew(path, format)))
|
|
|
fbe740 |
return NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (virStorageFileGetMetadataInternal(ret, buf, len,
|
|
|
fbe740 |
- backingFormat) < 0) {
|
|
|
fbe740 |
+ if (virStorageFileGetMetadataInternal(ret, buf, len) < 0) {
|
|
|
fbe740 |
virObjectUnref(ret);
|
|
|
fbe740 |
return NULL;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
+ if (backingFormat)
|
|
|
fbe740 |
+ *backingFormat = ret->backingStoreRawFormat;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
return ret;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -1211,9 +1207,12 @@ virStorageFileGetMetadataFromFD(const char *path,
|
|
|
fbe740 |
return NULL;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (virStorageFileGetMetadataInternal(meta, buf, len, backingFormat) < 0)
|
|
|
fbe740 |
+ if (virStorageFileGetMetadataInternal(meta, buf, len) < 0)
|
|
|
fbe740 |
return NULL;
|
|
|
fbe740 |
|
|
|
fbe740 |
+ if (backingFormat)
|
|
|
fbe740 |
+ *backingFormat = meta->backingStoreRawFormat;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
if (S_ISREG(sb.st_mode))
|
|
|
fbe740 |
meta->type = VIR_STORAGE_TYPE_FILE;
|
|
|
fbe740 |
else if (S_ISBLK(sb.st_mode))
|
|
|
fbe740 |
@@ -2293,6 +2292,7 @@ virStorageSourceCopy(const virStorageSource *src,
|
|
|
fbe740 |
def->volume = g_strdup(src->volume);
|
|
|
fbe740 |
def->relPath = g_strdup(src->relPath);
|
|
|
fbe740 |
def->backingStoreRaw = g_strdup(src->backingStoreRaw);
|
|
|
fbe740 |
+ def->backingStoreRawFormat = src->backingStoreRawFormat;
|
|
|
fbe740 |
def->externalDataStoreRaw = g_strdup(src->externalDataStoreRaw);
|
|
|
fbe740 |
def->snapshot = g_strdup(src->snapshot);
|
|
|
fbe740 |
def->configFile = g_strdup(src->configFile);
|
|
|
fbe740 |
@@ -5000,7 +5000,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
|
|
|
fbe740 |
unsigned int depth)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
size_t headerLen;
|
|
|
fbe740 |
- int backingFormat;
|
|
|
fbe740 |
int rv;
|
|
|
fbe740 |
g_autofree char *buf = NULL;
|
|
|
fbe740 |
g_autoptr(virStorageSource) backingStore = NULL;
|
|
|
fbe740 |
@@ -5018,7 +5017,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
|
|
|
fbe740 |
&buf, &headerLen, cycle) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (virStorageFileGetMetadataInternal(src, buf, headerLen, &backingFormat) < 0)
|
|
|
fbe740 |
+ if (virStorageFileGetMetadataInternal(src, buf, headerLen) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (src->backingStoreRaw) {
|
|
|
fbe740 |
@@ -5029,7 +5028,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
|
|
|
fbe740 |
if (rv == 1)
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
|
|
|
fbe740 |
- backingStore->format = backingFormat;
|
|
|
fbe740 |
+ backingStore->format = src->backingStoreRawFormat;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (backingStore->format == VIR_STORAGE_FILE_AUTO) {
|
|
|
fbe740 |
/* Assuming the backing store to be raw can lead to failures. We do
|
|
|
fbe740 |
@@ -5180,7 +5179,7 @@ virStorageFileGetBackingStoreStr(virStorageSourcePtr src,
|
|
|
fbe740 |
if (!(tmp = virStorageSourceCopy(src, false)))
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (virStorageFileGetMetadataInternal(tmp, buf, headerLen, NULL) < 0)
|
|
|
fbe740 |
+ if (virStorageFileGetMetadataInternal(tmp, buf, headerLen) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
*backing = g_steal_pointer(&tmp->backingStoreRaw);
|
|
|
fbe740 |
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
|
|
|
fbe740 |
index 2a684fd746..ecba418bb3 100644
|
|
|
fbe740 |
--- a/src/util/virstoragefile.h
|
|
|
fbe740 |
+++ b/src/util/virstoragefile.h
|
|
|
fbe740 |
@@ -330,6 +330,7 @@ struct _virStorageSource {
|
|
|
fbe740 |
/* Name of the child backing store recorded in metadata of the
|
|
|
fbe740 |
* current file. */
|
|
|
fbe740 |
char *backingStoreRaw;
|
|
|
fbe740 |
+ virStorageFileFormat backingStoreRawFormat;
|
|
|
fbe740 |
/* Name of the child data file recorded in metadata of the current file. */
|
|
|
fbe740 |
char *externalDataStoreRaw;
|
|
|
fbe740 |
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.25.1
|
|
|
fbe740 |
|