After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 685846 - Live VMs gets deleted automatically even on forced shutdowns
Live VMs gets deleted automatically even on forced shutdowns
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: installer
unspecified
Other All
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
: 688263 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-10-09 22:01 UTC by Zeeshan Ali
Modified: 2016-03-31 14:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libvirt-machine: API to indicate forced shutdown (2.47 KB, patch)
2012-10-09 22:01 UTC, Zeeshan Ali
reviewed Details | Review
vm-creator: Correctly handle forced shutdowns (1.20 KB, patch)
2012-10-09 22:01 UTC, Zeeshan Ali
reviewed Details | Review
libvirt-machine: API to indicate forced shutdown (1.83 KB, patch)
2012-10-10 14:19 UTC, Zeeshan Ali
committed Details | Review
vm-creator: Correctly handle forced shutdowns (1.17 KB, patch)
2012-10-10 14:19 UTC, Zeeshan Ali
committed Details | Review
libvirt-machine: More use of new is_on() predicate (1.39 KB, patch)
2012-10-10 14:20 UTC, Zeeshan Ali
committed Details | Review
Handle screenshots correctly on FORCE_STOPPED (1.37 KB, patch)
2012-10-31 13:37 UTC, Alexander Larsson
committed Details | Review

Description Zeeshan Ali 2012-10-09 22:01:51 UTC
While its desirable to automatically delete live VMs on normal shutdown if nothing is installed during the live run, its pprobably not the desired behavior when VM is forced shutdown.

Attaching patches that fix this issue.
Comment 1 Zeeshan Ali 2012-10-09 22:01:53 UTC
Created attachment 226146 [details] [review]
libvirt-machine: API to indicate forced shutdown

Add a public boolean field to indicate if last shutdown was forced.
Comment 2 Zeeshan Ali 2012-10-09 22:01:56 UTC
Created attachment 226147 [details] [review]
vm-creator: Correctly handle forced shutdowns

Don't do any post-installation checks on a machine if its forced to
shutdown. This is not only the right thing to do but it also solves the
issue of live VMs getting automatically deleted on forced shutdown.
Comment 3 Christophe Fergeau 2012-10-10 09:12:31 UTC
Review of attachment 226146 [details] [review]:

Shouldn't this be an additional MachineState rather than adding a boolean to update every time the state change?
Comment 4 Christophe Fergeau 2012-10-10 09:13:38 UTC
Review of attachment 226147 [details] [review]:

::: src/vm-creator.vala
@@ +97,3 @@
         }
 
+        if (machine.state == Machine.MachineState.STOPPED && machine.last_shutdown_forced)

if (machine.state == Machine.MachineState.FORCED_STOPPED)
   return;

would look better imo.
Comment 5 Zeeshan Ali 2012-10-10 14:19:00 UTC
Created attachment 226174 [details] [review]
libvirt-machine: API to indicate forced shutdown

Add a new machine state enum to indicate if last shutdown was forced.
Comment 6 Zeeshan Ali 2012-10-10 14:19:29 UTC
Created attachment 226175 [details] [review]
vm-creator: Correctly handle forced shutdowns

Don't do any post-installation checks on a machine if its forced to
shutdown. This is not only the right thing to do but it also solves the
issue of live VMs getting automatically deleted on forced shutdown.
Comment 7 Zeeshan Ali 2012-10-10 14:20:14 UTC
Created attachment 226176 [details] [review]
libvirt-machine: More use of new is_on() predicate

We don't tell user to reboot the box if machine is exactly in 'stopped'
state. We probably want to apply that to all off states.

A bit unrelated to his bug but small one so too lazy to file a new one for it. :)
Comment 8 Marc-Andre Lureau 2012-10-11 06:49:36 UTC
Review of attachment 226174 [details] [review]:

::: src/machine.vala
@@ +35,3 @@
         SAVED,
+        SLEEPING,
+        FORCE_STOPPED

nitpick, it would be nicer to add it close to STOPPED
Comment 9 Christophe Fergeau 2012-10-11 10:06:16 UTC
Review of attachment 226174 [details] [review]:

ACK from me if Marc-André's comments are addressed.
Comment 10 Christophe Fergeau 2012-10-11 10:06:32 UTC
Review of attachment 226175 [details] [review]:

Looks good.
Comment 11 Christophe Fergeau 2012-10-11 10:14:52 UTC
Review of attachment 226176 [details] [review]:

::: src/libvirt-machine.vala
@@ +534,2 @@
             this.notify["state"].connect (() => {
+                if (!is_on ())

ACK to this one

@@ +596,3 @@
             ulong state_id = 0;
             state_id = this.notify["state"].connect (() => {
+                if (!is_on ()) {

This one is more surprising, it's meant to catch the end of the 'shutdown' call further down this function, so STOPPED seems like the right check to have.
Comment 12 Zeeshan Ali 2012-10-11 14:09:13 UTC
Attachment 226174 [details] pushed as 7e86dde - libvirt-machine: API to indicate forced shutdown
Attachment 226175 [details] pushed as 6551a33 - vm-creator: Correctly handle forced shutdowns
Attachment 226176 [details] pushed as 8a7b1ab - libvirt-machine: More use of new is_on() predicate
Comment 13 Alexander Larsson 2012-10-31 13:37:55 UTC
Created attachment 227728 [details] [review]
Handle screenshots correctly on FORCE_STOPPED

This should be handled just like STOPPED. Without this we get
shaded screenshots instead of black screenshots when you force-stop
a box.
Comment 14 Alexander Larsson 2012-10-31 13:38:18 UTC
reopening due to regression, see patch above.
Comment 15 Zeeshan Ali 2012-10-31 13:49:18 UTC
Review of attachment 227728 [details] [review]:

ACK
Comment 16 Alexander Larsson 2012-10-31 13:55:03 UTC
Attachment 227728 [details] pushed as 526cd07 - Handle screenshots correctly on FORCE_STOPPED
Comment 17 Tobias Mueller 2013-06-09 11:39:39 UTC
*** Bug 688263 has been marked as a duplicate of this bug. ***