|
6 | 6 | import sys
|
7 | 7 | from asyncio.subprocess import Process
|
8 | 8 | from pathlib import Path
|
| 9 | +from time import sleep |
9 | 10 |
|
10 | 11 | from aleph.vm.hypervisors.firecracker.microvm import MicroVM
|
11 | 12 | from aleph.vm.hypervisors.qemu.qemuvm import QemuVM
|
@@ -127,21 +128,27 @@ def main():
|
127 | 128 |
|
128 | 129 | config.settings.check()
|
129 | 130 |
|
130 |
| - if args.initialize_network_settings: |
131 |
| - network = Network( |
132 |
| - vm_ipv4_address_pool_range=config.settings.IPV4_ADDRESS_POOL, |
133 |
| - vm_network_size=config.settings.IPV4_NETWORK_PREFIX_LENGTH, |
134 |
| - external_interface=config.settings.NETWORK_INTERFACE, |
135 |
| - ipv6_allocator=make_ipv6_allocator( |
136 |
| - allocation_policy=config.settings.IPV6_ALLOCATION_POLICY, |
137 |
| - address_pool=config.settings.IPV6_ADDRESS_POOL, |
138 |
| - subnet_prefix=config.settings.IPV6_SUBNET_PREFIX, |
139 |
| - ), |
140 |
| - use_ndp_proxy=config.settings.USE_NDP_PROXY, |
141 |
| - ipv6_forwarding_enabled=config.settings.IPV6_FORWARDING_ENABLED, |
142 |
| - ) |
| 131 | + network = Network( |
| 132 | + vm_ipv4_address_pool_range=config.settings.IPV4_ADDRESS_POOL, |
| 133 | + vm_network_size=config.settings.IPV4_NETWORK_PREFIX_LENGTH, |
| 134 | + external_interface=config.settings.NETWORK_INTERFACE, |
| 135 | + ipv6_allocator=make_ipv6_allocator( |
| 136 | + allocation_policy=config.settings.IPV6_ALLOCATION_POLICY, |
| 137 | + address_pool=config.settings.IPV6_ADDRESS_POOL, |
| 138 | + subnet_prefix=config.settings.IPV6_SUBNET_PREFIX, |
| 139 | + ), |
| 140 | + use_ndp_proxy=config.settings.USE_NDP_PROXY, |
| 141 | + ipv6_forwarding_enabled=config.settings.IPV6_FORWARDING_ENABLED, |
| 142 | + ) |
143 | 143 |
|
| 144 | + if args.initialize_network_settings: |
144 | 145 | network.setup()
|
| 146 | + else: |
| 147 | + # Wait for the network interface to be by the supervisor |
| 148 | + # Otherwise QEMU will create a new one, and it won't be properly setup as a tuntap as we expect |
| 149 | + while not network.interface_exists(config.vm_id): |
| 150 | + logger.info("Waiting for network interface to be created...") |
| 151 | + sleep(1) |
145 | 152 |
|
146 | 153 | asyncio.run(run_persistent_vm(config))
|
147 | 154 |
|
|
0 commit comments