[gnome-boxes] libvirt-broker: Make add_domain async



commit bc7e215edcc27b23649864e8f250d5b174d5319b
Author: Timm Bäder <mail baedert org>
Date:   Fri Sep 12 18:05:17 2014 +0200

    libvirt-broker: Make add_domain async
    
    ... and in turn, some of the other private functions in LibvirtBroker.
    This will later be necessary when we adjust the domain's cpu mode when
    adding it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735685

 src/libvirt-broker.vala |   16 ++++++++--------
 src/vm-creator.vala     |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/libvirt-broker.vala b/src/libvirt-broker.vala
index af4adf2..a5bdb7b 100644
--- a/src/libvirt-broker.vala
+++ b/src/libvirt-broker.vala
@@ -22,8 +22,8 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
         return broker.connections.get (name);
     }
 
-    public LibvirtMachine add_domain (CollectionSource source, GVir.Connection connection, GVir.Domain 
domain)
-                                      throws GLib.Error {
+    public async LibvirtMachine add_domain (CollectionSource source, GVir.Connection connection, GVir.Domain 
domain)
+                                            throws GLib.Error {
         return_if_fail (broker != null);
 
         var machine = domain.get_data<LibvirtMachine> ("machine");
@@ -39,18 +39,18 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
     }
 
     // New == Added after Boxes launch
-    private void try_add_new_domain (CollectionSource source, GVir.Connection connection, GVir.Domain 
domain) {
+    private async void try_add_new_domain (CollectionSource source, GVir.Connection connection, GVir.Domain 
domain) {
         try {
-            add_domain (source, connection, domain);
+            yield add_domain (source, connection, domain);
         } catch (GLib.Error error) {
             warning ("Failed to create source '%s': %s", source.name, error.message);
         }
     }
 
     // Existing == Existed before Boxes was launched
-    private void try_add_existing_domain (CollectionSource source, GVir.Connection connection, GVir.Domain 
domain) {
+    private async void try_add_existing_domain (CollectionSource source, GVir.Connection connection, 
GVir.Domain domain) {
         try {
-            var machine = add_domain (source, connection, domain);
+            var machine = yield add_domain (source, connection, domain);
             var config = machine.domain_config;
 
             // These instance will take care of their own lifecycles
@@ -93,7 +93,7 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
         connections.insert (source.name, connection);
 
         foreach (var domain in connection.get_domains ())
-            try_add_existing_domain (source, connection, domain);
+            yield try_add_existing_domain (source, connection, domain);
 
         connection.domain_removed.connect ((connection, domain) => {
             var machine = domain.get_data<LibvirtMachine> ("machine");
@@ -105,7 +105,7 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
 
         connection.domain_added.connect ((connection, domain) => {
             debug ("New domain '%s'", domain.get_name ());
-            try_add_new_domain (source, connection, domain);
+            try_add_new_domain.begin (source, connection, domain);
         });
 
         yield base.add_source (source);
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index ae066b2..6be3859 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -55,9 +55,9 @@ private class Boxes.VMCreator {
         var config = yield create_domain_config (name, title, volume, cancellable);
         var domain = connection.create_domain (config);
 
-        var machine = LibvirtBroker.get_default ().add_domain (App.app.default_source,
-                                                               App.app.default_connection,
-                                                               domain);
+        var machine = yield LibvirtBroker.get_default ().add_domain (App.app.default_source,
+                                                                     App.app.default_connection,
+                                                                     domain);
         machine.vm_creator = this;
 
         return machine;


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