Blob Blame History Raw
From 7bb256eb1ec8549b0902bfa921b8984c9a0bf50d Mon Sep 17 00:00:00 2001
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
Date: Thu, 13 Mar 2014 15:56:32 +0000
Subject: [PATCH 2/2] libvirt-machine-props: Refresh volume info after resize

For running machines, we make use of special libvirt API that operates
on GVir.DomainDisk rather than GVir.StorageVol and its the latter Boxes
reads current capacity info from (actually there is no way to read
capacity from GVir.DomainDisk) so what happens is that when you change the
capacity of a running machine, get out of properties and back again,
you find the capacity to remain unchanged even though the actual
capacity was changed.

This patch fixes the issue by refreshing the storage pool and refetching
the volume info after changing the capacity through GVir.DomainDisk.resize.

Conflicts:
	src/libvirt-machine-properties.vala
---
 src/libvirt-machine-properties.vala | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 97dcd85..458fed3 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -569,11 +569,26 @@ private void on_storage_changed (Boxes.Property property, uint64 value) {
                     if (disk != null) {
                         var size = (value + Osinfo.KIBIBYTES - 1) / Osinfo.KIBIBYTES;
                         disk.resize (size, 0);
+
+                        var pool = get_storage_pool (machine.connection);
+                        pool.refresh_async.begin (null, (obj, res) => {
+                            try {
+                                pool.refresh_async.end (res);
+                                machine.update_domain_config ();
+                                debug ("Storage changed to %llu KiB", size);
+                            } catch (GLib.Error error) {
+                                warning ("Failed to change storage capacity of volume '%s' to %llu KiB: %s",
+                                         machine.storage_volume.get_name (),
+                                         size,
+                                         error.message);
+                            }
+                        });
                     }
-                } else
+                } else {
                     // Currently this never happens as properties page cant be reached without starting the machine
                     machine.storage_volume.resize (value, StorageVolResizeFlags.NONE);
-                debug ("Storage changed to %llu", value);
+                    debug ("Storage changed to %llu", value);
+                }
             } catch (GLib.Error error) {
                 warning ("Failed to change storage capacity of volume '%s' to %llu: %s",
                          machine.storage_volume.get_name (),
-- 
2.1.0