mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 19:56:48 +00:00
fix(instances): a network device keeps its source unless another is chosen
The Edit dialog of a VM's network device selected the listed network or interface whose name matched the device's source, and the first one when none did: saving only a new model moved a macvtap device or a bridge the host's lists did not show onto the first network, a bridge named like a network became that network, and a macvtap device chosen again lost its mode. The dialog now offers the device's own source first, "<name>, as it is", and posts nothing for it; the view passes no source and the device's source element is left as it is. Choosing another source changes it as before.
This commit is contained in:
parent
3d69dfe5d9
commit
2e17661390
6 changed files with 44 additions and 15 deletions
|
|
@ -2706,7 +2706,8 @@ class wvmInstance(wvmConnect):
|
|||
"""Edit the NIC with old_mac in the persistent definition, in place.
|
||||
|
||||
Settings this form does not edit (QoS, link state, driver, PCI address)
|
||||
stay. A running VM gets the change at its next start.
|
||||
stay, and so does the source when source is None. A running VM gets
|
||||
the change at its next start.
|
||||
"""
|
||||
tree = etree.fromstring(self._XMLDesc(PERSISTENT_XML))
|
||||
found = tree.xpath("./devices/interface[mac/@address=$mac]", mac=old_mac)
|
||||
|
|
@ -2716,14 +2717,15 @@ class wvmInstance(wvmConnect):
|
|||
if iface.get("type") == "hostdev":
|
||||
raise util.OperationError("A network interface that is a host device is changed in the XML editor")
|
||||
|
||||
iface_type = {"net": "network", "bridge": "bridge"}.get(source_type, "direct")
|
||||
iface.set("type", iface_type)
|
||||
for old_source in iface.findall("source"):
|
||||
iface.remove(old_source)
|
||||
source_attrs = {"network": {"network": source}, "bridge": {"bridge": source}}.get(
|
||||
iface_type, {"dev": source, "mode": "bridge"}
|
||||
)
|
||||
iface.insert(1, etree.Element("source", **source_attrs))
|
||||
if source is not None:
|
||||
iface_type = {"net": "network", "bridge": "bridge"}.get(source_type, "direct")
|
||||
iface.set("type", iface_type)
|
||||
for old_source in iface.findall("source"):
|
||||
iface.remove(old_source)
|
||||
source_attrs = {"network": {"network": source}, "bridge": {"bridge": source}}.get(
|
||||
iface_type, {"dev": source, "mode": "bridge"}
|
||||
)
|
||||
iface.insert(1, etree.Element("source", **source_attrs))
|
||||
|
||||
iface.find("mac").set("address", mac)
|
||||
for old_model in iface.findall("model"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue