DM: VMcfg: support --dump options

run 'acrn-dm --dump <index>' to show build-in parameters

Tracked-On: #1528
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
This commit is contained in:
yuhong.tao@intel.com
2018-08-28 23:13:35 +08:00
committed by wenlingz
parent 67d7292081
commit c86da0034e
3 changed files with 44 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
#include <vmcfg_config.h>
#include <vmcfg.h>
#include <stdio.h>
#include <getopt.h>
void vmcfg_list(void)
{
@@ -18,6 +19,39 @@ void vmcfg_list(void)
}
}
void vmcfg_dump(int index, struct option *long_options, char *optstr)
{
char **argv;
int argc;
int c, option_idx = 0;
int i = 1;
if ((index <= 0) || (index > num_args_buildin)) {
fprintf(stderr, "%s(%d) index should be 1~%d\n", __FUNCTION__,
index, num_args_buildin);
return;
}
if (args_buildin[index - 1]->setup)
args_buildin[index - 1]->setup();
argv = args_buildin[index - 1]->argv;
argc = args_buildin[index - 1]->argc;
printf("%s build-in args:\n", argv[argc - 1]);
optind = 0;
while ((c = getopt_long(argc, argv, optstr, long_options,
&option_idx)) != -1) {
if (optarg)
printf("%s %s\n", argv[i], optarg);
else
printf("%s\n", argv[i]);
i = optind;
}
}
static struct vmcfg_arg *vmcfg_buildin_args[] = {
#ifdef CONFIG_MRB_VM1
&mrb_vm1_args,