Skip to content

Commit 6e953b3

Browse files
committed
Add option to use --force in qui-domains shutdown
If a VM cannot be shut down normally, ask the user if they want to force a shutdown. fixes QubesOS/qubes-issues#10029
1 parent 2614254 commit 6e953b3

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

qui/tray/domains.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,33 @@ async def perform_action(self):
206206
try:
207207
self.vm.shutdown()
208208
except exc.QubesException as ex:
209-
show_error(
210-
_("Error shutting down qube"),
211-
_(
212-
"The following error occurred while attempting to "
213-
"shut down qube {0}:\n{1}"
214-
).format(self.vm.name, str(ex)),
209+
dialog = Gtk.MessageDialog(
210+
None, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK_CANCEL
215211
)
212+
dialog.set_title("Error shutting down qube")
213+
dialog.set_markup(
214+
f"The qube {self.vm.name} couldn't be shut down "
215+
"normally. The following error occurred: \n"
216+
f"<tt>{str(ex)}</tt>\n\n"
217+
"Do you want to force shutdown? \n\n<b>Warning:</b> "
218+
"this may cause unexpected issues in connected qubes."
219+
)
220+
dialog.connect("response", self.react_to_question)
221+
GLib.idle_add(dialog.show)
222+
223+
def react_to_question(self, widget, response):
224+
if response == Gtk.ResponseType.OK:
225+
try:
226+
self.vm.shutdown(force=True)
227+
except exc.QubesException as ex:
228+
show_error(
229+
_("Error shutting down qube"),
230+
_(
231+
"The following error occurred while attempting to "
232+
"shut down qube {0}:\n{1}"
233+
).format(self.vm.name, str(ex)),
234+
)
235+
widget.destroy()
216236

217237

218238
class RestartItem(VMActionMenuItem):

0 commit comments

Comments
 (0)