render / rpms / libvirt

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