virtManager: Remove max memory UI and memory hotplug support

This was proposed here:
https://www.redhat.com/archives/virt-tools-list/2019-June/msg00117.html

"""
* UI maxmem and maxcpu notions, and related memballoon and cpu hotplug
operations. These have been in the UI forever but I'm not sure people
actually use them. cpu hotplug has always been a mess, and unless the
user plans ahead by setting a high maxmem value ballooning is only good
for reducing memory. These all sound like advanced usage to me that
just confuses the typical usecase of adding more mem or vcpus to an
offline VM. And the hotplug operations with virsh are simple to invoke.
So I'd like to drop this from the UI
"""

The remaining field sets both max and current memory in the
inactive XML

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-01-25 15:25:16 -05:00
parent 0335c9ce62
commit 7547905d79
4 changed files with 16 additions and 159 deletions

View File

@ -103,19 +103,16 @@ class Details(uiutils.UITestCase):
appl.click()
uiutils.check_in_loop(lambda: not appl.sensitive)
# Memory balloon
tab = self._select_hw(win, "Memory", "memory-tab")
tab.find("Current allocation:", "spin button").text = "300"
# Newer libvirt rejects this hotplug operation for test driver
# tab.find("Maximum allocation:", "spin button").text = "800"
appl.click()
uiutils.check_in_loop(lambda: not appl.sensitive)
# There's no hotplug operations after this point
self._stop_vm(win)
# CPU hotplug
# Memory
tab = self._select_hw(win, "Memory", "memory-tab")
tab.find("Memory allocation:", "spin button").text = "300"
appl.click()
uiutils.check_in_loop(lambda: not appl.sensitive)
# VCPUs
tab = self._select_hw(win, "CPUs", "cpu-tab")
tab.find("VCPU allocation:", "spin button").text = "4"
appl.click()

View File

