mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-05-28 21:05:36 +03:00
details: Disable snapshot buttons if conn or guest doesn't have support
This commit is contained in:
parent
023953d4ac
commit
d44f863c2d
@ -356,6 +356,7 @@ test-many-devices, like an alternate RNG.
|
|||||||
<disk type='file' device='disk'>
|
<disk type='file' device='disk'>
|
||||||
<source file='/dev/default-pool/test-clone-simple.img'/>
|
<source file='/dev/default-pool/test-clone-simple.img'/>
|
||||||
<target dev='hda' bus='ide'/>
|
<target dev='hda' bus='ide'/>
|
||||||
|
<driver type="qcow2"/>
|
||||||
</disk>
|
</disk>
|
||||||
<interface type='user'>
|
<interface type='user'>
|
||||||
<mac address='22:11:11:11:11:11'/>
|
<mac address='22:11:11:11:11:11'/>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Generated with glade 3.16.0 on Mon Sep 30 15:08:28 2013 -->
|
<!-- Generated with glade 3.16.0 on Mon Sep 30 20:26:08 2013 -->
|
||||||
<interface>
|
<interface>
|
||||||
<!-- interface-requires gtk+ 3.0 -->
|
<!-- interface-requires gtk+ 3.0 -->
|
||||||
<object class="GtkAccelGroup" id="accelgroup1"/>
|
<object class="GtkAccelGroup" id="accelgroup1"/>
|
||||||
@ -391,7 +391,6 @@
|
|||||||
<object class="GtkRadioToolButton" id="control-snapshots">
|
<object class="GtkRadioToolButton" id="control-snapshots">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="tooltip_text" translatable="yes">Manage VM snapshots</property>
|
|
||||||
<property name="label" translatable="yes">Snapshots</property>
|
<property name="label" translatable="yes">Snapshots</property>
|
||||||
<property name="icon_name">vm_clone_wizard</property>
|
<property name="icon_name">vm_clone_wizard</property>
|
||||||
<property name="group">control-vm-console</property>
|
<property name="group">control-vm-console</property>
|
||||||
|
@ -1335,10 +1335,17 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
|
|
||||||
details = self.widget("details-pages")
|
details = self.widget("details-pages")
|
||||||
self.page_refresh(details.get_current_page())
|
self.page_refresh(details.get_current_page())
|
||||||
|
|
||||||
# This is safe to refresh, and is dependent on domain state
|
|
||||||
self._refresh_runtime_pinning()
|
self._refresh_runtime_pinning()
|
||||||
|
|
||||||
|
errmsg = self.vm.snapshots_supported()
|
||||||
|
cansnap = not bool(errmsg)
|
||||||
|
self.widget("control-snapshots").set_sensitive(cansnap)
|
||||||
|
self.widget("details-menu-view-snapshots").set_sensitive(cansnap)
|
||||||
|
tooltip = _("Manage VM snapshots")
|
||||||
|
if not cansnap:
|
||||||
|
tooltip += "\n" + errmsg
|
||||||
|
self.widget("control-snapshots").set_tooltip_text(tooltip)
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# External action listeners #
|
# External action listeners #
|
||||||
|
@ -242,7 +242,6 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
|
|
||||||
self.managedsave_supported = False
|
self.managedsave_supported = False
|
||||||
self.remote_console_supported = False
|
self.remote_console_supported = False
|
||||||
self.snapshots_supported = False
|
|
||||||
self.title_supported = False
|
self.title_supported = False
|
||||||
|
|
||||||
self._enable_net_poll = False
|
self._enable_net_poll = False
|
||||||
@ -265,16 +264,6 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
snap.cleanup()
|
snap.cleanup()
|
||||||
self._snapshot_list = None
|
self._snapshot_list = None
|
||||||
|
|
||||||
def _get_getvcpus_supported(self):
|
|
||||||
return self.conn.check_domain_support(self._backend,
|
|
||||||
self.conn.SUPPORT_DOMAIN_GETVCPUS)
|
|
||||||
getvcpus_supported = property(_get_getvcpus_supported)
|
|
||||||
|
|
||||||
def _get_getjobinfo_supported(self):
|
|
||||||
return self.conn.check_domain_support(self._backend,
|
|
||||||
self.conn.SUPPORT_DOMAIN_JOB_INFO)
|
|
||||||
getjobinfo_supported = property(_get_getjobinfo_supported)
|
|
||||||
|
|
||||||
def _libvirt_init(self):
|
def _libvirt_init(self):
|
||||||
"""
|
"""
|
||||||
Initialization to do if backed by a libvirt virDomain
|
Initialization to do if backed by a libvirt virDomain
|
||||||
@ -285,9 +274,6 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
self.remote_console_supported = self.conn.check_domain_support(
|
self.remote_console_supported = self.conn.check_domain_support(
|
||||||
self._backend,
|
self._backend,
|
||||||
self.conn.SUPPORT_DOMAIN_CONSOLE_STREAM)
|
self.conn.SUPPORT_DOMAIN_CONSOLE_STREAM)
|
||||||
self.snapshots_supported = self.conn.check_domain_support(
|
|
||||||
self._backend,
|
|
||||||
self.conn.SUPPORT_DOMAIN_LIST_SNAPSHOTS)
|
|
||||||
self.title_supported = self.conn.check_domain_support(
|
self.title_supported = self.conn.check_domain_support(
|
||||||
self._backend,
|
self._backend,
|
||||||
self.conn.SUPPORT_DOMAIN_GET_METADATA)
|
self.conn.SUPPORT_DOMAIN_GET_METADATA)
|
||||||
@ -405,6 +391,44 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
return "-"
|
return "-"
|
||||||
return str(i)
|
return str(i)
|
||||||
|
|
||||||
|
##################
|
||||||
|
# Support checks #
|
||||||
|
##################
|
||||||
|
|
||||||
|
def _get_getvcpus_supported(self):
|
||||||
|
return self.conn.check_domain_support(self._backend,
|
||||||
|
self.conn.SUPPORT_DOMAIN_GETVCPUS)
|
||||||
|
getvcpus_supported = property(_get_getvcpus_supported)
|
||||||
|
|
||||||
|
def _get_getjobinfo_supported(self):
|
||||||
|
return self.conn.check_domain_support(self._backend,
|
||||||
|
self.conn.SUPPORT_DOMAIN_JOB_INFO)
|
||||||
|
getjobinfo_supported = property(_get_getjobinfo_supported)
|
||||||
|
|
||||||
|
def snapshots_supported(self):
|
||||||
|
if not self.conn.check_domain_support(
|
||||||
|
self._backend, self.conn.SUPPORT_DOMAIN_LIST_SNAPSHOTS):
|
||||||
|
return _("Libvirt connection does not support snapshots.")
|
||||||
|
|
||||||
|
if self.list_snapshots():
|
||||||
|
return
|
||||||
|
|
||||||
|
# Check if our disks are all qcow2
|
||||||
|
seen_qcow2 = False
|
||||||
|
for disk in self.get_disk_devices(refresh_if_nec=False):
|
||||||
|
if disk.read_only:
|
||||||
|
continue
|
||||||
|
if not disk.path:
|
||||||
|
continue
|
||||||
|
if disk.driver_type == "qcow2":
|
||||||
|
seen_qcow2 = True
|
||||||
|
continue
|
||||||
|
return _("Snapshots are only supported if all writeable disks "
|
||||||
|
"images allocated to the guest are qcow2 format.")
|
||||||
|
if not seen_qcow2:
|
||||||
|
return _("Snapshots require at least one writeable qcow2 disk "
|
||||||
|
"image allocated to the guest.")
|
||||||
|
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Internal XML handling API #
|
# Internal XML handling API #
|
||||||
|
@ -155,11 +155,6 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||||||
model = self.widget("snapshot-list").get_model()
|
model = self.widget("snapshot-list").get_model()
|
||||||
model.clear()
|
model.clear()
|
||||||
|
|
||||||
if not self.vm.snapshots_supported:
|
|
||||||
self._set_error_page(_("Libvirt connection does not support "
|
|
||||||
"snapshots."))
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
snapshots = self.vm.list_snapshots()
|
snapshots = self.vm.list_snapshots()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user