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

[libvirt] [PATCH 8/9] storage: Implement CreateVolFrom for logical and disk backend.



With the previous refactoring, this is a simple process, since the global
'CreateBlockFrom' in storage_backend does all the work.
---
 src/storage_backend_disk.c    |   15 +++++++++++++++
 src/storage_backend_logical.c |   17 +++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/storage_backend_disk.c b/src/storage_backend_disk.c
index eb694a7..1eb3eac 100644
--- a/src/storage_backend_disk.c
+++ b/src/storage_backend_disk.c
@@ -587,6 +587,20 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
     return 0;
 }
 
+static int
+virStorageBackendDiskBuildVolFrom(virConnectPtr conn,
+                                  virStorageVolDefPtr vol,
+                                  virStorageVolDefPtr inputvol,
+                                  unsigned int flags)
+{
+    virStorageBackendBuildVolFrom build_func;
+
+    build_func = virStorageBackendGetBuildVolFromFunction(conn, vol, inputvol);
+    if (!build_func)
+        return -1;
+
+    return build_func(conn, vol, inputvol, flags);
+}
 
 static int
 virStorageBackendDiskDeleteVol(virConnectPtr conn,
@@ -655,4 +669,5 @@ virStorageBackend virStorageBackendDisk = {
 
     .createVol = virStorageBackendDiskCreateVol,
     .deleteVol = virStorageBackendDiskDeleteVol,
+    .buildVolFrom = virStorageBackendDiskBuildVolFrom,
 };
diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index 1bd00d4..6c123ae 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -654,6 +654,21 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
 }
 
 static int
+virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
+                                     virStorageVolDefPtr vol,
+                                     virStorageVolDefPtr inputvol,
+                                     unsigned int flags)
+{
+    virStorageBackendBuildVolFrom build_func;
+
+    build_func = virStorageBackendGetBuildVolFromFunction(conn, vol, inputvol);
+    if (!build_func)
+        return -1;
+
+    return build_func(conn, vol, inputvol, flags);
+}
+
+static int
 virStorageBackendLogicalDeleteVol(virConnectPtr conn,
                                   virStoragePoolObjPtr pool ATTRIBUTE_UNUSED,
                                   virStorageVolDefPtr vol,
@@ -679,6 +694,8 @@ virStorageBackend virStorageBackendLogical = {
     .refreshPool = virStorageBackendLogicalRefreshPool,
     .stopPool = virStorageBackendLogicalStopPool,
     .deletePool = virStorageBackendLogicalDeletePool,
+    .buildVol = NULL,
+    .buildVolFrom = virStorageBackendLogicalBuildVolFrom,
     .createVol = virStorageBackendLogicalCreateVol,
     .deleteVol = virStorageBackendLogicalDeleteVol,
 };
-- 
1.6.0.6


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