Add a force reset item to all shutdown menus

This commit is contained in:
John Doyle 2013-03-16 17:59:32 -04:00 committed by Cole Robinson
parent 507640ea85
commit 9f4fddba04
8 changed files with 80 additions and 1 deletions

View File

@ -88,6 +88,7 @@ Further patches have been submitted by:
ChenHanxiao <chenhanxiao-at-cn-dot-fujitsu-dot-com>
David Shane Holden <dpejesh@yahoo.com>
Dave Allan <dallan@redhat.com>
John Doyle <spdubhghaill@gmail.com>
<...send a patch & get your name here...>

View File

@ -390,6 +390,7 @@ class vmmDetails(vmmGObjectUI):
"on_details_menu_poweroff_activate": self.control_vm_shutdown,
"on_details_menu_reboot_activate": self.control_vm_reboot,
"on_details_menu_save_activate": self.control_vm_save,
"on_details_menu_reset_activate": self.control_vm_reset,
"on_details_menu_destroy_activate": self.control_vm_destroy,
"on_details_menu_pause_activate": self.control_vm_pause,
"on_details_menu_clone_activate": self.control_vm_clone,
@ -614,12 +615,14 @@ class vmmDetails(vmmGObjectUI):
uihelpers.build_shutdown_button_menu(self.widget("control-shutdown"),
self.control_vm_shutdown,
self.control_vm_reboot,
self.control_vm_reset,
self.control_vm_destroy,
self.control_vm_save)
icon_name = self.config.get_shutdown_icon_name()
for name in ["details-menu-shutdown",
"details-menu-reboot",
"details-menu-reset",
"details-menu-poweroff",
"details-menu-destroy"]:
image = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
@ -1562,6 +1565,10 @@ class vmmDetails(vmmGObjectUI):
self.emit("action-save-domain",
self.vm.conn.get_uri(), self.vm.get_uuid())
def control_vm_reset(self, src_ignore):
self.emit("action-reset-domain",
self.vm.conn.get_uri(), self.vm.get_uuid())
def control_vm_destroy(self, src_ignore):
self.emit("action-destroy-domain",
self.vm.conn.get_uri(), self.vm.get_uuid())
@ -3673,6 +3680,7 @@ class vmmDetails(vmmGObjectUI):
vmmGObjectUI.type_register(vmmDetails)
vmmDetails.signal_new(vmmDetails, "action-save-domain", [str, str])
vmmDetails.signal_new(vmmDetails, "action-destroy-domain", [str, str])
vmmDetails.signal_new(vmmDetails, "action-reset-domain", [str, str])
vmmDetails.signal_new(vmmDetails, "action-suspend-domain", [str, str])
vmmDetails.signal_new(vmmDetails, "action-resume-domain", [str, str])
vmmDetails.signal_new(vmmDetails, "action-run-domain", [str, str])

View File

