@@ -440,19 +440,22 @@ static void handle_options(int argc,
440440 char * * dtb_file ,
441441 char * * initrd_file ,
442442 char * * disk_file ,
443+ char * * net_dev ,
443444 int * hart_count )
444445{
445- * kernel_file = * dtb_file = * initrd_file = * disk_file = NULL ;
446+ * kernel_file = * dtb_file = * initrd_file = * disk_file = * net_dev = NULL ;
446447
447448 int optidx = 0 ;
448449 struct option opts [] = {
449450 {"kernel" , 1 , NULL , 'k' }, {"dtb" , 1 , NULL , 'b' },
450451 {"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' },
452454 };
453455
454456 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 ) {
456459 switch (c ) {
457460 case 'k' :
458461 * kernel_file = optarg ;
@@ -466,6 +469,9 @@ static void handle_options(int argc,
466469 case 'd' :
467470 * disk_file = optarg ;
468471 break ;
472+ case 'n' :
473+ * net_dev = optarg ;
474+ break ;
469475 case 'c' :
470476 * hart_count = atoi (optarg );
471477 break ;
@@ -487,6 +493,9 @@ static void handle_options(int argc,
487493
488494 if (!* dtb_file )
489495 * dtb_file = "minimal.dtb" ;
496+
497+ if (!* net_dev )
498+ * net_dev = "tap" ;
490499}
491500
492501
@@ -509,9 +518,10 @@ static int semu_start(int argc, char **argv)
509518 char * dtb_file ;
510519 char * initrd_file ;
511520 char * disk_file ;
521+ char * netdev ;
512522 int hart_count = 1 ;
513523 handle_options (argc , argv , & kernel_file , & dtb_file , & initrd_file ,
514- & disk_file , & hart_count );
524+ & disk_file , & netdev , & hart_count );
515525
516526 /* Initialize the emulator */
517527 emu_state_t emu ;
@@ -573,7 +583,7 @@ static int semu_start(int argc, char **argv)
573583 emu .uart .in_fd = 0 , emu .uart .out_fd = 1 ;
574584 capture_keyboard_input (); /* set up uart */
575585#if SEMU_HAS (VIRTIONET )
576- if (!virtio_net_init (& (emu .vnet )))
586+ if (!virtio_net_init (& (emu .vnet ), netdev ))
577587 fprintf (stderr , "No virtio-net functioned\n" );
578588 emu .vnet .ram = emu .ram ;
579589#endif
0 commit comments