1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 04:36:48 +00:00

feat(instances): a VM's RNG device and crash action in its options

Two settings the owner chose to add to Settings > Options after the
page's review with Codex. Both change the persistent definition, so
they are saved while the VM runs and used from its next start.

- Random number generator: a switch for a virtio RNG device fed from
  the host's /dev/urandom, so a new VM does not wait for entropy at
  boot. Another RNG device, or the panel's with a rate or driver, is
  shown as the VM's own and left to the XML editor.
- When the guest crashes: Restart or Stop (on_crash restart or
  destroy); libvirt's default, Stop, when the definition has none.
  Stop keeps a VM that crashes again and again down for a look. Any
  other action is shown and left to the XML editor.
This commit is contained in:
catborise 2026-10-30 16:20:32 +03:00
parent a993c12db0
commit 1150b941be
8 changed files with 177 additions and 0 deletions

View file

@ -125,6 +125,16 @@ EDITS = {
lambda t: first(t, "devices/video/model/@type") == "virtio",
["devices/video"], True, False,
),
"set_rng": (
lambda vm: vm.set_rng(False),
lambda t: not t.xpath("devices/rng"),
["devices/rng"], True, False,
),
"set_on_crash": (
lambda vm: vm.set_on_crash("restart"),
lambda t: t.findtext("on_crash") == "restart",
["on_crash"], True, False,
),
"resize_cpu": (
lambda vm: vm.resize_cpu("1", "2"),
lambda t: t.findtext("vcpu") == "2" and first(t, "vcpu/@current") == "1",

View file

@ -141,6 +141,15 @@ class PendingEditsTestCase(TestCase):
self.assertEqual(doc.xpath("//select[@name='vcpu_hotplug']/option[@selected]/@value"), ["True"])
self.assertIn("No channel", doc.xpath("string(//form[.//select[@name='guest_agent']])"))
def test_a_custom_rng_or_crash_action_is_left_to_the_xml_editor(self):
doc = self.page(get_rng=("custom", "custom"), get_on_crash=("preserve", "preserve"))
self.assertIsNotNone(doc.xpath("//input[@name='rng']")[0].get("disabled"))
self.assertEqual(doc.xpath("//select[@name='on_crash']"), [])
self.assertIn("preserve: change it in the XML editor.", doc.xpath("string(//p[@id='on_crash'])"))
doc = self.page(get_rng=("virtio", "virtio"), get_on_crash=("restart", "restart")) # read from the persistent definition
self.assertEqual(doc.xpath("//input[@name='rng']/@checked"), ["checked"])
self.assertEqual(doc.xpath("//select[@name='on_crash']/option[@selected]/@value"), ["restart"])
def test_buttons_shown_as_disabled_cannot_submit(self):
# running: the CPU resize, vCPU hot plug, template and disk removal forms wait for a shutdown;
# the title, description and video model are of the next start, saved at once