Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions src/aleph/vm/controllers/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
from asyncio.subprocess import Process
from pathlib import Path
from time import sleep

from aleph.vm.hypervisors.firecracker.microvm import MicroVM
from aleph.vm.hypervisors.qemu.qemuvm import QemuVM
Expand Down Expand Up @@ -127,21 +128,27 @@ def main():

config.settings.check()

if args.initialize_network_settings:
network = Network(
vm_ipv4_address_pool_range=config.settings.IPV4_ADDRESS_POOL,
vm_network_size=config.settings.IPV4_NETWORK_PREFIX_LENGTH,
external_interface=config.settings.NETWORK_INTERFACE,
ipv6_allocator=make_ipv6_allocator(
allocation_policy=config.settings.IPV6_ALLOCATION_POLICY,
address_pool=config.settings.IPV6_ADDRESS_POOL,
subnet_prefix=config.settings.IPV6_SUBNET_PREFIX,
),
use_ndp_proxy=config.settings.USE_NDP_PROXY,
ipv6_forwarding_enabled=config.settings.IPV6_FORWARDING_ENABLED,
)
network = Network(
vm_ipv4_address_pool_range=config.settings.IPV4_ADDRESS_POOL,
vm_network_size=config.settings.IPV4_NETWORK_PREFIX_LENGTH,
external_interface=config.settings.NETWORK_INTERFACE,
ipv6_allocator=make_ipv6_allocator(
allocation_policy=config.settings.IPV6_ALLOCATION_POLICY,
address_pool=config.settings.IPV6_ADDRESS_POOL,
subnet_prefix=config.settings.IPV6_SUBNET_PREFIX,
),
use_ndp_proxy=config.settings.USE_NDP_PROXY,
ipv6_forwarding_enabled=config.settings.IPV6_FORWARDING_ENABLED,
)

if args.initialize_network_settings:
network.setup()
else:
# Wait for the network interface to be by the supervisor
# Otherwise QEMU will create a new one, and it won't be properly setup as a tuntap as we expect
while not network.interface_exists(config.vm_id):
logger.info("Waiting for network interface to be created...")
sleep(1)

asyncio.run(run_persistent_vm(config))

Expand Down
3 changes: 3 additions & 0 deletions src/aleph/vm/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ async def load_persistent_executions(self):
if self.network:
vm_type = VmType.from_message_content(execution.message)
tap_interface = await self.network.prepare_tap(vm_id, vm_hash, vm_type)
if not self.network.interface_exists(vm_id):
# In case of a reboot, the network is not automatically created
await self.network.create_tap(vm_id, tap_interface)

# Activate ndp_proxy for existing interfaces if needed
if self.network.ndp_proxy and self.network.interface_exists(vm_id):
Expand Down
Loading