---
 libvirt-gobject/libvirt-gobject-storage-vol.c |   75 +++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-storage-vol.h |   14 +++++
 libvirt-gobject/libvirt-gobject.h             |    1 +
 libvirt-gobject/libvirt-gobject.sym           |    2 +
 4 files changed, 92 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c 
b/libvirt-gobject/libvirt-gobject-storage-vol.c
index 6f60fcd..7f9aeb7 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -349,3 +349,78 @@ gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
 
     return TRUE;
 }
+
+/**
+ * gvir_storage_vol_download:
+ * @vol: the storage volume to download from
+ * @stream: stream to use as output
+ * @offset: position in @vol to start reading from
+ * @length: limit on amount of data to download
+ * @flags: extra flags, not used yet, pass 0
+ *
+ * Returns: #TRUE of success, #FALSE otherwise
+ */
+gboolean gvir_storage_vol_download(GVirStorageVol *vol,
+                                   GVirStream *stream,
+                                   unsigned long long offset,
+                                   unsigned long long length,
+                                   guint flags,
+                                   GError **err)
+{
+    virStreamPtr st = NULL;
+
+    g_object_get(stream, "handle", &st, NULL);
+
+    g_return_val_if_fail(GVIR_IS_STORAGE_VOL(vol), FALSE);
+    g_return_val_if_fail(GVIR_IS_STREAM(stream), FALSE);
+    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+
+    if(virStorageVolDownload(vol->priv->handle, st, offset, length, 0) < 0) {
+       gvir_set_error_literal(err,
+                              GVIR_STORAGE_VOL_ERROR,
+                              0,
+                              "Unable to downlaod volume storage");
+
+       return FALSE;
+    }
+
+    return TRUE;
+}
+
+/**
+ * gvir_storage_vol_upload:
+ * @vol: the storage volume to upload
+ * @stream: stream to use as input
+ * @offset: position in @vol to start to write to
+ * @length: limit on amount of data to upload
+ * @flags: the flags, not set yet, pass 0
+ *
+ * Returns: #TRUE of success, #FALSE otherwise
+ */
+gboolean gvir_storage_vol_upload(GVirStorageVol *vol,
+                                 GVirStream *stream,
+                                 unsigned long long offset,
+                                 unsigned long long length,
+                                 guint flags,
+                                 GError **err)
+{
+    virStreamPtr st = NULL;
+
+    g_object_get(stream, "handle", &st, NULL);
+
+    g_return_val_if_fail(GVIR_IS_STORAGE_VOL(vol), FALSE);
+    g_return_val_if_fail(GVIR_IS_STREAM(stream), FALSE);
+    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
+
+    if(virStorageVolUpload(vol->priv->handle, st, offset, length, 0) < 0) {
+       gvir_set_error_literal(err,
+                              GVIR_STORAGE_VOL_ERROR,
+                              0,
+                              "Unable to upload to stream");
+
+       return FALSE;
+    }
+
+    return TRUE;
+}
+
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.h 
b/libvirt-gobject/libvirt-gobject-storage-vol.h
index b425f0a..e156792 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.h
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.h
@@ -110,6 +110,20 @@ gboolean gvir_storage_vol_resize(GVirStorageVol *vol,
                                  guint flags,
                                  GError **err);
 
+gboolean gvir_storage_vol_download(GVirStorageVol *vol,
+                                   GVirStream *stream,
+                                   unsigned long long offset,
+                                   unsigned long long length,
+                                   guint flags,
+                                   GError **err);
+
+gboolean gvir_storage_vol_upload(GVirStorageVol *vol,
+                                 GVirStream *stream,
+                                 unsigned long long offset,
+                                 unsigned long long length,
+                                 guint flags,
+                                 GError **err);
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_STORAGE_VOL_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.h 
b/libvirt-gobject/libvirt-gobject.h
index f52cc00..b1158f7 100644
--- a/libvirt-gobject/libvirt-gobject.h
+++ b/libvirt-gobject/libvirt-gobject.h
@@ -44,5 +44,6 @@
 #include <libvirt-gobject/libvirt-gobject-storage-pool.h>
 #include <libvirt-gobject/libvirt-gobject-connection.h>
 #include <libvirt-gobject/libvirt-gobject-manager.h>
+#include <libvirt-gobject/libvirt-gobject-stream.h>
 
 #endif /* __LIBVIRT_GOBJECT_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index db32c7f..478881b 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -143,6 +143,8 @@ LIBVIRT_GOBJECT_0.0.8 {
        gvir_storage_vol_get_info;
        gvir_storage_vol_delete;
        gvir_storage_vol_resize;
+       gvir_storage_vol_download;
+       gvir_storage_vol_upload;
 
        gvir_connection_handle_get_type;
 
-- 
1.7.10.4

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

Reply via email to