@@ -440,19 +440,22 @@ static void handle_options(int argc,
440
440
char * * dtb_file ,
441
441
char * * initrd_file ,
442
442
char * * disk_file ,
443
+ char * * net_dev ,
443
444
int * hart_count )
444
445
{
445
- * kernel_file = * dtb_file = * initrd_file = * disk_file = NULL ;
446
+ * kernel_file = * dtb_file = * initrd_file = * disk_file = * net_dev = NULL ;
446
447
447
448
int optidx = 0 ;
448
449
struct option opts [] = {
449
450
{"kernel" , 1 , NULL , 'k' }, {"dtb" , 1 , NULL , 'b' },
450
451
{"initrd" , 1 , NULL , 'i' }, {"disk" , 1 , NULL , 'd' },
451
- {"smp" , 1 , NULL , 'c' }, {"help" , 0 , NULL , 'h' },
452
+ {"netdev" , 1 , NULL , 'n' }, {"smp" , 1 , NULL , 'c' },
453
+ {"help" , 0 , NULL , 'h' },
452
454
};
453
455
454
456
int c ;
455
- while ((c = getopt_long (argc , argv , "k:b:i:d:c:h" , opts , & optidx )) != -1 ) {
457
+ while ((c = getopt_long (argc , argv , "k:b:i:d:n:c:h" , opts , & optidx )) !=
458
+ -1 ) {
456
459
switch (c ) {
457
460
case 'k' :
458
461
* kernel_file = optarg ;
@@ -466,6 +469,9 @@ static void handle_options(int argc,
466
469
case 'd' :
467
470
* disk_file = optarg ;
468
471
break ;
472
+ case 'n' :
473
+ * net_dev = optarg ;
474
+ break ;
469
475
case 'c' :
470
476
* hart_count = atoi (optarg );
471
477
break ;
@@ -487,6 +493,9 @@ static void handle_options(int argc,
487
493
488
494
if (!* dtb_file )
489
495
* dtb_file = "minimal.dtb" ;
496
+
497
+ if (!* net_dev )
498
+ * net_dev = "tap" ;
490
499
}
491
500
492
501
@@ -509,9 +518,10 @@ static int semu_start(int argc, char **argv)
509
518
char * dtb_file ;
510
519
char * initrd_file ;
511
520
char * disk_file ;
521
+ char * netdev ;
512
522
int hart_count = 1 ;
513
523
handle_options (argc , argv , & kernel_file , & dtb_file , & initrd_file ,
514
- & disk_file , & hart_count );
524
+ & disk_file , & netdev , & hart_count );
515
525
516
526
/* Initialize the emulator */
517
527
emu_state_t emu ;
@@ -573,7 +583,7 @@ static int semu_start(int argc, char **argv)
573
583
emu .uart .in_fd = 0 , emu .uart .out_fd = 1 ;
574
584
capture_keyboard_input (); /* set up uart */
575
585
#if SEMU_HAS (VIRTIONET )
576
- if (!virtio_net_init (& (emu .vnet )))
586
+ if (!virtio_net_init (& (emu .vnet ), netdev ))
577
587
fprintf (stderr , "No virtio-net functioned\n" );
578
588
emu .vnet .ram = emu .ram ;
579
589
#endif
0 commit comments