From 21f83348e91ce4b5a51efbcd8aaa754da77a3b83 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Mon, 29 Jun 2020 19:59:02 -0700 Subject: [PATCH] clh: Set 'virtio-blk' as the default block device driver [ port from runtime commit 5e5527204c03036f1d1a6b3122c1e0c3e1d1ba94 ] The block device driver defaults to 'virtio-scsi' when it is not set in the hypervisor configuration file, while cloud-hypervisor supports only 'virtio-blk' for its block devices. Signed-off-by: Bo Chen Signed-off-by: Peng Tao --- src/runtime/cli/config/configuration-clh.toml.in | 5 +++++ src/runtime/virtcontainers/clh.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/runtime/cli/config/configuration-clh.toml.in b/src/runtime/cli/config/configuration-clh.toml.in index 00185ea2e4..c9d0f5f086 100644 --- a/src/runtime/cli/config/configuration-clh.toml.in +++ b/src/runtime/cli/config/configuration-clh.toml.in @@ -68,6 +68,11 @@ virtio_fs_cache_size = @DEFVIRTIOFSCACHESIZE@ # cloud-hypervisor prefers virtiofs caching (dax) for performance reasons virtio_fs_cache = "always" +# Block storage driver to be used for the hypervisor in case the container +# rootfs is backed by a block device. This is virtio-scsi, virtio-blk +# or nvdimm. +block_device_driver = "virtio-blk" + # This option changes the default hypervisor and kernel parameters # to enable debug output where available. This extra output is added # to the proxy logs, but only when proxy debug is also enabled. diff --git a/src/runtime/virtcontainers/clh.go b/src/runtime/virtcontainers/clh.go index 4ef64f9820..598cba19c4 100644 --- a/src/runtime/virtcontainers/clh.go +++ b/src/runtime/virtcontainers/clh.go @@ -413,6 +413,11 @@ func (clh *cloudHypervisor) getThreadIDs() (vcpuThreadIDs, error) { } func (clh *cloudHypervisor) hotplugBlockDevice(drive *config.BlockDrive) error { + if clh.config.BlockDeviceDriver != config.VirtioBlock { + return fmt.Errorf("incorrect hypervisor configuration on 'block_device_driver':"+ + " using '%v' but only support '%v'", clh.config.BlockDeviceDriver, config.VirtioBlock) + } + cl := clh.client() ctx, cancel := context.WithTimeout(context.Background(), clhHotPlugAPITimeout*time.Second) defer cancel()