From ec679d4d7af917e9cd4f0c69ab6cef347f12c735 Mon Sep 17 00:00:00 2001 From: catborise Date: Sat, 24 Oct 2026 19:44:10 +0300 Subject: [PATCH] feat(instances): a running VM's XML can be edited for its next start The XML editor of a running or paused VM only showed its XML. It now shows the persistent definition, the one the VM starts with next (with secrets, like the other edit forms), and Change saves it through the same review dialog; the running VM keeps its live configuration until it restarts. The tab and the saved message say so. The check against a definition changed since the editor was opened covers this case too. --- instances/models.py | 6 +-- .../templates/instances/settings_tab.html | 50 ++++++++----------- instances/tests/test_change_xml.py | 14 +++--- instances/tests/test_pending_edits.py | 19 ++++--- instances/views.py | 12 ++--- static/js/xml_editor.js | 3 -- 6 files changed, 49 insertions(+), 55 deletions(-) diff --git a/instances/models.py b/instances/models.py index 9248037a..3295bd59 100644 --- a/instances/models.py +++ b/instances/models.py @@ -6,12 +6,11 @@ from django.utils.translation import gettext_lazy as _ from libvirt import ( VIR_DOMAIN_SNAPSHOT_LIST_EXTERNAL, VIR_DOMAIN_SNAPSHOT_LIST_INTERNAL, - VIR_DOMAIN_XML_SECURE, libvirtError, ) from operations import claims from operations.models import Claim -from vrtManager.instance import wvmInstance +from vrtManager.instance import PERSISTENT_XML, wvmInstance from webvirtcloud.settings import QEMU_CONSOLE_LISTENER_ADDRESSES @@ -291,7 +290,8 @@ class Instance(models.Model): @cached_property def inst_xml(self): - return self.proxy._XMLDesc(VIR_DOMAIN_XML_SECURE) + # the definition for the next start, which is the current one while the VM is off + return self.proxy._XMLDesc(PERSISTENT_XML) @cached_property def has_managed_save_image(self): diff --git a/instances/templates/instances/settings_tab.html b/instances/templates/instances/settings_tab.html index 2ab07c9f..1b2ec0e4 100644 --- a/instances/templates/instances/settings_tab.html +++ b/instances/templates/instances/settings_tab.html @@ -656,46 +656,38 @@
{% if instance.status != 5 %} -

{% trans "If you need to edit XML please Power Off the instance" %}

+

{% trans "This is the definition for the VM's next start; a saved change applies then." %}

{% endif %}
{% csrf_token %}
- {% if instance.status == 5 %} - - {% else %} - - {% endif %} +
- {% if instance.status == 5 %} -