fix: preserve guest network identities and refresh session profiles
This commit is contained in:
@@ -26,6 +26,7 @@ class Profile:
|
||||
width: int = 1280
|
||||
height: int = 800
|
||||
refresh_millihz: int = 0
|
||||
mac: str | None = None
|
||||
|
||||
def __post_init__(self):
|
||||
validate_name(self.name)
|
||||
@@ -33,6 +34,12 @@ class Profile:
|
||||
if not isinstance(self.iso, (str, Path)) or not str(self.iso):
|
||||
raise ValueError('ISO must be a nonempty path or omitted')
|
||||
object.__setattr__(self, 'iso', Path(self.iso).expanduser().resolve())
|
||||
if self.mac is not None:
|
||||
if (not isinstance(self.mac, str) or
|
||||
not re.fullmatch(r'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}', self.mac) or
|
||||
int(self.mac[:2], 16) & 3 != 2):
|
||||
raise ValueError('mac must be a locally administered unicast Ethernet address')
|
||||
object.__setattr__(self, 'mac', self.mac.lower())
|
||||
for key, upper in (('memory', 262144), ('cpus', 256)):
|
||||
value = getattr(self, key)
|
||||
if type(value) is not int or not 1 <= value <= upper:
|
||||
|
||||
Reference in New Issue
Block a user