libvirt/SOURCES/libvirt-util-virstoragefile...

114 lines
3.4 KiB
Diff

From 57dfcbb6715008f731deb02b8964fca5f38fd2fc Mon Sep 17 00:00:00 2001
Message-Id: <57dfcbb6715008f731deb02b8964fca5f38fd2fc@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 19 Feb 2020 15:10:15 +0100
Subject: [PATCH] util: virstoragefile: Add data structure for storing storage
source slices
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Introduce virStorageSourceSlice which will store the 'offset' and 'size'
of a virStorageSource and declare it as 'sliceStorage' and 'sliceFormat'
attributes of a virStorageSource.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 6efa04616553c573700906cb7154a8ceb3bd2cb3)
https://bugzilla.redhat.com/show_bug.cgi?id=1791788
Message-Id: <c0e6db154dbb2087bd6dbcae2e232b61f36b7800.1582120424.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/virstoragefile.c | 29 +++++++++++++++++++++++++++++
src/util/virstoragefile.h | 12 ++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index b02fad92b6..0be4168d6e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2248,6 +2248,30 @@ virStorageSourcePoolDefCopy(const virStorageSourcePoolDef *src)
}
+static virStorageSourceSlicePtr
+virStorageSourceSliceCopy(const virStorageSourceSlice *src)
+{
+ virStorageSourceSlicePtr ret = g_new0(virStorageSourceSlice, 1);
+
+ ret->offset = src->offset;
+ ret->size = src->size;
+ ret->nodename = g_strdup(src->nodename);
+
+ return ret;
+}
+
+
+static void
+virStorageSourceSliceFree(virStorageSourceSlicePtr slice)
+{
+ if (!slice)
+ return;
+
+ g_free(slice->nodename);
+ g_free(slice);
+}
+
+
/**
* virStorageSourcePtr:
*
@@ -2302,6 +2326,9 @@ virStorageSourceCopy(const virStorageSource *src,
def->tlsAlias = g_strdup(src->tlsAlias);
def->tlsCertdir = g_strdup(src->tlsCertdir);
+ if (src->sliceStorage)
+ def->sliceStorage = virStorageSourceSliceCopy(src->sliceStorage);
+
if (src->nhosts) {
if (!(def->hosts = virStorageNetHostDefCopy(src->nhosts, src->hosts)))
return NULL;
@@ -2581,6 +2608,8 @@ virStorageSourceClear(virStorageSourcePtr def)
VIR_FREE(def->timestamps);
VIR_FREE(def->externalDataStoreRaw);
+ virStorageSourceSliceFree(def->sliceStorage);
+
virObjectUnref(def->externalDataStore);
def->externalDataStore = NULL;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 39e50a989d..1f41e6e357 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -242,6 +242,16 @@ struct _virStorageSourceNVMeDef {
/* Don't forget to update virStorageSourceNVMeDefCopy */
};
+
+typedef struct _virStorageSourceSlice virStorageSourceSlice;
+typedef virStorageSourceSlice *virStorageSourceSlicePtr;
+struct _virStorageSourceSlice {
+ unsigned long long offset;
+ unsigned long long size;
+ char *nodename;
+};
+
+
typedef struct _virStorageDriverData virStorageDriverData;
typedef virStorageDriverData *virStorageDriverDataPtr;
@@ -286,6 +296,8 @@ struct _virStorageSource {
bool nocow;
bool sparse;
+ virStorageSourceSlicePtr sliceStorage;
+
virStoragePermsPtr perms;
virStorageTimestampsPtr timestamps;
unsigned long long capacity; /* in bytes, 0 if unknown */
--
2.25.0