mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-22 07:03:16 +00:00
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:
parent
67d7292081
commit
c86da0034e
@ -162,6 +162,7 @@ usage(int code)
|
|||||||
" -i: ioc boot parameters\n"
|
" -i: ioc boot parameters\n"
|
||||||
#ifdef CONFIG_VM_CFG
|
#ifdef CONFIG_VM_CFG
|
||||||
" --vmcfg: build-in VM configurations\n"
|
" --vmcfg: build-in VM configurations\n"
|
||||||
|
" --dump: show build-in VM configurations\n"
|
||||||
#endif
|
#endif
|
||||||
" --vsbl: vsbl file path\n"
|
" --vsbl: vsbl file path\n"
|
||||||
" --part_info: guest partition info file path\n"
|
" --part_info: guest partition info file path\n"
|
||||||
@ -710,6 +711,7 @@ enum {
|
|||||||
CMD_OPT_PTDEV_NO_RESET,
|
CMD_OPT_PTDEV_NO_RESET,
|
||||||
CMD_OPT_DEBUGEXIT,
|
CMD_OPT_DEBUGEXIT,
|
||||||
CMD_OPT_VMCFG,
|
CMD_OPT_VMCFG,
|
||||||
|
CMD_OPT_DUMP,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
@ -742,6 +744,7 @@ static struct option long_options[] = {
|
|||||||
/* Following cmd option only has long option */
|
/* Following cmd option only has long option */
|
||||||
#ifdef CONFIG_VM_CFG
|
#ifdef CONFIG_VM_CFG
|
||||||
{"vmcfg", required_argument, 0, CMD_OPT_VMCFG},
|
{"vmcfg", required_argument, 0, CMD_OPT_VMCFG},
|
||||||
|
{"dump", required_argument, 0, CMD_OPT_DUMP},
|
||||||
#endif
|
#endif
|
||||||
{"vsbl", required_argument, 0, CMD_OPT_VSBL},
|
{"vsbl", required_argument, 0, CMD_OPT_VSBL},
|
||||||
{"part_info", required_argument, 0, CMD_OPT_PART_INFO},
|
{"part_info", required_argument, 0, CMD_OPT_PART_INFO},
|
||||||
@ -1047,6 +1050,10 @@ int main(int argc, char *argv[])
|
|||||||
vmcfg = 1;
|
vmcfg = 1;
|
||||||
index = atoi(optarg);
|
index = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
case CMD_OPT_DUMP:
|
||||||
|
index = atoi(optarg);
|
||||||
|
vmcfg_dump(index, long_options, optstr);
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
dm_options++;
|
dm_options++;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#ifndef VMCFG_H
|
#ifndef VMCFG_H
|
||||||
#define VMCFG_H
|
#define VMCFG_H
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
struct vmcfg_arg {
|
struct vmcfg_arg {
|
||||||
char **argv;
|
char **argv;
|
||||||
int argc;
|
int argc;
|
||||||
@ -19,4 +21,5 @@ extern int num_args_buildin;
|
|||||||
extern struct vmcfg_arg mrb_vm1_args;
|
extern struct vmcfg_arg mrb_vm1_args;
|
||||||
|
|
||||||
void vmcfg_list(void);
|
void vmcfg_list(void);
|
||||||
|
void vmcfg_dump(int index, struct option *long_options, char *optstr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <vmcfg_config.h>
|
#include <vmcfg_config.h>
|
||||||
#include <vmcfg.h>
|
#include <vmcfg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
void vmcfg_list(void)
|
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[] = {
|
static struct vmcfg_arg *vmcfg_buildin_args[] = {
|
||||||
#ifdef CONFIG_MRB_VM1
|
#ifdef CONFIG_MRB_VM1
|
||||||
&mrb_vm1_args,
|
&mrb_vm1_args,
|
||||||
|
Loading…
Reference in New Issue
Block a user