1use std::os::raw::c_char;
7
8pub const KRUN_LOG_TARGET_DEFAULT: i32 = 0;
10pub const KRUN_LOG_TARGET_STDOUT: i32 = 1;
11pub const KRUN_LOG_TARGET_STDERR: i32 = 2;
12
13pub const KRUN_LOG_LEVEL_OFF: u32 = 0;
14pub const KRUN_LOG_LEVEL_ERROR: u32 = 1;
15pub const KRUN_LOG_LEVEL_WARN: u32 = 2;
16pub const KRUN_LOG_LEVEL_INFO: u32 = 3;
17pub const KRUN_LOG_LEVEL_DEBUG: u32 = 4;
18pub const KRUN_LOG_LEVEL_TRACE: u32 = 5;
19
20pub const KRUN_LOG_STYLE_AUTO: u32 = 0;
21pub const KRUN_LOG_STYLE_ALWAYS: u32 = 1;
22pub const KRUN_LOG_STYLE_NEVER: u32 = 2;
23
24pub const KRUN_DISK_FORMAT_RAW: u32 = 0;
26pub const KRUN_DISK_FORMAT_QCOW2: u32 = 1;
27
28extern "C" {
29 pub fn krun_init_log(target: i32, level: u32, style: u32, flags: u32) -> i32;
30 pub fn krun_set_log_level(level: u32) -> i32;
31 pub fn krun_create_ctx() -> i32;
32 pub fn krun_free_ctx(ctx_id: u32) -> i32;
33 pub fn krun_set_vm_config(ctx_id: u32, num_vcpus: u8, ram_mib: u32) -> i32;
34 pub fn krun_set_root(ctx_id: u32, root_path: *const c_char) -> i32;
35 pub fn krun_add_virtiofs(
36 ctx_id: u32,
37 mount_tag: *const c_char,
38 host_path: *const c_char,
39 ) -> i32;
40 pub fn krun_add_virtiofs3(
41 ctx_id: u32,
42 mount_tag: *const c_char,
43 host_path: *const c_char,
44 shm_size: u64,
45 read_only: bool,
46 ) -> i32;
47 pub fn krun_set_kernel(
48 ctx_id: u32,
49 kernel_path: *const c_char,
50 kernel_format: u32,
51 initramfs: *const c_char,
52 cmdline: *const c_char,
53 ) -> i32;
54 pub fn krun_set_exec(
55 ctx_id: u32,
56 exec_path: *const c_char,
57 argv: *const *const c_char,
58 envp: *const *const c_char,
59 ) -> i32;
60 pub fn krun_set_env(ctx_id: u32, envp: *const *const c_char) -> i32;
61 pub fn krun_set_workdir(ctx_id: u32, workdir_path: *const c_char) -> i32;
62 pub fn krun_split_irqchip(ctx_id: u32, enable: bool) -> i32;
63 pub fn krun_set_nested_virt(ctx_id: u32, enabled: bool) -> i32;
64 pub fn krun_set_gpu_options(ctx_id: u32, virgl_flags: u32) -> i32;
65 pub fn krun_set_rlimits(ctx_id: u32, rlimits: *const *const c_char) -> i32;
66 pub fn krun_set_port_map(ctx_id: u32, port_map: *const *const c_char) -> i32;
67 pub fn krun_add_vsock_port2(
68 ctx_id: u32,
69 port: u32,
70 filepath: *const c_char,
71 listen: bool,
72 ) -> i32;
73 pub fn krun_add_disk(
74 ctx_id: u32,
75 block_id: *const c_char,
76 disk_path: *const c_char,
77 read_only: bool,
78 ) -> i32;
79 pub fn krun_add_disk2(
80 ctx_id: u32,
81 block_id: *const c_char,
82 disk_path: *const c_char,
83 disk_format: u32,
84 read_only: bool,
85 ) -> i32;
86 pub fn krun_add_net_unixstream(
87 ctx_id: u32,
88 c_path: *const c_char,
89 fd: i32,
90 c_mac: *const u8,
91 features: u32,
92 flags: u32,
93 ) -> i32;
94 pub fn krun_add_net_unixgram(
95 ctx_id: u32,
96 c_path: *const c_char,
97 fd: i32,
98 c_mac: *const u8,
99 features: u32,
100 flags: u32,
101 ) -> i32;
102 pub fn krun_disable_implicit_vsock(ctx_id: u32) -> i32;
103 pub fn krun_add_vsock(ctx_id: u32, tsi_features: u32) -> i32;
104 pub fn krun_start_enter(ctx_id: u32) -> i32;
105
106 pub fn krun_set_console_output(ctx_id: u32, filepath: *const c_char) -> i32;
110
111 pub fn krun_setuid(ctx_id: u32, uid: libc::uid_t) -> i32;
114
115 pub fn krun_setgid(ctx_id: u32, gid: libc::gid_t) -> i32;
117
118 pub fn krun_set_root_disk_remount(
130 ctx_id: u32,
131 device: *const c_char,
132 fstype: *const c_char,
133 options: *const c_char,
134 ) -> i32;
135}