[libvirt] [PATCH 4/9] Implement the public API for vol wiping

David Allan dallan at redhat.com
Thu Mar 4 22:25:30 UTC 2010


---
 src/libvirt.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index d9242bc..6abf74f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -8468,6 +8468,53 @@ error:


 /**
+ * virStorageVolWipe:
+ * @vol: pointer to storage volume
+ * @flags: future flags, use 0 for now
+ *
+ * Ensure data previously on a volume is not accessible to future reads
+ *
+ * Returns 0 on success, or -1 on error
+ */
+int
+virStorageVolWipe(virStorageVolPtr vol,
+                  unsigned int flags)
+{
+    virConnectPtr conn;
+    VIR_DEBUG("vol=%p, flags=%u", vol, flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_STORAGE_VOL(vol)) {
+        virLibStorageVolError(NULL, VIR_ERR_INVALID_STORAGE_VOL, __FUNCTION__);
+        virDispatchError(NULL);
+        return (-1);
+    }
+
+    conn = vol->conn;
+    if (conn->flags & VIR_CONNECT_RO) {
+        virLibStorageVolError(vol, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->storageDriver && conn->storageDriver->volWipe) {
+        int ret;
+        ret = conn->storageDriver->volWipe(vol, flags);
+        if (ret < 0) {
+            goto error;
+        }
+        return ret;
+    }
+
+    virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(vol->conn);
+    return -1;
+}
+
+
+/**
  * virStorageVolFree:
  * @vol: pointer to storage volume
  *
-- 
1.6.5.5




More information about the libvir-list mailing list