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

David Allan dallan at redhat.com
Tue Mar 2 22:13:29 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..1434874 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -8468,6 +8468,53 @@ error:


 /**
+ * virStorageVolZeroOut:
+ * @vol: pointer to storage volume
+ * @flags: future flags, use 0 for now
+ *
+ * Ensure that future reads from the storage volume return zeroes.
+ *
+ * Returns 0 on success, or -1 on error
+ */
+int
+virStorageVolZeroOut(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->volZeroOut) {
+        int ret;
+        ret = conn->storageDriver->volZeroOut(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