[gnome-boxes/dont-clone-while-vm-running] actions-popover: Don't allow to "clone" when VM is running



commit 246fd5cdc82937bf99b6f4cba924bb9f60f20cb3
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Dec 18 13:18:55 2019 +0100

    actions-popover: Don't allow to "clone" when VM is running
    
    Cloning VMs consists of copying a VM's config XML into a new one
    and using qemu-img on its disk to copy/convert into the disk of
    the new VM.
    
    When a VM is running, qemu-img will yell:
    
    qemu-img" Could not open '<box-filename>': Failed to get shared "write" lock
    
    Closes #348

 src/actions-popover.vala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/actions-popover.vala b/src/actions-popover.vala
index 7d1e0cdd..f028bafa 100644
--- a/src/actions-popover.vala
+++ b/src/actions-popover.vala
@@ -72,9 +72,13 @@ public void update_for_item (CollectionItem item) {
 
         if (window.ui_state != UIState.DISPLAY) {
             // Clone
+            var can_clone = machine.can_clone;
+            if (machine is LibvirtMachine)
+                can_clone = can_clone && !machine.is_running;
+
             section.append (_("Clone"), "box.clone");
             var action = action_group.lookup_action ("clone") as GLib.SimpleAction;
-            action.set_enabled (machine.can_clone);
+            action.set_enabled (can_clone);
 
             // Delete
             section.append (_("Delete"), "box.delete");


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