From 3730a95c020250699aa4fd20c626ce9325829a69 Mon Sep 17 00:00:00 2001 From: catborise Date: Sat, 24 Oct 2026 19:57:34 +0300 Subject: [PATCH] fix(instances): the XML dialog keeps the edit and defines only this VM Found by review (Codex and agy) of the XML editor's dialog: - A busy or moved VM made the page reload and the edit was lost. The dialog's requests now get these answers as JSON (X-Requested-With, as the create page's flavor forms) and show them; any other failure says the edit is still in the editor. - libvirt finds the VM to define by the XML's UUID: another VM's UUID overwrote that VM past its lock, a new or missing one added a VM. The XML must keep this VM's UUID; a malformed one is refused with the parser's error, as on the create page. - Save sends the XML whose diff the dialog shows, also when two previews answer out of order; a failed save keeps the diff and Save. - The edited XML is defined with the line breaks libvirt gave, not the form's CRLF, and the VM's state is read before the definition, so a failed read cannot turn a saved change into an error. --- .../templates/instances/settings_tab.html | 2 +- instances/tests/test_change_xml.py | 45 +++++++++++++++++-- instances/views.py | 39 +++++++++------- static/js/xml_editor.js | 34 +++++++------- 4 files changed, 85 insertions(+), 35 deletions(-) diff --git a/instances/templates/instances/settings_tab.html b/instances/templates/instances/settings_tab.html index 1b2ec0e4..d874d7a4 100644 --- a/instances/templates/instances/settings_tab.html +++ b/instances/templates/instances/settings_tab.html @@ -669,7 +669,7 @@