Skip to content
This repository has been archived by the owner on Apr 26, 2020. It is now read-only.

Commit

Permalink
Add Kill method to org.qubes.Domain interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kalkin committed Jun 20, 2017
1 parent 5f3796c commit b445722
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion qubesdbus/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ def Shutdown(self):
vm.shutdown()
return True

@dbus.service.method("org.qubes.Domain", out_signature="b")
def Kill(self):
app = qubesadmin.Qubes()
name = str(self.name)
vm = app.domains[name]
vm.kill()
return True

@dbus.service.method("org.qubes.Domain", out_signature="b")
def Start(self):
app = qubesadmin.Qubes()
Expand All @@ -85,7 +93,7 @@ def valid_state_change(cur_state: DBusString, state: DBusString) -> bool:
* UNKNOWN → [STARTED|HALTING] — workaround Transient state bug
* FAILED → STARTING
* HALTED → STARTING
* STARTING → [FAILED|STARTED]
* STARTING → [FAILED|STARTED|HALTED]
* STARTED → [FAILED|HALTING]
* HALTING → [FAILED|HALTED]
''' # pylint: disable=too-many-boolean-expressions
Expand All @@ -101,6 +109,7 @@ def valid_state_change(cur_state: DBusString, state: DBusString) -> bool:
or (cur_state == 'Failed' and state == 'Starting')\
or (cur_state == 'Halted' and state == 'Starting')\
or (cur_state == 'Starting' and state == 'Started')\
or (cur_state == 'Starting' and state == 'Halted')\
or (cur_state == 'Started' and state == 'Halting')\
or (cur_state == 'Halting' and state == 'Halted'):
return True
Expand Down

0 comments on commit b445722

Please sign in to comment.