diff --git a/CHANGELOG.md b/CHANGELOG.md index cced83c48..ec04fbef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- **TDX quotes go to QGS over vsock first.** When `/etc/tdx-attest.conf` + sets a port, `tdx-attest` asks QGS directly and falls back to configfs only + if that fails, or uses configfs alone when `DCAP_TDX_QUOTE_CONFIGFS_PATH` is + set. The kernel's configfs path polls once a second, so a quote took about + 1 s there and takes about 5 ms over vsock. - **`vmm-cli update --compose` takes an app compose file.** It sends the `app-compose.json` written by `vmm-cli compose` unchanged instead of a Docker Compose file patched into the stored one, and `--prelaunch-script` and diff --git a/dstack/tdx-attest/src/linux.rs b/dstack/tdx-attest/src/linux.rs index bde47ce34..c1100f4d9 100644 --- a/dstack/tdx-attest/src/linux.rs +++ b/dstack/tdx-attest/src/linux.rs @@ -166,17 +166,26 @@ static CONFIGFS_MKDIR_TRIED: Mutex = Mutex::new(false); /// Get a TDX quote for the given report data. /// /// Tries multiple methods in order: -/// 1. ConfigFS (Linux 6.7+) -/// 2. VSock to QGS service +/// 1. VSock to QGS service, when a port is configured and no configfs path is +/// forced through the environment +/// 2. ConfigFS (Linux 6.7+) +/// +/// VSock goes first because the kernel's configfs path polls for the quote +/// once a second, so a quote QGS returns in milliseconds takes a second there. pub fn get_quote(report_data: &TdxReportData) -> Result> { let _guard = TDX_LOCK.lock().map_err(|_| TdxAttestError::Busy)?; - if should_try_configfs() { - return get_quote_via_configfs(report_data); + if std::env::var_os(CONFIGFS_PATH_ENV).is_none() && is_vsock_available() { + match get_quote_via_vsock(report_data) { + Ok(quote) => return Ok(quote), + Err(err) if !should_try_configfs() => return Err(err), + // Images configure the port whether or not the host serves it. + Err(_) => {} + } } - if is_vsock_available() { - return get_quote_via_vsock(report_data); + if should_try_configfs() { + return get_quote_via_configfs(report_data); } Err(TdxAttestError::NotSupported(