@@ -49,16 +49,17 @@ pub async fn run(config: &Config, vm_config: &VmConfig) -> Result<TartInstance>
49
49
MachineCopy :: clone_vm ( & vm_config. image_path ) . await ?
50
50
} ;
51
51
52
+ if let Err ( err) = machine_copy. configure ( & vm_config) . await {
53
+ log:: error!( "Failed to configure tart vm: {err}" ) ;
54
+ }
55
+
52
56
// Start VM
53
57
let mut tart_cmd = Command :: new ( "tart" ) ;
54
58
tart_cmd. args ( [ "run" , & machine_copy. name , "--serial" ] ) ;
55
59
56
60
if !vm_config. disks . is_empty ( ) {
57
61
log:: warn!( "Mounting disks is not yet supported" )
58
62
}
59
- if let Some ( cpu) = vm_config. vcpus {
60
- tart_cmd. args ( [ "--cpu" , & cpu. to_string ( ) ] ) ;
61
- }
62
63
63
64
match config. runtime_opts . display {
64
65
config:: Display :: None => {
@@ -170,6 +171,28 @@ impl MachineCopy {
170
171
} )
171
172
}
172
173
174
+ pub async fn configure ( & self , vm_config : & VmConfig ) -> Result < ( ) > {
175
+ let mut args = vec ! [ ] ;
176
+ if let Some ( cpu) = vm_config. vcpus {
177
+ args. extend ( [ "--cpu" . to_owned ( ) , cpu. to_string ( ) ] ) ;
178
+ log:: info!( "vCPUs: {cpu}" ) ;
179
+ }
180
+ if let Some ( mem) = vm_config. memory {
181
+ args. extend ( [ "--memory" . to_owned ( ) , mem. to_string ( ) ] ) ;
182
+ log:: info!( "Memory: {mem} MB" ) ;
183
+ }
184
+ if !args. is_empty ( ) {
185
+ let mut tart_cmd = Command :: new ( "tart" ) ;
186
+ tart_cmd. args ( [ "set" , & self . name ] ) ;
187
+ tart_cmd. args ( args) ;
188
+ tart_cmd
189
+ . status ( )
190
+ . await
191
+ . context ( "failed to update tart config" ) ?;
192
+ }
193
+ Ok ( ( ) )
194
+ }
195
+
173
196
pub async fn cleanup ( mut self ) {
174
197
let _ = tokio:: task:: spawn_blocking ( move || self . try_destroy ( ) ) . await ;
175
198
}
0 commit comments