[virt-tools-list] [virt-manager][PATCH ] Permit to delete a running VM.
Leonardo Garcia
lagarcia at linux.vnet.ibm.com
Tue Jun 18 03:29:20 UTC 2013
From: Leonardo Garcia <lagarcia at br.ibm.com>
The VM will be forced off before being deleted.
---
ui/vmm-delete.ui | 46 +++++++++++++++++++++++++++++++++++++++++++++-
ui/vmm-details.ui | 1 -
virtManager/console.py | 10 ++++++++--
virtManager/delete.py | 8 ++++++++
virtManager/details.py | 5 -----
virtManager/manager.py | 4 ----
6 files changed, 61 insertions(+), 13 deletions(-)
diff --git a/ui/vmm-delete.ui b/ui/vmm-delete.ui
index fa1e75e..7cbab36 100644
--- a/ui/vmm-delete.ui
+++ b/ui/vmm-delete.ui
@@ -116,6 +116,50 @@
</packing>
</child>
<child>
+ <object class="GtkAlignment" id="delete-warn-running-vm-align">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">6</property>
+ <child>
+ <object class="GtkHBox" id="delete-warn-running-vm-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">3</property>
+ <child>
+ <object class="GtkImage" id="delete-warn-running-vm-icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-dialog-warning</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="delete-warn-running-vm-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><small>This VM is currently running and will be forced off before being deleted</small></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="delete-remove-storage">
<property name="label" translatable="yes">Delete _associated storage files</property>
<property name="visible">True</property>
@@ -129,7 +173,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui
index c523372..ea4b53e 100644
--- a/ui/vmm-details.ui
+++ b/ui/vmm-details.ui
@@ -184,7 +184,6 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes">Virtual _Machine</property>
<property name="use_underline">True</property>
- <signal name="activate" handler="on_details_menu_vm" swapped="no"/>
<child type="submenu">
<object class="GtkMenu" id="virtual_machine1_menu">
<property name="can_focus">False</property>
diff --git a/virtManager/console.py b/virtManager/console.py
index b9186ce..001318e 100644
--- a/virtManager/console.py
+++ b/virtManager/console.py
@@ -651,7 +651,10 @@ class vmmConsolePages(vmmGObjectUI):
self.page_changed()
def is_visible(self):
- return self.topwin.get_visible()
+ if self.topwin:
+ return self.topwin.get_visible()
+ else:
+ return False
def _cleanup(self):
self.vm = None
@@ -892,6 +895,9 @@ class vmmConsolePages(vmmGObjectUI):
##########################
def view_vm_status(self):
+ if not self.vm:
+ # window has been closed and no pages to update are available.
+ return
status = self.vm.status()
if status == libvirt.VIR_DOMAIN_SHUTOFF:
self.activate_unavailable_page(_("Guest not running"))
@@ -900,7 +906,6 @@ class vmmConsolePages(vmmGObjectUI):
self.activate_unavailable_page(_("Guest has crashed"))
def close_viewer(self):
- viewport = self.widget("console-gfx-viewport")
if self.viewer is None:
return
@@ -908,6 +913,7 @@ class vmmConsolePages(vmmGObjectUI):
self.viewer = None
w = v.display
+ viewport = self.widget("console-gfx-viewport")
if w and w in viewport.get_children():
viewport.remove(w)
diff --git a/virtManager/delete.py b/virtManager/delete.py
index 2bb4480..23aac1b 100644
--- a/virtManager/delete.py
+++ b/virtManager/delete.py
@@ -99,6 +99,10 @@ class vmmDeleteDialog(vmmGObjectUI):
self.widget("delete-cancel").grab_focus()
+ # Show warning message if VM is running
+ vm_active = self.vm.is_active()
+ self.widget("delete-warn-running-vm-box").set_visible(vm_active)
+
# Disable storage removal by default
self.widget("delete-remove-storage").set_active(True)
self.widget("delete-remove-storage").toggled()
@@ -169,6 +173,10 @@ class vmmDeleteDialog(vmmGObjectUI):
details = ""
try:
+ if self.vm.is_active():
+ logging.debug("Forcing VM '%s' power off.", self.vm.get_name())
+ self.vm.destroy()
+
# Open a seperate connection to install on since this is async
logging.debug("Threading off connection to delete vol.")
newconn = util.dup_conn(self.conn).vmm
diff --git a/virtManager/details.py b/virtManager/details.py
index b40ea47..b2d496e 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -404,7 +404,6 @@ class vmmDetails(vmmGObjectUI):
"on_details_customize_finish_clicked": self.customize_finish,
"on_details_cancel_customize_clicked": self.close,
- "on_details_menu_vm": self.update_vm_menu,
"on_details_menu_run_activate": self.control_vm_run,
"on_details_menu_poweroff_activate": self.control_vm_shutdown,
"on_details_menu_reboot_activate": self.control_vm_reboot,
@@ -1551,10 +1550,6 @@ class vmmDetails(vmmGObjectUI):
self.vm.get_uuid())
- def update_vm_menu(self, src_ignore):
- delete = bool(self.vm and self.vm.is_runable())
- self.widget("details-menu-delete").set_sensitive(delete)
-
def control_vm_run(self, src_ignore):
self.emit("action-run-domain",
self.vm.conn.get_uri(), self.vm.get_uuid())
diff --git a/virtManager/manager.py b/virtManager/manager.py
index 6b6ceb1..b0cbb3b 100644
--- a/virtManager/manager.py
+++ b/virtManager/manager.py
@@ -1052,8 +1052,6 @@ class vmmManager(vmmGObjectUI):
show_details = bool(vm)
host_details = bool(len(self.rows))
- delete = bool((vm and vm.is_runable()) or
- (not vm and conn))
show_run = bool(vm and vm.is_runable())
is_paused = bool(vm and vm.is_paused())
if is_paused:
@@ -1073,7 +1071,6 @@ class vmmManager(vmmGObjectUI):
self.widget("menu_edit_details").set_sensitive(show_details)
self.widget("menu_host_details").set_sensitive(host_details)
- self.widget("menu_edit_delete").set_sensitive(delete)
def popup_vm_menu_key(self, widget_ignore, event):
if Gdk.keyval_name(event.keyval) != "Menu":
@@ -1118,7 +1115,6 @@ class vmmManager(vmmGObjectUI):
self.vmmenu_items["resume"].set_sensitive(paused)
self.vmmenu_items["migrate"].set_sensitive(stop)
self.vmmenu_items["clone"].set_sensitive(not ro)
- self.vmmenu_items["delete"].set_sensitive(run)
self.vmmenushutdown_items["poweroff"].set_sensitive(stop)
self.vmmenushutdown_items["reboot"].set_sensitive(stop)
--
1.7.1
More information about the virt-tools-list
mailing list