runtime-rs: cloud-hypervisor queue_size not set for guest swap disk (enable_guest_swap)

Author: alexander-turnerCreated Sep 23, 2026Updated Sep 23, 2026

Problem: with runtime-rs and Cloud Hypervisor, turning on guest swap (enable_guest_swap = true) never gives the guest a swap disk. When the swap task hot-plugs the swap file, Cloud Hypervisor rejects the disk:

swap_task in "/run/user/1006/run/kata-containers/swap/<sid>" fail: do_handle_device
    0: failed to add device
    1: ... "The disk could not be added to the VM","Failed to validate config","Queue size is smaller than 2: 0"

Setup: Kata 4.2.0 static release on arm64, the bundled Cloud Hypervisor, containerd with the devmapper snapshotter. The config sets queue_size = 128 and num_queues = 1, with rootless = true. Any container triggers it once guest_swap_create_threshold_secs passes.

Cause: this is the same bug as #13210, in a second place. #13211 fixed it for the rootfs disk (block_rootfs.rs) by copying the queue settings from the config. The swap disk in cpu_mem/swap.rs (unchanged on main) still leaves them at their default of 0:

rust
DeviceConfig::BlockCfgModern(BlockConfigModern {
    path_on_host: swap_path.clone(),
    driver_option: block_driver,
    is_direct: Some(true),
    ..Default::default()   // queue_size = 0, num_queues = 0
})

Suggested fix: swap.rs already calls get_block_device_info(&self.device_manager) to get the driver. Set queue_size and num_queues from that same value, as #13211 did.

Possible follow-on (untested): create_disk creates the swap file as root with mode 0700. With rootless = true, Cloud Hypervisor runs as an unprivileged user and opens that file itself, so after the queue fix the hot-plug may fail with a permission error.

Source: kata-containers/kata-containers