[gnome-boxes] libvirt-machine: API to indicate forced shutdown
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] libvirt-machine: API to indicate forced shutdown
- Date: Thu, 11 Oct 2012 14:09:02 +0000 (UTC)
commit 7e86dde845d493ce233d44cd3a0506f6da169506
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Oct 10 00:50:59 2012 +0300
libvirt-machine: API to indicate forced shutdown
Add a new machine state enum to indicate if last shutdown was forced.
https://bugzilla.gnome.org/show_bug.cgi?id=685846
src/libvirt-machine.vala | 4 ++++
src/machine.vala | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index e0007dc..c5975ea 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -119,6 +119,9 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
domain.suspended.connect (() => { state = MachineState.PAUSED; });
domain.resumed.connect (() => { state = MachineState.RUNNING; });
domain.stopped.connect (() => {
+ if (state == MachineState.FORCE_STOPPED)
+ return; // State already set by us when machine is forced to shutdown
+
if (Signal.get_invocation_hint (this.domain).detail == Quark.from_string ("saved"))
state = MachineState.SAVED;
else
@@ -454,6 +457,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
debug ("Force shutdown '%s'..", name);
try {
+ state = MachineState.FORCE_STOPPED;
domain.stop (0);
} catch (GLib.Error error) {
warning ("Failed to shutdown '%s': %s", domain.get_name (), error.message);
diff --git a/src/machine.vala b/src/machine.vala
index 103e91b..d8ade95 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -30,6 +30,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
public enum MachineState {
UNKNOWN,
STOPPED,
+ FORCE_STOPPED,
RUNNING,
PAUSED,
SAVED,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]