[gnome-boxes] Avoid blocking call in disk stats



commit 78fde27c098d2c6b7e8bcd845deafd03ed19e9ac
Author: Alexander Larsson <alexl redhat com>
Date:   Wed May 2 17:04:34 2012 +0200

    Avoid blocking call in disk stats
    
    domain.get_devices () does a blocking get_config() call, but we already have a
    copy of the config. Use that instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675663

 src/libvirt-machine.vala |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index d28e2cc..80df148 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -380,16 +380,16 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         var disk = null as GVir.DomainDisk;
         var volume = get_storage_volume (connection, domain, null);
 
-        foreach (var device in domain.get_devices ()) {
-            if (device is GVir.DomainDisk) {
-                var disk_config = device.config as GVirConfig.DomainDisk;
+        foreach (var device_config in domain_config.get_devices ()) {
+            if (device_config is GVirConfig.DomainDisk) {
+                var disk_config = device_config as GVirConfig.DomainDisk;
                 var disk_type = disk_config.get_guest_device_type ();
                 var volume_path = (volume != null)? volume.get_path () : null;
                 var disk_source = (volume != null)? disk_config.get_source () : null;
 
                 // Prefer Boxes' managed volume over other disks
                 if (disk_type == GVirConfig.DomainDiskGuestDeviceType.DISK && volume_path == disk_source) {
-                    disk = device as GVir.DomainDisk;
+                    disk = Object.new (typeof (GVir.DomainDisk), "domain", domain, "config", device_config) as GVir.DomainDisk;
 
                     break;
                 }



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