62
62
#include "ioc.h"
63
63
#include "pm.h"
64
64
#include "atomic.h"
65
+ #include "vmcfg_config.h"
66
+ #include "vmcfg.h"
65
67
66
68
#define GUEST_NIO_PORT 0x488 /* guest upcalls via i/o port */
67
69
@@ -158,6 +160,9 @@ usage(int code)
158
160
" -G: GVT args: low_gm_size, high_gm_size, fence_sz\n"
159
161
" -v: version\n"
160
162
" -i: ioc boot parameters\n"
163
+ #ifdef CONFIG_VM_CFG
164
+ " --vmcfg: build-in VM configurations\n"
165
+ #endif
161
166
" --vsbl: vsbl file path\n"
162
167
" --part_info: guest partition info file path\n"
163
168
" --enable_trusty: enable trusty for guest\n"
@@ -704,6 +709,7 @@ enum {
704
709
CMD_OPT_TRUSTY_ENABLE ,
705
710
CMD_OPT_PTDEV_NO_RESET ,
706
711
CMD_OPT_DEBUGEXIT ,
712
+ CMD_OPT_VMCFG ,
707
713
};
708
714
709
715
static struct option long_options [] = {
@@ -734,6 +740,9 @@ static struct option long_options[] = {
734
740
{"help" , no_argument , 0 , 'h' },
735
741
736
742
/* Following cmd option only has long option */
743
+ #ifdef CONFIG_VM_CFG
744
+ {"vmcfg" , required_argument , 0 , CMD_OPT_VMCFG },
745
+ #endif
737
746
{"vsbl" , required_argument , 0 , CMD_OPT_VSBL },
738
747
{"part_info" , required_argument , 0 , CMD_OPT_PART_INFO },
739
748
{"enable_trusty" , no_argument , 0 ,
@@ -744,14 +753,15 @@ static struct option long_options[] = {
744
753
{0 , 0 , 0 , 0 },
745
754
};
746
755
756
+ static char optstr [] = "abehuwxACHIPSWYvk:r:B:p:g:c:s:m:l:U:G:i:" ;
757
+
747
758
int
748
- main (int argc , char * argv [])
759
+ dm_run (int argc , char * argv [])
749
760
{
750
761
int c , error , gdb_port , err ;
751
762
int max_vcpus , mptgen , memflags ;
752
763
struct vmctx * ctx ;
753
764
size_t memsize ;
754
- char * optstr ;
755
765
int option_idx = 0 ;
756
766
757
767
progname = basename (argv [0 ]);
@@ -767,7 +777,6 @@ main(int argc, char *argv[])
767
777
if (signal (SIGINT , sig_handler_term ) == SIG_ERR )
768
778
fprintf (stderr , "cannot register handler for SIGINT\n" );
769
779
770
- optstr = "abhuwxACSWYvE:k:r:B:p:g:c:s:m:l:U:G:i:" ;
771
780
while ((c = getopt_long (argc , argv , optstr , long_options ,
772
781
& option_idx )) != -1 ) {
773
782
switch (c ) {
@@ -1023,3 +1032,50 @@ main(int argc, char *argv[])
1023
1032
vm_destroy (ctx );
1024
1033
exit (0 );
1025
1034
}
1035
+
1036
+ int main (int argc , char * argv [])
1037
+ {
1038
+ int c ;
1039
+ int option_idx = 0 ;
1040
+ int dm_options = 0 , vmcfg = 0 ;
1041
+ int index = -1 ;
1042
+
1043
+ while ((c = getopt_long (argc , argv , optstr , long_options ,
1044
+ & option_idx )) != -1 ) {
1045
+ switch (c ) {
1046
+ case CMD_OPT_VMCFG :
1047
+ vmcfg = 1 ;
1048
+ index = atoi (optarg );
1049
+ break ;
1050
+ default :
1051
+ dm_options ++ ;
1052
+ }
1053
+ }
1054
+
1055
+ if (!vmcfg ) {
1056
+ optind = 0 ;
1057
+ return dm_run (argc , argv );
1058
+ }
1059
+
1060
+ if (dm_options )
1061
+ fprintf (stderr , "Waring: --vmcfg override optional args\n" );
1062
+
1063
+ if (index <= 0 ) {
1064
+ vmcfg_list ();
1065
+ return -1 ;
1066
+ }
1067
+
1068
+ if (index > num_args_buildin ) {
1069
+ fprintf (stderr , "Error: --vmcfg %d, max index is %d\n" ,
1070
+ index , num_args_buildin );
1071
+ return -1 ;
1072
+ }
1073
+
1074
+ optind = 0 ;
1075
+ index -- ;
1076
+ args_buildin [index ]-> argv [0 ] = argv [0 ];
1077
+ if (args_buildin [index ]-> setup )
1078
+ args_buildin [index ]-> setup ();
1079
+
1080
+ return dm_run (args_buildin [index ]-> argc , args_buildin [index ]-> argv );
1081
+ }
0 commit comments