mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-02 12:26:23 +00:00
runtime-rs: support configure vm_rootfs_driver
support configure vm_rootfs_driver in toml config Fixes: #7119 Signed-off-by: Zhongtao Hu <zhongtaohu.tim@linux.alibaba.com>
This commit is contained in:
parent
5d6199f9bc
commit
901c192251
@ -32,7 +32,7 @@ pub const DEFAULT_HYPERVISOR: &str = HYPERVISOR_NAME_DRAGONBALL;
|
||||
|
||||
pub const DEFAULT_INTERNETWORKING_MODEL: &str = "tcfilter";
|
||||
|
||||
pub const DEFAULT_BLOCK_DEVICE_TYPE: &str = "virtio-blk";
|
||||
pub const DEFAULT_BLOCK_DEVICE_TYPE: &str = "virtio-blk-pci";
|
||||
pub const DEFAULT_VHOST_USER_STORE_PATH: &str = "/var/run/vhost-user";
|
||||
pub const DEFAULT_BLOCK_NVDIMM_MEM_OFFSET: u64 = 0;
|
||||
|
||||
|
@ -47,7 +47,7 @@ const VIRTIO_BLK_PCI: &str = "virtio-blk-pci";
|
||||
const VIRTIO_BLK_MMIO: &str = "virtio-blk-mmio";
|
||||
const VIRTIO_BLK_CCW: &str = "virtio-blk-ccw";
|
||||
const VIRTIO_SCSI: &str = "virtio-scsi";
|
||||
const VIRTIO_PMEM: &str = "nvdimm";
|
||||
const VIRTIO_PMEM: &str = "virtio-pmem";
|
||||
const VIRTIO_9P: &str = "virtio-9p";
|
||||
const VIRTIO_FS: &str = "virtio-fs";
|
||||
const VIRTIO_FS_INLINE: &str = "inline-virtio-fs";
|
||||
@ -221,6 +221,10 @@ pub struct BootInfo {
|
||||
/// If you want that qemu uses the default firmware leave this option empty.
|
||||
#[serde(default)]
|
||||
pub firmware: String,
|
||||
/// Block storage driver to be used for the VM rootfs is backed
|
||||
/// by a block device. This is virtio-pmem, virtio-blk-pci or virtio-blk-mmio
|
||||
#[serde(default)]
|
||||
pub vm_rootfs_driver: String,
|
||||
}
|
||||
|
||||
impl BootInfo {
|
||||
@ -230,6 +234,11 @@ impl BootInfo {
|
||||
resolve_path!(self.image, "guest boot image file {} is invalid: {}")?;
|
||||
resolve_path!(self.initrd, "guest initrd image file {} is invalid: {}")?;
|
||||
resolve_path!(self.firmware, "firmware image file {} is invalid: {}")?;
|
||||
|
||||
if self.vm_rootfs_driver.is_empty() {
|
||||
self.vm_rootfs_driver = default::DEFAULT_BLOCK_DEVICE_TYPE.to_string();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -242,6 +251,21 @@ impl BootInfo {
|
||||
if !self.image.is_empty() && !self.initrd.is_empty() {
|
||||
return Err(eother!("Can not configure both initrd and image for boot"));
|
||||
}
|
||||
|
||||
let l = [
|
||||
VIRTIO_BLK_PCI,
|
||||
VIRTIO_BLK_CCW,
|
||||
VIRTIO_BLK_MMIO,
|
||||
VIRTIO_PMEM,
|
||||
VIRTIO_SCSI,
|
||||
];
|
||||
if !l.contains(&self.vm_rootfs_driver.as_str()) {
|
||||
return Err(eother!(
|
||||
"{} is unsupported block device type.",
|
||||
self.vm_rootfs_driver
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -202,6 +202,7 @@ ifneq (,$(DBCMD))
|
||||
SYSCONFIG_PATHS += $(SYSCONFIG_DB)
|
||||
CONFIGS += $(CONFIG_DB)
|
||||
# dragonball-specific options (all should be suffixed by "_DB")
|
||||
VMROOTFSDRIVER_DB := virtio-blk-pci
|
||||
DEFMAXVCPUS_DB := 1
|
||||
DEFBLOCKSTORAGEDRIVER_DB := virtio-blk-mmio
|
||||
DEFNETWORKMODEL_DB := tcfilter
|
||||
@ -235,6 +236,7 @@ USER_VARS += SYSCONFIG
|
||||
USER_VARS += IMAGENAME
|
||||
USER_VARS += IMAGEPATH
|
||||
USER_VARS += DEFROOTFSTYPE
|
||||
USER_VARS += VMROOTFSDRIVER_DB
|
||||
USER_VARS += MACHINETYPE
|
||||
USER_VARS += KERNELDIR
|
||||
USER_VARS += KERNELTYPE
|
||||
|
@ -23,6 +23,11 @@ image = "@IMAGEPATH@"
|
||||
# - erofs
|
||||
rootfs_type=@DEFROOTFSTYPE@
|
||||
|
||||
|
||||
# Block storage driver to be used for the VM rootfs is backed
|
||||
# by a block device. This is virtio-blk-pci, virtio-blk-mmio or nvdimm
|
||||
vm_rootfs_driver = "@VMROOTFSDRIVER_DB@"
|
||||
|
||||
# List of valid annotation names for the hypervisor
|
||||
# Each member of the list is a regular expression, which is the base name
|
||||
# of the annotation, e.g. "path" for io.katacontainers.config.hypervisor.path"
|
||||
|
@ -33,7 +33,7 @@ pub use kata_types::config::hypervisor::HYPERVISOR_NAME_CH;
|
||||
|
||||
// Config which driver to use as vm root dev
|
||||
const VM_ROOTFS_DRIVER_BLK: &str = "virtio-blk-pci";
|
||||
const VM_ROOTFS_DRIVER_PMEM: &str = "virtio-pmem";
|
||||
const VM_ROOTFS_DRIVER_PMEM: &str = "nvdimm";
|
||||
const VM_ROOTFS_DRIVER_MMIO: &str = "virtio-blk-mmio";
|
||||
|
||||
//Configure the root corresponding to the driver
|
||||
|
Loading…
Reference in New Issue
Block a user