[gnome-boxes] libvirt-machine: Cancel ongoing tasks on shutdown



commit 56da378c9da7fea13022488b8b9b07fec9955c81
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Dec 16 16:40:15 2021 +0100

    libvirt-machine: Cancel ongoing tasks on shutdown
    
    If the user is importing/creating a VM and turns it off, it indicates
    that they want to cancel the task.

 src/libvirt-machine.vala | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 93b6bf24..72897702 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -394,10 +394,18 @@ public async void suspend () throws GLib.Error {
             domain.suspend ();
     }
 
+    private void cancel_vm_creation () {
+        vm_creator = null;
+    }
+
     public void force_shutdown () {
         debug ("Force shutdown '%s'..", name);
         try {
             force_stopped = true;
+
+            if (vm_creator != null)
+                cancel_vm_creation ();
+
             domain.stop (0);
         } catch (GLib.Error error) {
             warning ("Failed to shutdown '%s': %s", domain.get_name (), error.message);
@@ -407,6 +415,9 @@ public void force_shutdown () {
     public void try_shutdown () {
         try {
             domain.shutdown (0);
+
+            if (vm_creator != null)
+                cancel_vm_creation ();
         } catch (GLib.Error error) {
             warning ("Failed to reboot '%s': %s", domain.get_name (), error.message);
         }


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