1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-01 16:36:06 +00:00

fix(instances): memory, boot order and QoS edits check what they change first

Three edits went wrong on input or a state made outside the panel:

- A running VM's memory was set live, then for its next start. When the
  next start had a lower maximum (virsh --config), the live change was
  made and the second one failed. The maximum of the next start is now
  checked first.
- A boot order entry without its device type ("disk") raised an error
  page. It is now refused with a message.
- A QoS form of a NIC whose MAC changed since redefined the VM unchanged
  and said the QoS was set or deleted. It now says the NIC is not in the
  definition.

Turkish and Chinese texts included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-11 12:43:40 +03:00
parent 63fb7defee
commit 015972dc38
8 changed files with 307 additions and 243 deletions

View file

@ -132,6 +132,17 @@ class DeviceEditsTestCase(unittest.TestCase):
p._defineXML.assert_called_once()
p.wvm.defineXML.assert_not_called()
def test_a_qos_edit_of_a_nic_not_in_the_definition_changes_nothing(self):
# a form loaded before the NIC's MAC changed
for change in (
lambda p: p.set_qos("52:54:10:00:00:09", "outbound", 1, 2, 3),
lambda p: p.unset_qos("52:54:10:00:00:09", "inbound"),
):
p = proxy()
with self.assertRaisesRegex(util.OperationError, "52:54:10:00:00:09 is not in the definition"):
change(p)
p._defineXML.assert_not_called()
def test_a_qos_edit_keeps_the_floor(self):
p = proxy()
p.set_qos("52:54:10:00:00:01", "inbound", 10, 20, 30)
@ -279,6 +290,7 @@ class ResizeMemTestCase(unittest.TestCase):
def test_an_active_vm_changes_only_its_current_memory(self):
# a paused VM is active too: its guest applies the balloon once resumed
p = proxy(active=True)
p._XMLDesc = lambda flags: "<domain><memory>163840</memory></domain>"
p.resize_mem(96, 160)
self.assertEqual(
[c.args for c in p.instance.setMemoryFlags.call_args_list],
@ -286,6 +298,14 @@ class ResizeMemTestCase(unittest.TestCase):
)
p._defineXML.assert_not_called()
def test_an_active_vm_whose_next_start_has_a_lower_maximum_changes_nothing(self):
# set with virsh --config: the running VM's maximum is higher
p = proxy(active=True)
p._XMLDesc = lambda flags: "<domain><memory>65536</memory></domain>"
with self.assertRaisesRegex(util.OperationError, "next start has a maximum memory"):
p.resize_mem(96, 160)
p.instance.setMemoryFlags.assert_not_called()
def test_a_stopped_vm_gets_both_values_in_its_definition(self):
p = proxy(active=False)
p._XMLDesc = lambda flags: "<domain><memory>131072</memory><currentMemory>131072</currentMemory></domain>"