@@ -95,7 +95,7 @@ class VmExecution:
9595 """
9696
9797 uuid : uuid .UUID # Unique identifier of this execution
98- vm_hash : VmId
98+ vm_id : VmId
9999 # The message-free description this execution is built from.
100100 spec : CreateVmSpec
101101 resources : (
@@ -144,7 +144,7 @@ async def update_port_redirects(self, requested_ports: dict[int, dict[str, bool]
144144
145145 for protocol in SUPPORTED_PROTOCOL_FOR_REDIRECT :
146146 if target [protocol ]:
147- add_port_redirect_rule (self .vm .vm_id , interface , host_port , vm_port , protocol )
147+ add_port_redirect_rule (self .vm .vm_index , interface , host_port , vm_port , protocol )
148148 self .mapped_ports [int (vm_port )] = {"host" : host_port , ** target }
149149 changed = True
150150
@@ -155,7 +155,7 @@ async def update_port_redirects(self, requested_ports: dict[int, dict[str, bool]
155155 for protocol in SUPPORTED_PROTOCOL_FOR_REDIRECT :
156156 if current [protocol ] != target [protocol ]:
157157 if target [protocol ]:
158- add_port_redirect_rule (self .vm .vm_id , interface , host_port , vm_port , protocol )
158+ add_port_redirect_rule (self .vm .vm_index , interface , host_port , vm_port , protocol )
159159 else :
160160 remove_port_redirect_rule (interface , host_port , vm_port , protocol )
161161 changed = True
@@ -164,7 +164,7 @@ async def update_port_redirects(self, requested_ports: dict[int, dict[str, bool]
164164
165165 # Persist port mappings to dedicated table if anything changed
166166 if changed :
167- await save_port_mappings (self .vm_hash , self .mapped_ports )
167+ await save_port_mappings (self .vm_id , self .mapped_ports )
168168
169169 async def recreate_port_redirect_rules (self ) -> None :
170170 """Recreate nftables port redirect rules from saved mapped_ports after restart.
@@ -215,15 +215,15 @@ async def recreate_port_redirect_rules(self) -> None:
215215 host_port ,
216216 new_host_port ,
217217 vm_port ,
218- self .vm_hash ,
218+ self .vm_id ,
219219 )
220220 host_port = new_host_port
221221 mapping ["host" ] = new_host_port
222222 port_changed = True
223223
224224 for protocol in protocols_to_create :
225225 all_entities += build_port_redirect_entities (
226- self .vm .vm_id ,
226+ self .vm .vm_index ,
227227 interface ,
228228 host_port ,
229229 vm_port ,
@@ -242,11 +242,11 @@ async def recreate_port_redirect_rules(self) -> None:
242242 protocol ,
243243 host_port ,
244244 vm_port ,
245- self .vm_hash ,
245+ self .vm_id ,
246246 )
247247
248248 if port_changed :
249- await save_port_mappings (self .vm_hash , self .mapped_ports )
249+ await save_port_mappings (self .vm_id , self .mapped_ports )
250250
251251 async def removed_all_ports_redirection (self ):
252252 if not self .vm :
@@ -323,12 +323,12 @@ def becomes_ready(self) -> Callable[[], Coroutine]:
323323 return self .ready_event .wait
324324
325325 @property
326- def vm_id (self ) -> int | None :
327- return self .vm .vm_id if self .vm else None
326+ def vm_index (self ) -> int | None :
327+ return self .vm .vm_index if self .vm else None
328328
329329 @property
330330 def controller_service (self ) -> str :
331- return f"aleph-vm-controller@{ self .vm_hash } .service"
331+ return f"aleph-vm-controller@{ self .vm_id } .service"
332332
333333 @property
334334 def allocated_memory_mib (self ) -> int :
@@ -349,19 +349,19 @@ def has_resources(self) -> bool:
349349 return True
350350
351351 def __repr__ (self ):
352- return f"<VMExecution { type (self .vm ).__name__ } { self .vm_hash } { self .times .started_at } >"
352+ return f"<VMExecution { type (self .vm ).__name__ } { self .vm_id } { self .times .started_at } >"
353353
354354 def __init__ (
355355 self ,
356- vm_hash : VmId ,
356+ vm_id : VmId ,
357357 vm_spec : CreateVmSpec ,
358358 snapshot_manager : SnapshotManager | None = None ,
359359 systemd_manager : SystemDManager | None = None ,
360360 persistent : bool = False ,
361361 ):
362362 self .init_task = None
363363 self .uuid = uuid .uuid1 () # uuid1() includes the hardware address and timestamp
364- self .vm_hash = vm_hash
364+ self .vm_id = vm_id
365365 self .spec = vm_spec
366366 self .times = VmExecutionTimes (defined_at = datetime .now (tz = timezone .utc ))
367367 self .ready_event = asyncio .Event ()
@@ -390,7 +390,7 @@ def from_spec(
390390 The supervisor's machinery (prepare/create/start) reads only the spec.
391391 """
392392 return cls (
393- vm_hash = spec .vm_id ,
393+ vm_id = spec .vm_id ,
394394 vm_spec = spec ,
395395 snapshot_manager = snapshot_manager ,
396396 systemd_manager = systemd_manager ,
@@ -416,9 +416,9 @@ async def prepare(self) -> None:
416416 if self .spec .backend is Backend .FIRECRACKER :
417417 self .resources = SpecProgramResources .from_spec (self .spec )
418418 elif self .spec .tee is not None :
419- self .resources = AlephQemuConfidentialResources .from_spec (self .spec , namespace = str (self .vm_hash ))
419+ self .resources = AlephQemuConfidentialResources .from_spec (self .spec , namespace = str (self .vm_id ))
420420 else :
421- self .resources = AlephQemuResources .from_spec (self .spec , namespace = str (self .vm_hash ))
421+ self .resources = AlephQemuResources .from_spec (self .spec , namespace = str (self .vm_id ))
422422 self .times .prepared_at = datetime .now (tz = timezone .utc )
423423
424424 def uses_gpu (self , pci_host : str ) -> bool :
@@ -429,7 +429,7 @@ def uses_gpu(self, pci_host: str) -> bool:
429429 return False
430430
431431 def create (
432- self , vm_id : int , tap_interface : TapInterface | None = None , prepare : bool = True
432+ self , vm_index : int , tap_interface : TapInterface | None = None , prepare : bool = True
433433 ) -> AlephVmControllerInterface :
434434 if not self .resources :
435435 msg = "Execution resources must be configured first"
@@ -439,8 +439,8 @@ def create(
439439 if self .spec .backend is Backend .FIRECRACKER :
440440 assert isinstance (self .resources , SpecProgramResources )
441441 self .vm = vm = SpecFirecrackerProgram (
442- vm_id = vm_id ,
443- vm_hash = self .vm_hash ,
442+ vm_index = vm_index ,
443+ vm_hash = self .vm_id ,
444444 spec = self .spec ,
445445 resources = self .resources ,
446446 tap_interface = tap_interface ,
@@ -454,8 +454,8 @@ def create(
454454 # SAFETY-CRITICAL: never fall through to the plain AlephQemuInstance.
455455 assert isinstance (self .resources , AlephQemuConfidentialResources )
456456 self .vm = vm = AlephQemuConfidentialInstance (
457- vm_id = vm_id ,
458- vm_hash = self .vm_hash ,
457+ vm_index = vm_index ,
458+ vm_hash = self .vm_id ,
459459 resources = self .resources ,
460460 enable_networking = self .spec .network .internet_access ,
461461 confidential_policy = int (self .spec .tee .policy , 0 ),
@@ -465,8 +465,8 @@ def create(
465465 return vm
466466 assert isinstance (self .resources , AlephQemuResources )
467467 self .vm = vm = AlephQemuInstance (
468- vm_id = vm_id ,
469- vm_hash = self .vm_hash ,
468+ vm_index = vm_index ,
469+ vm_hash = self .vm_id ,
470470 resources = self .resources ,
471471 enable_networking = self .spec .network .internet_access ,
472472 hardware_resources = hardware_resources ,
@@ -639,7 +639,7 @@ async def stop(self) -> None:
639639 # Prevent concurrent calls to stop() using a Lock
640640 async with self .stop_pending_lock :
641641 if self .times .stopped_at is not None :
642- logger .debug (f"VM={ self .vm .vm_id } already stopped" )
642+ logger .debug (f"VM={ self .vm .vm_index } already stopped" )
643643 return
644644 if self .persistent and self .systemd_manager :
645645 self .systemd_manager .stop_and_disable (self .controller_service )
@@ -655,7 +655,7 @@ async def stop(self) -> None:
655655 self .times .stopped_at = datetime .now (tz = timezone .utc )
656656
657657 if self .vm .support_snapshot and self .snapshot_manager :
658- await self .snapshot_manager .stop_for (self .vm_hash )
658+ await self .snapshot_manager .stop_for (self .vm_id )
659659 self .stop_event .set ()
660660 logger .info ("%s stopped" , self )
661661
@@ -695,6 +695,6 @@ async def record_usage(self):
695695 await delete_record (execution_uuid = str (self .uuid ))
696696 # Non-persistent VMs won't restart, so clean up their port mappings
697697 if not self .persistent :
698- await delete_port_mappings (self .vm_hash )
698+ await delete_port_mappings (self .vm_id )
699699 if settings .EXECUTION_LOG_ENABLED :
700700 await save_execution_data (execution_uuid = self .uuid , execution_data = self .to_json ())
0 commit comments