[PATCH 07/15] storage file: fill in src->dataFileStore during file probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Nikolai Barybin <nikolai.barybin@xxxxxxxxxxxxx>
---
 src/storage_file/storage_source.c | 39 +++++++++++++++++++++++++++++++
 src/storage_file/storage_source.h |  4 ++++
 2 files changed, 43 insertions(+)

diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c
index 2cfe3bc325..b9d2d71aea 100644
--- a/src/storage_file/storage_source.c
+++ b/src/storage_file/storage_source.c
@@ -543,6 +543,33 @@ virStorageSourceNewFromBacking(virStorageSource *parent,
 }
 
 
+/**
+ * virStorageSourceNewFromDataFile:
+ * @parent: storage source parent
+ * @dataFileSrc: returned data file source definition
+ *
+ * Creates a storage source which describes the data file image of @parent.
+ * Returned storage source format is VIR_STORAGE_FILE_RAW, and, unlike
+ * backing storage creation, readonly flag is copied from @parent.
+ *
+ * Return codes are the same as in virStorageSourceNewFromChild.
+ */
+int
+virStorageSourceNewFromDataFile(virStorageSource *parent,
+                                virStorageSource **dataFileSrc)
+{
+    if (virStorageSourceNewFromChild(parent,
+                                     parent->dataFileRaw,
+                                     dataFileSrc) < 0)
+        return -1;
+
+    (*dataFileSrc)->format = VIR_STORAGE_FILE_RAW;
+    (*dataFileSrc)->readonly = parent->readonly;
+
+    return 0;
+}
+
+
 /**
  * @src: disk source definition structure
  * @fd: file descriptor
@@ -1391,6 +1418,18 @@ virStorageSourceGetMetadataRecurse(virStorageSource *src,
         }
     }
 
+    if (src->dataFileRaw) {
+        g_autoptr(virStorageSource) dataFileStore = NULL;
+        if ((rv = virStorageSourceNewFromDataFile(src, &dataFileStore)) < 0)
+            return -1;
+
+        /* the data file would not be usable for VM usage */
+        if (rv == 1)
+            return 0;
+
+        src->dataFileStore = g_steal_pointer(&dataFileStore);
+    }
+
     if (src->backingStoreRaw) {
         if ((rv = virStorageSourceNewFromBacking(src, &backingStore)) < 0)
             return -1;
diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_source.h
index 63fefb6919..78b31e405a 100644
--- a/src/storage_file/storage_source.h
+++ b/src/storage_file/storage_source.h
@@ -72,6 +72,10 @@ int
 virStorageSourceNewFromBacking(virStorageSource *parent,
                                virStorageSource **backing);
 
+int
+virStorageSourceNewFromDataFile(virStorageSource *parent,
+                                virStorageSource **dataFileSrc);
+
 int
 virStorageSourceGetRelativeBackingPath(virStorageSource *top,
                                        virStorageSource *base,
-- 
2.43.5



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux