1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(computes): a VM migrates to its host's panel address when it has no migration address

Without a migration address libvirt sends a migrating VM to the
destination's own host name, which the source host often cannot resolve:
a live migration to a host added without one failed ("Unable to resolve
address ..."), also when the other host had one. The destination's
address on the Computes page, which the panel reaches it at, is now the
default; the migration address stays for another network. A host the
panel reaches on its loopback keeps libvirt's default.
This commit is contained in:
catborise 2026-11-01 17:59:39 +03:00
parent 940e639149
commit cf991adad5
8 changed files with 74 additions and 23 deletions

View file

@ -26,7 +26,7 @@ class Compute(Model):
validators=[validate_migration_address],
help_text=_(
"IP address or host name the other hosts send migrating VMs to; "
"empty: the host's own host name, which they must be able to resolve"
"empty: the address the panel reaches the host at"
),
)
gstfsd_key = CharField(
@ -43,16 +43,18 @@ class Compute(Model):
@property
def migration_uri(self):
"""The native migration URI for VMs migrated to this host, or None for
libvirt's default."""
if not self.migration_address:
return None
"""The native migration URI for VMs migrated to this host: its
migration address, or else the address the panel reaches it at, so
that the other hosts need not resolve its own name. None, libvirt's
default (that name), for a host the panel reaches on its loopback."""
address = self.migration_address or self.hostname
try:
if ip_address(self.migration_address).version == 6:
return f"tcp://[{self.migration_address}]"
ip = ip_address(address)
except ValueError:
pass
return f"tcp://{self.migration_address}"
ip = None
if not self.migration_address and (address.lower().rstrip(".") == "localhost" or ip and ip.is_loopback):
return None
return f"tcp://[{address}]" if ip and ip.version == 6 else f"tcp://{address}"
@cached_property
def status(self):