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

[libvirt] [libvirt-glib 2/6] Add gvir_domain_disk_resize()



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

Binding for virDomainBlockResize().
---
 libvirt-gobject/libvirt-gobject-domain-disk.c |   38 +++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain-disk.h |    4 ++
 libvirt-gobject/libvirt-gobject.sym           |    1 +
 3 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-domain-disk.c b/libvirt-gobject/libvirt-gobject-domain-disk.c
index f98d816..fb7672e 100644
--- a/libvirt-gobject/libvirt-gobject-domain-disk.c
+++ b/libvirt-gobject/libvirt-gobject-domain-disk.c
@@ -192,3 +192,41 @@ end:
     virDomainFree(handle);
     return ret;
 }
+
+/**
+ * gvir_domain_disk_resize:
+ * @self: the domain disk
+ * @size: new size of the block image in kilobytes
+ * @flags: flags, currently unused. Pass '0'.
+ * @err: placeholder for an error, or NULL
+ *
+ * This function resize the disk of a running domain.
+ *
+ * Returns: TRUE if size was successfully changed, FALSE otherwise.
+ **/
+gboolean gvir_domain_disk_resize(GVirDomainDisk *self,
+                                 guint64 size,
+                                 guint flags,
+                                 GError **err)
+{
+    gboolean ret = FALSE;
+    virDomainPtr handle;
+
+    g_return_val_if_fail(GVIR_IS_DOMAIN_DISK(self), FALSE);
+    g_return_val_if_fail(err == NULL || *err != NULL, FALSE);
+
+    handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self));
+
+    if (virDomainBlockResize(handle, self->priv->path, size, flags) < 0) {
+        gvir_set_error_literal(err, GVIR_DOMAIN_DISK_ERROR,
+                               0,
+                               "Failed to resize domain disk");
+        goto end;
+    }
+
+    ret = TRUE;
+
+end:
+    virDomainFree(handle);
+    return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain-disk.h b/libvirt-gobject/libvirt-gobject-domain-disk.h
index 21f2357..1788d63 100644
--- a/libvirt-gobject/libvirt-gobject-domain-disk.h
+++ b/libvirt-gobject/libvirt-gobject-domain-disk.h
@@ -72,6 +72,10 @@ GType gvir_domain_disk_get_type(void);
 GType gvir_domain_disk_stats_get_type(void);
 
 GVirDomainDiskStats *gvir_domain_disk_get_stats(GVirDomainDisk *self, GError **err);
+gboolean gvir_domain_disk_resize(GVirDomainDisk *self,
+                                 guint64 size,
+                                 guint flags,
+                                 GError **err);
 
 G_END_DECLS
 
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index 1ad6b53..5081f41 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -37,6 +37,7 @@ LIBVIRT_GOBJECT_0.0.4 {
 	gvir_domain_disk_get_type;
 	gvir_domain_disk_stats_get_type;
 	gvir_domain_disk_get_stats;
+	gvir_domain_disk_resize;
 
 	gvir_domain_interface_get_type;
 	gvir_domain_interface_stats_get_type;
-- 
1.7.7.6


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