[gnome-boxes] libvirt-machine: Set forced state from domain state change handler
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] libvirt-machine: Set forced state from domain state change handler
- Date: Thu, 8 Nov 2012 15:26:26 +0000 (UTC)
commit b43ad37abb8741e04397de564c208b2e7a31d0c9
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Nov 6 00:13:29 2012 +0100
libvirt-machine: Set forced state from domain state change handler
We should set the state only from the handler of underlying domain's
state change to avoid any race-conditions.
https://bugzilla.gnome.org/show_bug.cgi?id=673930
src/libvirt-machine.vala | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 752cb20..bfe4011 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -46,6 +46,9 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
static const int STATS_SIZE = 20;
private MachineStat[] stats;
+
+ private bool force_stopped;
+
construct {
stats = new MachineStat[STATS_SIZE];
stats_cancellable = new Cancellable ();
@@ -118,12 +121,12 @@ 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
+ else if (force_stopped) {
+ force_stopped = false;
+ state = MachineState.FORCE_STOPPED;
+ } else
state = MachineState.STOPPED;
});
domain.pmsuspended.connect (() => {
@@ -455,7 +458,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
debug ("Force shutdown '%s'..", name);
try {
- state = MachineState.FORCE_STOPPED;
+ force_stopped = true;
domain.stop (0);
} catch (GLib.Error error) {
warning ("Failed to shutdown '%s': %s", domain.get_name (), error.message);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]