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 <chen.bo@intel.com>
Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Bo Chen 2020-06-29 19:59:02 -07:00 committed by Peng Tao
parent 8b5eed70f7
commit 21f83348e9
2 changed files with 10 additions and 0 deletions

View File

@ -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.

View File

@ -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()