[gnome-boxes] Do vm removal async
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Do vm removal async
- Date: Mon, 27 Aug 2012 14:31:18 +0000 (UTC)
commit 6c9995d2cad451de6bbbf8356aa4331d967667fb
Author: Alexander Larsson <alexl redhat com>
Date: Mon Aug 27 15:13:34 2012 +0200
Do vm removal async
This can be a pretty expensive operation if it deletes files
and all the calls are sync, so we do them in a thread.
https://bugzilla.gnome.org/show_bug.cgi?id=682792
src/libvirt-machine.vala | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index a2ee3b3..cc96e84 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -380,18 +380,26 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
set_stats_enable (false);
if (by_user) {
- force_shutdown (false);
-
- try {
- if (connection == App.app.default_connection) {
- var volume = get_storage_volume (connection, domain, null);
+ GVir.StorageVol? volume = null;
+ if (connection == App.app.default_connection)
+ volume = get_storage_volume (connection, domain, null);
+ var domain = this.domain; // Don't reference self in thread
+
+ /* Run all the slow operations in a separate thread
+ to avoid blocking the UI */
+ run_in_thread.begin ( () => {
+ try {
+ // This undefines the domain, causing it to be transient
+ domain.delete (DomainDeleteFlags.SAVED_STATE);
+ // Ensure that the domain is stopped before we touch any data
+ domain.stop (0);
+ // Remove any images controlled by boxes
if (volume != null)
volume.delete (0);
+ } catch (GLib.Error err) {
+ warning (err.message);
}
- domain.delete (DomainDeleteFlags.SAVED_STATE);
- } catch (GLib.Error err) {
- warning (err.message);
- }
+ });
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]