render / rpms / libvirt

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