1#![allow(warnings)]
22use serde_tuple::Deserialize_tuple;
23use zbus::proxy;
24use zbus::zvariant::Type;
25
26use crate::dbus::zbus_machine::MachineProxy;
27
28#[derive(Deserialize_tuple, PartialEq, Eq, Debug, Type)]
29pub struct ListedMachine {
30 pub name: String,
31 pub class: String,
32 pub service: String,
33 pub path: zbus::zvariant::OwnedObjectPath,
34}
35
36#[proxy(
37 interface = "org.freedesktop.machine1.Manager",
38 default_service = "org.freedesktop.machine1",
39 default_path = "/org/freedesktop/machine1"
40)]
41pub trait Manager {
42 fn bind_mount_machine(
44 &self,
45 name: &str,
46 source: &str,
47 destination: &str,
48 read_only: bool,
49 mkdir: bool,
50 ) -> zbus::Result<()>;
51
52 fn clean_pool(&self, mode: &str) -> zbus::Result<Vec<(String, u64)>>;
54
55 fn clone_image(&self, name: &str, new_name: &str, read_only: bool) -> zbus::Result<()>;
57
58 fn copy_from_machine(&self, name: &str, source: &str, destination: &str) -> zbus::Result<()>;
60
61 fn copy_from_machine_with_flags(
63 &self,
64 name: &str,
65 source: &str,
66 destination: &str,
67 flags: u64,
68 ) -> zbus::Result<()>;
69
70 fn copy_to_machine(&self, name: &str, source: &str, destination: &str) -> zbus::Result<()>;
72
73 fn copy_to_machine_with_flags(
75 &self,
76 name: &str,
77 source: &str,
78 destination: &str,
79 flags: u64,
80 ) -> zbus::Result<()>;
81
82 #[allow(clippy::too_many_arguments)]
84 fn create_machine(
85 &self,
86 name: &str,
87 id: &[u8],
88 service: &str,
89 class: &str,
90 leader: u32,
91 root_directory: &str,
92 scope_properties: &[&(&str, &zbus::zvariant::Value<'_>)],
93 ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
94
95 #[allow(clippy::too_many_arguments)]
97 fn create_machine_with_network(
98 &self,
99 name: &str,
100 id: &[u8],
101 service: &str,
102 class: &str,
103 leader: u32,
104 root_directory: &str,
105 ifindices: &[i32],
106 scope_properties: &[&(&str, &zbus::zvariant::Value<'_>)],
107 ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
108
109 fn get_image(&self, name: &str) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
111
112 fn get_image_hostname(&self, name: &str) -> zbus::Result<String>;
114
115 #[zbus(name = "GetImageMachineID")]
117 fn get_image_machine_id(&self, name: &str) -> zbus::Result<Vec<u8>>;
118
119 fn get_image_machine_info(
121 &self,
122 name: &str,
123 ) -> zbus::Result<std::collections::HashMap<String, String>>;
124
125 #[zbus(name = "GetImageOSRelease")]
127 fn get_image_osrelease(
128 &self,
129 name: &str,
130 ) -> zbus::Result<std::collections::HashMap<String, String>>;
131
132 #[zbus(object = "Machine")]
134 fn get_machine(&self, name: &str) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
135
136 fn get_machine_addresses(&self, name: &str) -> zbus::Result<Vec<(i32, Vec<u8>)>>;
138
139 #[zbus(name = "GetMachineByPID", object = "Machine")]
141 fn get_machine_by_pid(&self, pid: u32) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
142
143 #[zbus(name = "GetMachineOSRelease")]
145 fn get_machine_osrelease(
146 &self,
147 name: &str,
148 ) -> zbus::Result<std::collections::HashMap<String, String>>;
149
150 #[zbus(name = "GetMachineUIDShift")]
152 fn get_machine_uidshift(&self, name: &str) -> zbus::Result<u32>;
153
154 fn kill_machine(&self, name: &str, who: &str, signal: i32) -> zbus::Result<()>;
156
157 fn list_images(
159 &self,
160 ) -> zbus::Result<
161 Vec<(
162 String,
163 String,
164 bool,
165 u64,
166 u64,
167 u64,
168 zbus::zvariant::OwnedObjectPath,
169 )>,
170 >;
171
172 fn list_machines(&self) -> zbus::Result<Vec<ListedMachine>>;
174
175 fn map_from_machine_group(&self, name: &str, gid_inner: u32) -> zbus::Result<u32>;
177
178 fn map_from_machine_user(&self, name: &str, uid_inner: u32) -> zbus::Result<u32>;
180
181 fn map_to_machine_group(
183 &self,
184 gid_outer: u32,
185 ) -> zbus::Result<(String, zbus::zvariant::OwnedObjectPath, u32)>;
186
187 fn map_to_machine_user(
189 &self,
190 uid_outer: u32,
191 ) -> zbus::Result<(String, zbus::zvariant::OwnedObjectPath, u32)>;
192
193 fn mark_image_read_only(&self, name: &str, read_only: bool) -> zbus::Result<()>;
195
196 fn open_machine_login(&self, name: &str) -> zbus::Result<(zbus::zvariant::OwnedFd, String)>;
198
199 #[zbus(name = "OpenMachinePTY")]
201 fn open_machine_pty(&self, name: &str) -> zbus::Result<(zbus::zvariant::OwnedFd, String)>;
202
203 fn open_machine_root_directory(&self, name: &str) -> zbus::Result<zbus::zvariant::OwnedFd>;
205
206 #[allow(clippy::too_many_arguments)]
208 fn open_machine_shell(
209 &self,
210 name: &str,
211 user: &str,
212 path: &str,
213 args: &[&str],
214 environment: &[&str],
215 ) -> zbus::Result<(zbus::zvariant::OwnedFd, String)>;
216
217 #[allow(clippy::too_many_arguments)]
219 fn register_machine(
220 &self,
221 name: &str,
222 id: &[u8],
223 service: &str,
224 class: &str,
225 leader: u32,
226 root_directory: &str,
227 ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
228
229 #[allow(clippy::too_many_arguments)]
231 fn register_machine_with_network(
232 &self,
233 name: &str,
234 id: &[u8],
235 service: &str,
236 class: &str,
237 leader: u32,
238 root_directory: &str,
239 ifindices: &[i32],
240 ) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
241
242 fn remove_image(&self, name: &str) -> zbus::Result<()>;
244
245 fn rename_image(&self, name: &str, new_name: &str) -> zbus::Result<()>;
247
248 fn set_image_limit(&self, name: &str, size: u64) -> zbus::Result<()>;
250
251 fn set_pool_limit(&self, size: u64) -> zbus::Result<()>;
253
254 fn terminate_machine(&self, id: &str) -> zbus::Result<()>;
256
257 fn unregister_machine(&self, name: &str) -> zbus::Result<()>;
259
260 #[zbus(signal)]
262 fn machine_new(&self, machine: &str, path: zbus::zvariant::ObjectPath<'_>) -> zbus::Result<()>;
263
264 #[zbus(signal)]
266 fn machine_removed(
267 &self,
268 machine: &str,
269 path: zbus::zvariant::ObjectPath<'_>,
270 ) -> zbus::Result<()>;
271
272 #[zbus(property)]
274 fn pool_limit(&self) -> zbus::Result<u64>;
275
276 #[zbus(property)]
278 fn pool_path(&self) -> zbus::Result<String>;
279
280 #[zbus(property)]
282 fn pool_usage(&self) -> zbus::Result<u64>;
283}