Skip to content

Commit

Permalink
vmm:qemu support config_qemu.toml
Browse files Browse the repository at this point in the history
Signed-off-by: liuxu <liuxu156@huawei.com>
  • Loading branch information
liuxu committed Oct 26, 2024
1 parent 02ed014 commit f2d36c0
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 8 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ runc: bin/runc-sandboxer

ifeq ($(HYPERVISOR), stratovirt)
vmm: bin/vmm-sandboxer bin/kuasar.initrd bin/vmlinux.bin
else ifeq ($(HYPERVISOR), qemu)
vmm: bin/vmm-sandboxer bin/kuasar.img bin/vmlinux.bin
else
vmm: bin/vmm-sandboxer bin/kuasar.img bin/vmlinux.bin
endif
Expand All @@ -78,10 +80,13 @@ install-vmm:

ifeq ($(HYPERVISOR), stratovirt)
@install -p -m 640 bin/kuasar.initrd ${DEST_DIR}${INSTALL_DIR}/kuasar.initrd
@install -p -m 640 vmm/sandbox/config_stratovirt_${ARCH}.toml ${DEST_DIR}${INSTALL_DIR}/config_stratovirt.toml
@install -p -m 640 vmm/sandbox/config_stratovirt_${ARCH}.toml ${DEST_DIR}${INSTALL_DIR}/config.toml
else ifeq ($(HYPERVISOR), qemu)
@install -p -m 640 bin/kuasar.img ${DEST_DIR}${INSTALL_DIR}/kuasar.img
@install -p -m 640 vmm/sandbox/config_qemu_${ARCH}.toml ${DEST_DIR}${INSTALL_DIR}/config.toml
else
@install -p -m 640 bin/kuasar.img ${DEST_DIR}${INSTALL_DIR}/kuasar.img
@install -p -m 640 vmm/sandbox/config_clh.toml ${DEST_DIR}${INSTALL_DIR}/config_clh.toml
@install -p -m 640 vmm/sandbox/config_clh.toml ${DEST_DIR}${INSTALL_DIR}/config.toml
endif

install-wasm:
Expand Down
41 changes: 41 additions & 0 deletions vmm/sandbox/config_qemu_aarch64.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[sandbox]
log_level = "info"

[hypervisor]
machine_accelerators = ""
firmware_path = ""
cpu_features = "pmu=off"
cpu_model = "host"
qemu_path = "/usr/bin/qemu-system-aarch64"
machine_type = "virt"
default_bridges = 1
default_max_vcpus = 0
entropy_source = "/dev/urandom"
mem_slots = 1
mem_offset = 0
memory_path = ""
file_backend_mem_path = ""
mem_prealloc = false
hugepages = false
enable_vhost_user_store = false
enable_swap = false
virtiofs_daemon_path = "/usr/libexec/virtiofsd"
virtiofs_cache = "auto"
virtiofs_extra_args = ["--thread-pool-size=1", "--announce-submounts"]
virtiofs_cache_size = 0
msize_9p = 8192
virtio_9p_direct_io = false
virtio_9p_multidevs = ""
enable_iothreads = false
block_device_driver = "VirtioScsi"
disable_nvdimm = true
share_fs = "Virtio9P"
use_vsock = true

[hypervisor.common]
memory_in_mb = 2048
vcpus = 1
kernel_params = "task.log_level=debug task.sharefs_type=9p tsc=reliable rcupdate.rcu_expedited=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1 noreplace-smp= reboot=k console=hvc0 console=hvc1 iommu=off cryptomgr.notests= net.ifnames=0 pci=lastbus=0"
kernel_path = "/var/lib/kuasar/vmlinux.bin"
initrd_path = "/var/lib/kuasar/kuasar.img"
image_path = ""
41 changes: 41 additions & 0 deletions vmm/sandbox/config_qemu_x86_64.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[sandbox]
log_level = "info"

[hypervisor]
machine_accelerators = ""
firmware_path = ""
cpu_features = "pmu=off"
cpu_model = "host"
qemu_path = "/usr/bin/qemu-system-x86_64"
machine_type = "virt"
default_bridges = 1
default_max_vcpus = 0
entropy_source = "/dev/urandom"
mem_slots = 1
mem_offset = 0
memory_path = ""
file_backend_mem_path = ""
mem_prealloc = false
hugepages = false
enable_vhost_user_store = false
enable_swap = false
virtiofs_daemon_path = "/usr/libexec/virtiofsd"
virtiofs_cache = "auto"
virtiofs_extra_args = ["--thread-pool-size=1", "--announce-submounts"]
virtiofs_cache_size = 0
msize_9p = 8192
virtio_9p_direct_io = false
virtio_9p_multidevs = ""
enable_iothreads = false
block_device_driver = "VirtioScsi"
disable_nvdimm = true
share_fs = "Virtio9P"
use_vsock = true

[hypervisor.common]
memory_in_mb = 2048
vcpus = 1
kernel_params = "task.log_level=debug task.sharefs_type=9p tsc=reliable rcupdate.rcu_expedited=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1 noreplace-smp= reboot=k console=hvc0 console=hvc1 iommu=off cryptomgr.notests= net.ifnames=0 pci=lastbus=0"
kernel_path = "/var/lib/kuasar/vmlinux.bin"
initrd_path = "/var/lib/kuasar/kuasar.img"
image_path = ""
6 changes: 3 additions & 3 deletions vmm/sandbox/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ pub struct Args {
#[arg(short, long)]
pub version: bool,

/// Config file path, only for cloud hypervisor and stratovirt, default is `/var/lib/kuasar/config_clh.toml`
/// Config file path, for cloud hypervisor, qemu and stratovirt, default is `/var/lib/kuasar/config.toml`
#[arg(
short,
long,
value_name = "FILE",
default_value = "/var/lib/kuasar/config_clh.toml"
default_value = "/var/lib/kuasar/config.toml"
)]
pub config: String,

Expand Down Expand Up @@ -61,7 +61,7 @@ mod tests {
fn test_args_parse_default() {
let args = Args::parse();
assert!(!args.version);
assert_eq!(args.config, "/var/lib/kuasar/config_clh.toml");
assert_eq!(args.config, "/var/lib/kuasar/config.toml");
assert_eq!(args.dir, "/run/kuasar-vmm");
assert_eq!(args.listen, "/run/vmm-sandboxer.sock");
assert!(args.log_level.is_none());
Expand Down
8 changes: 5 additions & 3 deletions vmm/sandbox/src/bin/qemu/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ async fn main() {
}

// For compatibility with kata config
let config_path = std::env::var("KATA_CONFIG_PATH")
.unwrap_or_else(|_| "/usr/share/defaults/kata-containers/configuration.toml".to_string());
let config_path = std::env::var("KATA_CONFIG_PATH").unwrap_or_default();
let path = std::path::Path::new(&config_path);

let config = if path.exists() {
Expand All @@ -54,12 +53,15 @@ async fn main() {
// Initialize log
init_logger(&config.sandbox.log_level());

let sandboxer: KuasarSandboxer<QemuVMFactory, QemuHooks> = KuasarSandboxer::new(
let mut sandboxer: KuasarSandboxer<QemuVMFactory, QemuHooks> = KuasarSandboxer::new(
config.sandbox,
config.hypervisor.clone(),
QemuHooks::new(config.hypervisor),
);

// Do recovery job
sandboxer.recover(&args.dir).await;

// Run the sandboxer
containerd_sandbox::run(
"kuasar-vmm-sandboxer-qemu",
Expand Down

0 comments on commit f2d36c0

Please sign in to comment.