From 2e9d27c5006b4798013b2d817d20dcd2704d46bb Mon Sep 17 00:00:00 2001 From: "alex.lyn" Date: Fri, 30 May 2025 17:34:46 +0800 Subject: [PATCH] runtime-rs: Enables block device and disable virtio-fs via capabilities Kata runtime employs a CapabilityBits mechanism for VMM capability governance. Fundamentally, this mechanism utilizes predefined feature flags to manage the VMM's operational boundaries. To meet demands for storage performance and security, it's necessary to explicitly enable capability flags such as `BlockDeviceSupport` (basic block device support) and `BlockDeviceHotplugSupport` (block device hotplug) which ensures the VMM provides the expected caps. In CoCo scenarios, due to the potential risks of sensitive data leaks or side-channel attacks introduced by virtio-fs through shared file systems, the `FsSharingSupport` flag must be forcibly disabled. This disables the virtio-fs feature at the capability set level, blocking insecure data channels. Fixes #11341 Signed-off-by: alex.lyn --- src/runtime-rs/crates/hypervisor/src/qemu/inner.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs index 2a2dbba699..66345a4c91 100644 --- a/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs +++ b/src/runtime-rs/crates/hypervisor/src/qemu/inner.rs @@ -379,7 +379,17 @@ impl QemuInner { pub(crate) async fn capabilities(&self) -> Result { let mut caps = Capabilities::default(); - caps.set(CapabilityBits::FsSharingSupport); + + // Confidential Guest doesn't permit virtio-fs. + let flags = if self.hypervisor_config().security_info.confidential_guest { + CapabilityBits::BlockDeviceSupport | CapabilityBits::BlockDeviceHotplugSupport + } else { + CapabilityBits::BlockDeviceSupport + | CapabilityBits::BlockDeviceHotplugSupport + | CapabilityBits::FsSharingSupport + }; + caps.set(flags); + Ok(caps) }