@@ -65,21 +65,6 @@ impl Qemu {
65
65
if image_name. contains ( "rftrace" ) {
66
66
sh. create_dir ( "shared/tracedir" ) ?;
67
67
}
68
- let machine_args = if image_name == "hermit-wasm" {
69
- let mut args = self . machine_args ( arch) ;
70
-
71
- if args. contains ( & "-append" . to_string ( ) ) {
72
- let last = args. last_mut ( ) . unwrap ( ) ;
73
- * last = format ! ( "{last} -- {}" , "/root/hello_world.wasm" ) ;
74
- } else {
75
- args. push ( "-append" . to_string ( ) ) ;
76
- args. push ( format ! ( "-- {}" , "/root/hello_world.wasm" ) ) ;
77
- }
78
-
79
- args
80
- } else {
81
- self . machine_args ( arch)
82
- } ;
83
68
84
69
let qemu = env:: var ( "QEMU" ) . unwrap_or_else ( |_| format ! ( "qemu-system-{arch}" ) ) ;
85
70
let program = if self . sudo { "sudo" } else { qemu. as_str ( ) } ;
@@ -97,13 +82,14 @@ impl Qemu {
97
82
. args ( & [ "-display" , "none" ] )
98
83
. args ( & [ "-serial" , "stdio" ] )
99
84
. args ( self . image_args ( image, arch) ?)
100
- . args ( machine_args)
85
+ . args ( self . machine_args ( arch ) )
101
86
. args ( self . cpu_args ( arch) )
102
87
. args ( & [ "-smp" , & effective_smp. to_string ( ) ] )
103
88
. args ( & [ "-m" . to_string ( ) , format ! ( "{memory}M" ) ] )
104
89
. args ( & [ "-global" , "virtio-mmio.force-legacy=off" ] )
105
90
. args ( self . netdev_args ( ) )
106
- . args ( self . virtiofsd_args ( memory) ) ;
91
+ . args ( self . virtiofsd_args ( memory) )
92
+ . args ( self . cmdline_args ( image_name) ) ;
107
93
108
94
eprintln ! ( "$ {qemu}" ) ;
109
95
let mut qemu = KillChildOnDrop (
@@ -210,7 +196,6 @@ impl Qemu {
210
196
211
197
fn machine_args ( & self , arch : Arch ) -> Vec < String > {
212
198
if self . microvm {
213
- let frequency = get_frequency ( ) ;
214
199
vec ! [
215
200
"-M" . to_string( ) ,
216
201
"microvm,x-option-roms=off,pit=off,pic=off,rtc=on,auto-kernel-cmdline=off,acpi=off"
@@ -219,8 +204,6 @@ impl Qemu {
219
204
"virtio-mmio.force-legacy=off" . to_string( ) ,
220
205
"-nodefaults" . to_string( ) ,
221
206
"-no-user-config" . to_string( ) ,
222
- "-append" . to_string( ) ,
223
- format!( "-freq {frequency}" ) ,
224
207
]
225
208
} else if arch == Arch :: Aarch64 {
226
209
vec ! [ "-machine" . to_string( ) , "virt,gic-version=3" . to_string( ) ]
@@ -369,6 +352,38 @@ impl Qemu {
369
352
}
370
353
}
371
354
355
+ fn cmdline_args ( & self , image_name : & str ) -> Vec < String > {
356
+ let mut cmdline = self . kernel_args ( ) ;
357
+
358
+ let mut app_args = self . app_args ( image_name) ;
359
+ if !app_args. is_empty ( ) {
360
+ cmdline. push ( "--" . to_owned ( ) ) ;
361
+ cmdline. append ( & mut app_args) ;
362
+ }
363
+
364
+ if cmdline. is_empty ( ) {
365
+ return vec ! [ ] ;
366
+ }
367
+
368
+ vec ! [ "-append" . to_owned( ) , cmdline. join( " " ) ]
369
+ }
370
+
371
+ fn kernel_args ( & self ) -> Vec < String > {
372
+ if self . microvm {
373
+ let frequency = get_frequency ( ) ;
374
+ vec ! [ "-freq" . to_owned( ) , frequency. to_string( ) ]
375
+ } else {
376
+ vec ! [ ]
377
+ }
378
+ }
379
+
380
+ fn app_args ( & self , image_name : & str ) -> Vec < String > {
381
+ match image_name {
382
+ "hermit-wasm" => vec ! [ "/root/hello_world.wasm" . to_owned( ) ] ,
383
+ _ => vec ! [ ] ,
384
+ }
385
+ }
386
+
372
387
fn qemu_success ( & self , status : ExitStatus , arch : Arch ) -> bool {
373
388
if status. code ( ) . is_none ( ) {
374
389
return true ;
0 commit comments