[PATCH] storage: zfs: implement pool build and delete

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

 



Provide an implementation for buildPool and deletePool operations for
the ZFS storage backend.
---
 docs/schemas/storagepool.rng      |  1 +
 src/storage/storage_backend_zfs.c | 57 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 908cc11..da8e1f3 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -386,6 +386,7 @@
     <element name='source'>
       <interleave>
         <ref name='sourceinfoname'/>
+        <ref name='sourceinfodev'/>
       </interleave>
     </element>
   </define>
diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c
index d8201ac..9482706 100644
--- a/src/storage/storage_backend_zfs.c
+++ b/src/storage/storage_backend_zfs.c
@@ -325,6 +325,61 @@ virStorageBackendZFSDeleteVol(virConnectPtr conn ATTRIBUTE_UNUSED,
     return ret;
 }
 
+static int
+virStorageBackendZFSBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
+                              virStoragePoolObjPtr pool,
+                              unsigned int flags)
+{
+    virCommandPtr cmd = NULL;
+    size_t i;
+    int ret = -1;
+
+    virCheckFlags(0, -1);
+
+    if (pool->def->source.ndevice == 0) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       "%s", _("missing source devices"));
+        return -1;
+    }
+
+    cmd = virCommandNewArgList(ZPOOL, "create",
+                               pool->def->source.name, NULL);
+
+    for (i = 0; i < pool->def->source.ndevice; i++)
+        virCommandAddArg(cmd, pool->def->source.devices[i].path);
+
+    if (virCommandRun(cmd, NULL) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    virCommandFree(cmd);
+    return ret;
+}
+
+static int
+virStorageBackendZFSDeletePool(virConnectPtr conn ATTRIBUTE_UNUSED,
+                               virStoragePoolObjPtr pool,
+                               unsigned int flags)
+{
+    virCommandPtr cmd = NULL;
+    int ret = -1;
+
+    virCheckFlags(0, -1);
+
+    cmd = virCommandNewArgList(ZPOOL, "destroy",
+                               pool->def->source.name, NULL);
+
+    if (virCommandRun(cmd, NULL) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    virCommandFree(cmd);
+    return ret;
+}
 
 virStorageBackend virStorageBackendZFS = {
     .type = VIR_STORAGE_POOL_ZFS,
@@ -333,6 +388,8 @@ virStorageBackend virStorageBackendZFS = {
     .refreshPool = virStorageBackendZFSRefreshPool,
     .createVol = virStorageBackendZFSCreateVol,
     .deleteVol = virStorageBackendZFSDeleteVol,
+    .buildPool = virStorageBackendZFSBuildPool,
+    .deletePool = virStorageBackendZFSDeletePool,
     .uploadVol = virStorageBackendVolUploadLocal,
     .downloadVol = virStorageBackendVolDownloadLocal,
 };
-- 
2.0.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]