@ -2,13 +2,6 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">10240000</property>
<property name="value">50</property>
<property name="step_increment">1</property>
<property name="page_increment">25</property>
</object>
<object class="GtkAdjustment" id="adjustment16">
<property name="upper">10000000</property>
<property name="value">1000</property>
@ -1937,7 +1930,7 @@
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Current a_llocation:</property>
<property name="label" translatable="yes">Memory a_llocation:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">mem-memory</property>
</object>
@ -1946,21 +1939,6 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label307">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Ma_ximum allocation:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">mem-maxmem</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label61">
<property name="visible">True</property>
@ -2038,55 +2016,6 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="hbox47">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="spacing">3</property>
<child>
<object class="GtkSpinButton" id="mem-maxmem">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
<property name="text" translatable="yes">50</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">2</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
<property name="value">50</property>
<signal name="changed" handler="on_mem_maxmem_changed" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="mem-maxmem-atkobject">
<property name="AtkObject::accessible-name">Max Memory Select</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label346">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">MiB</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -462,7 +462,6 @@ class vmmDetails(vmmGObjectUI):
"on_cpu_topology_enable_toggled": self.config_cpu_topology_enable,
"on_mem_memory_changed": self.config_memory_changed,
"on_mem_maxmem_changed": self.config_maxmem_changed,
"on_boot_list_changed": self.config_bootdev_selected,
@ -1201,26 +1200,9 @@ class vmmDetails(vmmGObjectUI):
# Memory
def config_get_maxmem(self):
return uiutil.spin_get_helper(self.widget("mem-maxmem"))
def config_get_memory(self):
return uiutil.spin_get_helper(self.widget("mem-memory"))
def config_maxmem_changed(self, src_ignore):
self.enable_apply(EDIT_MEM)
def config_memory_changed(self, src_ignore):
self.enable_apply(EDIT_MEM)
maxadj = self.widget("mem-maxmem")
mem = self.config_get_memory()
if maxadj.get_value() < mem:
maxadj.set_value(mem)
ignore, upper = maxadj.get_range()
maxadj.set_range(mem, upper)
# VCPUS
def config_get_vcpus(self):
@ -1568,27 +1550,13 @@ class vmmDetails(vmmGObjectUI):
def config_memory_apply(self):
kwargs = {}
hotplug_args = {}
if self.edited(EDIT_MEM):
curmem = None
maxmem = self.config_get_maxmem()
if self.widget("mem-memory").get_sensitive():
curmem = self.config_get_memory()
if curmem:
curmem = int(curmem) * 1024
if maxmem:
maxmem = int(maxmem) * 1024
kwargs["memory"] = curmem
kwargs["maxmem"] = maxmem
hotplug_args["memory"] = kwargs["memory"]
hotplug_args["maxmem"] = kwargs["maxmem"]
memory = uiutil.spin_get_helper(self.widget("mem-memory"))
kwargs["memory"] = int(memory) * 1024
return vmmAddHardware.change_config_helper(self.vm.define_memory,
kwargs, self.vm, self.err,
hotplug_args=hotplug_args)
kwargs, self.vm, self.err)
def config_boot_options_apply(self):
kwargs = {}
@ -2054,7 +2022,7 @@ class vmmDetails(vmmGObjectUI):
if self.config.get_stats_enable_memory_poll():
cur_vm_memory = self.vm.stats_memory()
vm_memory = self.vm.maximum_memory()
vm_memory = self.vm.xmlobj.memory
mem_txt = _("%(current-memory)s of %(total-memory)s") % {
"current-memory": uiutil.pretty_mem(cur_vm_memory),
"total-memory": uiutil.pretty_mem(vm_memory)
@ -2152,19 +2120,12 @@ class vmmDetails(vmmGObjectUI):
def refresh_config_memory(self):
host_mem_widget = self.widget("state-host-memory")
host_mem = self.vm.conn.host_memory_size() // 1024
vm_cur_mem = self.vm.get_memory() / 1024.0
vm_max_mem = self.vm.maximum_memory() / 1024.0
vm_cur_mem = self.vm.xmlobj.memory / 1024.0
host_mem_widget.set_text("%d MiB" % (int(round(host_mem))))
curmem = self.widget("mem-memory")
maxmem = self.widget("mem-maxmem")
curmem.set_value(int(round(vm_cur_mem)))
maxmem.set_value(int(round(vm_max_mem)))
if not self.widget("mem-memory").get_sensitive():
ignore, upper = maxmem.get_range()
maxmem.set_range(curmem.get_value(), upper)
def refresh_disk_page(self, disk):
path = disk.path

View File

@ -562,13 +562,12 @@ class vmmDomain(vmmLibvirtObject):
guest.cpu.set_model(guest, model)
self._redefine_xmlobj(guest)
def define_memory(self, memory=_SENTINEL, maxmem=_SENTINEL):
def define_memory(self, memory=_SENTINEL):
guest = self._make_xmlobj_to_define()
if memory != _SENTINEL:
guest.currentMemory = int(memory)
if maxmem != _SENTINEL:
guest.memory = int(maxmem)
guest.memory = int(memory)
self._redefine_xmlobj(guest)
def define_overview(self, machine=_SENTINEL, description=_SENTINEL,
@ -1001,39 +1000,15 @@ class vmmDomain(vmmLibvirtObject):
log.debug("update_device with xml=\n%s", xml)
self._backend.updateDeviceFlags(xml, flags)
def hotplug(self, memory=_SENTINEL, maxmem=_SENTINEL,
description=_SENTINEL, title=_SENTINEL, device=_SENTINEL):
def hotplug(self, description=_SENTINEL, title=_SENTINEL, device=_SENTINEL):
if not self.is_active():
return
def _hotplug_memory(val):
if val != self.get_memory():
self._backend.setMemory(val)
def _hotplug_maxmem(val):
if val != self.maximum_memory():
self._backend.setMaxMemory(val)
def _hotplug_metadata(val, mtype):
flags = (libvirt.VIR_DOMAIN_AFFECT_LIVE |
libvirt.VIR_DOMAIN_AFFECT_CONFIG)
self._backend.setMetadata(mtype, val, None, None, flags)
if memory != _SENTINEL:
log.debug("Hotplugging curmem=%s maxmem=%s for VM '%s'",
memory, maxmem, self.get_name())
actual_cur = self.get_memory()
if memory:
if maxmem < actual_cur:
# Set current first to avoid error
_hotplug_memory(memory)
_hotplug_maxmem(maxmem)
else:
_hotplug_maxmem(maxmem)
_hotplug_memory(memory)
else:
_hotplug_maxmem(maxmem)
if description != _SENTINEL:
_hotplug_metadata(description,
libvirt.VIR_DOMAIN_METADATA_DESCRIPTION)
@ -1305,11 +1280,6 @@ class vmmDomain(vmmLibvirtObject):
def get_description(self):
return self.get_xmlobj().description
def get_memory(self):
return int(self.get_xmlobj().currentMemory)
def maximum_memory(self):
return int(self.get_xmlobj().memory)
def get_cpu_config(self):
return self.get_xmlobj().cpu