[gnome-boxes] Don't wait for domain creation event
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Don't wait for domain creation event
- Date: Sat, 17 Mar 2012 00:24:18 +0000 (UTC)
commit 1cb59a584d87b0e6230c86b3d8693e652dce35fd
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sun Mar 11 22:59:17 2012 +0200
Don't wait for domain creation event
libvirt doesn't seem to be very reliable on prolonged sessions so the
lesser we depend on it, the better. This patch is mainly a work-around
for a very hard to debug/reproduce libvirt issue: It stops sending
domain events after libvirtd has been running for a long time (where the
definition of 'long time' doesn't seem to be predictable).
OTOH, this patch doesn't do any harm and actually reduces the time it
takes before user hitting 'create' button in wizard and new machine
appearing in the collection view.
https://bugzilla.gnome.org/show_bug.cgi?id=671847
src/app.vala | 15 ++++++++++++---
src/wizard.vala | 3 ++-
2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 94e2b26..f459a4f 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -48,7 +48,9 @@ private class Boxes.App: Boxes.UI {
private CollectionView view;
private HashTable<string,GVir.Connection> connections;
+ private HashTable<string,CollectionSource> sources;
public GVir.Connection default_connection { get { return connections.get ("QEMU Session"); } }
+ public CollectionSource default_source { get { return sources.get ("QEMU Session"); } }
private uint configure_id;
public static const uint configure_id_timeout = 100; // 100ms
@@ -57,6 +59,7 @@ private class Boxes.App: Boxes.UI {
application = new Gtk.Application ("org.gnome.Boxes", 0);
settings = new GLib.Settings ("org.gnome.boxes");
connections = new HashTable<string, GVir.Connection> (str_hash, str_equal);
+ sources = new HashTable<string,CollectionSource> (str_hash, str_equal);
var action = new GLib.SimpleAction ("quit", null);
action.activate.connect (() => { quit (); });
@@ -146,8 +149,10 @@ private class Boxes.App: Boxes.UI {
view.category = category;
}
- private void add_domain (CollectionSource source,
- GVir.Connection connection, GVir.Domain domain) {
+ public void add_domain (CollectionSource source, GVir.Connection connection, GVir.Domain domain) {
+ if (domain.get_data<LibvirtMachine> ("machine") != null)
+ return; // Already added
+
try {
var machine = new LibvirtMachine (source, this, connection, domain);
collection.add_item (machine);
@@ -176,8 +181,11 @@ private class Boxes.App: Boxes.UI {
}
connections.insert (source.name, connection);
- if (source.name == "QEMU Session")
+ sources.insert (source.name, source);
+ if (source.name == "QEMU Session") {
notify_property ("default-connection");
+ notify_property ("default-source");
+ }
foreach (var domain in connection.get_domains ())
add_domain (source, connection, domain);
@@ -192,6 +200,7 @@ private class Boxes.App: Boxes.UI {
});
connection.domain_added.connect ((connection, domain) => {
+ debug ("New domain '%s'", domain.get_name ());
add_domain (source, connection, domain);
});
}
diff --git a/src/wizard.vala b/src/wizard.vala
index 02ae434..8b21409 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -148,7 +148,8 @@ private class Boxes.Wizard: Boxes.UI {
next_button.sensitive = false;
try {
- yield vm_creator.create_and_launch_vm (install_media, null);
+ var domain = yield vm_creator.create_and_launch_vm (install_media, null);
+ app.add_domain (app.default_source, app.default_connection, domain);
} catch (IOError.CANCELLED cancel_error) { // We did this, so ignore!
} catch (GLib.Error error) {
warning (error.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]