@ -1144,6 +1144,11 @@ class vmmDomain(vmmLibvirtObject):
self._backend.destroy()
self.idle_add(self.force_update_status)
def reset(self):
self._install_abort = True
self._backend.reset(0)
self.idle_add(self.force_update_status)
def startup(self):
if self.get_cloning():
raise RuntimeError(_("Cannot start guest while cloning "

View File

@ -129,6 +129,7 @@ class vmmEngine(vmmGObject):
self.systray.connect("action-shutdown-domain", self._do_shutdown_domain)
self.systray.connect("action-reboot-domain", self._do_reboot_domain)
self.systray.connect("action-destroy-domain", self._do_destroy_domain)
self.systray.connect("action-reset-domain", self._do_reset_domain)
self.systray.connect("action-show-vm", self._do_show_vm)
self.systray.connect("action-exit-app", self.exit_app)
@ -575,6 +576,7 @@ class vmmEngine(vmmGObject):
obj = vmmDetails(con.get_vm(uuid))
obj.connect("action-save-domain", self._do_save_domain)
obj.connect("action-destroy-domain", self._do_destroy_domain)
obj.connect("action-reset-domain", self._do_reset_domain)
obj.connect("action-show-help", self._do_show_help)
obj.connect("action-suspend-domain", self._do_suspend_domain)
obj.connect("action-resume-domain", self._do_resume_domain)
@ -624,6 +626,7 @@ class vmmEngine(vmmGObject):
obj.connect("action-shutdown-domain", self._do_shutdown_domain)
obj.connect("action-reboot-domain", self._do_reboot_domain)
obj.connect("action-destroy-domain", self._do_destroy_domain)
obj.connect("action-reset-domain", self._do_reset_domain)
obj.connect("action-save-domain", self._do_save_domain)
obj.connect("action-migrate-domain", self._do_show_migrate)
obj.connect("action-clone-domain", self._do_show_clone)
@ -962,6 +965,22 @@ class vmmEngine(vmmGObject):
vmmAsyncJob.simple_async_noshow(reboot_cb, [], src, "")
def _do_reset_domain(self, src, uri, uuid):
conn = self._lookup_conn(uri)
vm = conn.get_vm(uuid)
if not util.chkbox_helper(src, self.config.get_confirm_forcepoweroff,
self.config.set_confirm_forcepoweroff,
text1=_("Are you sure you want to force reset '%s'?" %
vm.get_name()),
text2=_("This will immediately reset the VM without "
"shutting down the OS and may cause data loss.")):
return
logging.debug("Resetting vm '%s'", vm.get_name())
vmmAsyncJob.simple_async_noshow(vm.reset, [], src,
_("Error resetting domain"))
vmmGObject.type_register(vmmEngine)
vmmEngine.signal_new(vmmEngine, "conn-added", [object])
vmmEngine.signal_new(vmmEngine, "conn-removed", [str])

View File

@ -265,6 +265,7 @@ class vmmManager(vmmGObjectUI):
uihelpers.build_shutdown_button_menu(self.widget("vm-shutdown"),
self.poweroff_vm,
self.reboot_vm,
self.reset_vm,
self.destroy_vm,
self.save_vm)
@ -285,6 +286,7 @@ class vmmManager(vmmGObjectUI):
reboot_icon = build_icon(icon_name)
shutdown_icon = build_icon(icon_name)
destroy_icon = build_icon(icon_name)
reset_icon = build_icon(icon_name)
run_icon = build_stock(gtk.STOCK_MEDIA_PLAY)
pause_icon = build_stock(gtk.STOCK_MEDIA_PAUSE)
save_icon = build_stock(gtk.STOCK_SAVE)
@ -325,6 +327,8 @@ class vmmManager(vmmGObjectUI):
add_shutdown_menu("reboot", _("_Reboot"), reboot_icon, self.reboot_vm)
add_shutdown_menu("poweroff", _("_Shut Down"), shutdown_icon,
self.poweroff_vm)
add_shutdown_menu("forcereset", _("_Force Reset"), reset_icon,
self.reset_vm)
add_shutdown_menu("forcepoweroff", _("_Force Off"), destroy_icon,
self.destroy_vm)
add_sep(self.vmmenushutdown, self.vmmenushutdown_items, "sep")
@ -610,6 +614,12 @@ class vmmManager(vmmGObjectUI):
self.emit("action-destroy-domain",
vm.conn.get_uri(), vm.get_uuid())
def reset_vm(self, ignore):
vm = self.current_vm()
if vm is not None:
self.emit("action-reset-domain",
vm.conn.get_uri(), vm.get_uuid())
def save_vm(self, ignore):
vm = self.current_vm()
if vm is not None:
@ -1234,6 +1244,7 @@ vmmManager.signal_new(vmmManager, "action-run-domain", [str, str])
vmmManager.signal_new(vmmManager, "action-shutdown-domain", [str, str])
vmmManager.signal_new(vmmManager, "action-reboot-domain", [str, str])
vmmManager.signal_new(vmmManager, "action-destroy-domain", [str, str])
vmmManager.signal_new(vmmManager, "action-reset-domain", [str, str])
vmmManager.signal_new(vmmManager, "action-save-domain", [str, str])
vmmManager.signal_new(vmmManager, "action-connect", [str])
vmmManager.signal_new(vmmManager, "action-show-help", [str])

View File

@ -187,6 +187,13 @@ class vmmSystray(vmmGObject):
"action-shutdown-domain", vm.get_uuid())
shutdown_item.show()
reset_item = gtk.ImageMenuItem(_("_Force Reset"))
reset_img = gtk.image_new_from_icon_name(stop_icon, icon_size)
reset_item.set_image(reset_img)
reset_item.show()
reset_item.connect("activate", self.run_vm_action,
"action-reset-domain", vm.get_uuid())
destroy_item = gtk.ImageMenuItem(_("_Force Off"))
destroy_img = gtk.image_new_from_icon_name(stop_icon, icon_size)
destroy_item.set_image(destroy_img)
@ -197,6 +204,7 @@ class vmmSystray(vmmGObject):
shutdown_menu = gtk.Menu()
shutdown_menu.add(reboot_item)
shutdown_menu.add(shutdown_item)
shutdown_menu.add(reset_item)
shutdown_menu.add(destroy_item)
shutdown_menu_item = gtk.ImageMenuItem(_("_Shut Down"))
shutdown_menu_img = gtk.image_new_from_icon_name(stop_icon, icon_size)
@ -217,6 +225,7 @@ class vmmSystray(vmmGObject):
vm_action_dict["shutdown_menu"] = shutdown_menu_item
vm_action_dict["reboot"] = reboot_item
vm_action_dict["shutdown"] = shutdown_item
vm_action_dict["reset"] = reset_item
vm_action_dict["destroy"] = destroy_item
vm_action_dict["sep"] = sep
vm_action_dict["open"] = open_item
@ -406,6 +415,7 @@ class vmmSystray(vmmGObject):
actions["shutdown_menu"].set_sensitive(vm.is_active())
actions["shutdown"].set_sensitive(vm.is_stoppable())
actions["reboot"].set_sensitive(vm.is_stoppable())
actions["reset"].set_sensitive(vm.is_destroyable())
actions["destroy"].set_sensitive(vm.is_destroyable())
actions["pause"].set_property("visible", not is_paused)
@ -434,6 +444,7 @@ vmmSystray.signal_new(vmmSystray, "action-resume-domain", [str, str])
vmmSystray.signal_new(vmmSystray, "action-run-domain", [str, str])
vmmSystray.signal_new(vmmSystray, "action-shutdown-domain", [str, str])
vmmSystray.signal_new(vmmSystray, "action-reboot-domain", [str, str])
vmmSystray.signal_new(vmmSystray, "action-reset-domain", [str, str])
vmmSystray.signal_new(vmmSystray, "action-destroy-domain", [str, str])
vmmSystray.signal_new(vmmSystray, "action-show-host", [str])
vmmSystray.signal_new(vmmSystray, "action-show-vm", [str, str])

View File

@ -840,7 +840,7 @@ def mediadev_set_default_selection(widget):
# Build toolbar shutdown button menu (manager and details toolbar) #
####################################################################
def build_shutdown_button_menu(widget, shutdown_cb, reboot_cb,
def build_shutdown_button_menu(widget, shutdown_cb, reboot_cb, reset_cb,
destroy_cb, save_cb):
icon_name = util.running_config.get_shutdown_icon_name()
widget.set_icon_name(icon_name)
@ -849,6 +849,7 @@ def build_shutdown_button_menu(widget, shutdown_cb, reboot_cb,
rebootimg = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
shutdownimg = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
resetimg = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
destroyimg = gtk.image_new_from_icon_name(icon_name, gtk.ICON_SIZE_MENU)
saveimg = gtk.image_new_from_icon_name(gtk.STOCK_SAVE, gtk.ICON_SIZE_MENU)
@ -864,6 +865,12 @@ def build_shutdown_button_menu(widget, shutdown_cb, reboot_cb,
shutdown.connect("activate", shutdown_cb)
menu.add(shutdown)
reset = gtk.ImageMenuItem(_("_Force Reset"))
reset.set_image(resetimg)
reset.show()
reset.connect("activate", reset_cb)
menu.add(reset)
destroy = gtk.ImageMenuItem(_("_Force Off"))
destroy.set_image(destroyimg)
destroy.show()

View File

@ -110,6 +110,11 @@
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkImage" id="image178">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkWindow" id="vmm-details">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Virtual Machine</property>
@ -250,6 +255,18 @@
<signal name="activate" handler="on_details_menu_poweroff_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="details-menu-reset">
<property name="label" translatable="yes">F_orce Reset</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="image">image178</property>
<property name="use_stock">False</property>
<signal name="activate" handler="on_details_menu_reset_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="details-menu-destroy">
<property name="label" translatable="yes">_Force Off</property>