MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / setup_fs

Method setup_fs

dstack-util/src/system_setup.rs:1378–1433  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1376 }
1377
1378 async fn setup_fs(self) -> Result<Stage1<'a>> {
1379 let app_info = self
1380 .measure_app_info()
1381 .context("Failed to measure app info")?;
1382 if self.shared.app_compose.key_provider().is_kms() {
1383 cmd_show_mrs()?;
1384 }
1385 self.vmm
1386 .notify_q("boot.progress", "requesting app keys")
1387 .await;
1388 let app_keys = self
1389 .request_app_keys()
1390 .await
1391 .context("Failed to request app keys")?;
1392 if app_keys.disk_crypt_key.is_empty() {
1393 bail!("Failed to get valid key phrase from KMS");
1394 }
1395
1396 self.verify_app(&app_info, &app_keys)
1397 .context("Failed to verify app")?;
1398
1399 // Save app keys
1400 let keys_json = serde_json::to_string(&app_keys).context("Failed to serialize app keys")?;
1401 fs::write(self.app_keys_file(), keys_json).context("Failed to write app keys")?;
1402
1403 // Parse kernel command line options
1404 let opts = parse_dstack_options(&self.shared).context("Failed to parse kernel cmdline")?;
1405 emit_runtime_event("storage-fs", opts.storage_fs.to_string().as_bytes())?;
1406 info!(
1407 "Filesystem options: encryption={}, filesystem={:?}",
1408 opts.storage_encrypted, opts.storage_fs
1409 );
1410
1411 self.mount_data_disk(&hex::encode(&app_keys.disk_crypt_key), &opts)
1412 .await?;
1413 self.setup_swap(self.shared.app_compose.swap_size, &opts)
1414 .await?;
1415 self.vmm
1416 .notify_q(
1417 "instance.info",
1418 &serde_json::to_string(&app_info.instance_info)?,
1419 )
1420 .await;
1421 emit_runtime_event("system-ready", &[])?;
1422 self.vmm.notify_q("boot.progress", "data disk ready").await;
1423
1424 if !self.shared.app_compose.key_provider().is_kms() {
1425 cmd_show_mrs()?;
1426 }
1427 Ok(Stage1 {
1428 args: self.args,
1429 shared: self.shared,
1430 vmm: self.vmm,
1431 keys: app_keys,
1432 })
1433 }
1434}
1435

Callers 1

do_sys_setupFunction · 0.80

Calls 14

cmd_show_mrsFunction · 0.85
parse_dstack_optionsFunction · 0.85
emit_runtime_eventFunction · 0.85
encodeFunction · 0.85
measure_app_infoMethod · 0.80
is_kmsMethod · 0.80
key_providerMethod · 0.80
notify_qMethod · 0.80
request_app_keysMethod · 0.80
verify_appMethod · 0.80
app_keys_fileMethod · 0.80
mount_data_diskMethod · 0.80

Tested by

no test coverage detected