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

fix(instances): NIC edits keep their settings; edits keep metadata

- change_network detached the NIC and attached one built from scratch,
  dropping its QoS, link state and other settings. It now edits the NIC
  of the persistent definition in place and defines once; a running VM
  gets the change at its next start, as the UI already says.
- add_network, delete_network and set_link_state did nothing on a
  paused VM, and set_link_state rewrote the persistent NIC from the live
  XML. They now update the running definition when the VM is active and
  the persistent one always, each from its own XML.
- Boot and console edits used xml.etree, which renamed the namespace
  prefixes of other tools' metadata (<app:info> became <ns0:info>); they
  use lxml now.
- The NIC table and the clone form are filled from the persistent
  definition (Instance.config_networks, config_disks), so a pending NIC
  change is shown and can be edited again.

A live test runs 18 domain edits on stopped, running and paused VMs
whose definition has elements WebVirtCloud does not manage, and checks
for each the effect, that nothing else in the persistent definition
changed, and that persistent-only edits leave the running VM alone.
This commit is contained in:
catborise 2026-10-04 00:27:55 +03:00
parent 57cf49262a
commit 5def4e41fd
8 changed files with 444 additions and 89 deletions

View file

@ -135,6 +135,21 @@ class Instance(models.Model):
def networks(self) -> list[dict]:
return self.proxy.get_net_devices()
@cached_property
def config_networks(self) -> list[dict]:
"""NICs of the persistent definition, which the edit and clone forms
change; target is the running VM's device name, if any."""
live_targets = {net["mac"]: net.get("target", "") for net in self.networks}
networks = self.proxy.get_net_devices(config=True)
for net in networks:
net["target"] = live_targets.get(net["mac"], "")
return networks
@cached_property
def config_disks(self) -> list[dict]:
"""Disks of the persistent definition, which a clone copies."""
return self.proxy.get_disk_devices(config=True)
@cached_property
def qos(self):
return self.proxy.get_all_qos()