mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +00:00
DM: VMcfg: support --vmcfg options
Enable --vmcfg options for acrn-dm, if --vmcfg <index> is specified, build-in VM configuration will be used, and override any other optional parameters. run 'acrn-dm --vmcfg list' to show all build-in VM configurations. run 'acrnpdm --vmcfg <index>' to launch UOS with selected config. 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
321021ebaf
commit
67d7292081
@ -62,6 +62,8 @@
|
|||||||
#include "ioc.h"
|
#include "ioc.h"
|
||||||
#include "pm.h"
|
#include "pm.h"
|
||||||
#include "atomic.h"
|
#include "atomic.h"
|
||||||
|
#include "vmcfg_config.h"
|
||||||
|
#include "vmcfg.h"
|
||||||
|
|
||||||
#define GUEST_NIO_PORT 0x488 /* guest upcalls via i/o port */
|
#define GUEST_NIO_PORT 0x488 /* guest upcalls via i/o port */
|
||||||
|
|
||||||
@ -158,6 +160,9 @@ usage(int code)
|
|||||||
" -G: GVT args: low_gm_size, high_gm_size, fence_sz\n"
|
" -G: GVT args: low_gm_size, high_gm_size, fence_sz\n"
|
||||||
" -v: version\n"
|
" -v: version\n"
|
||||||
" -i: ioc boot parameters\n"
|
" -i: ioc boot parameters\n"
|
||||||
|
#ifdef CONFIG_VM_CFG
|
||||||
|
" --vmcfg: build-in VM configurations\n"
|
||||||
|
#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"
|
||||||
" --enable_trusty: enable trusty for guest\n"
|
" --enable_trusty: enable trusty for guest\n"
|
||||||
@ -704,6 +709,7 @@ enum {
|
|||||||
CMD_OPT_TRUSTY_ENABLE,
|
CMD_OPT_TRUSTY_ENABLE,
|
||||||
CMD_OPT_PTDEV_NO_RESET,
|
CMD_OPT_PTDEV_NO_RESET,
|
||||||
CMD_OPT_DEBUGEXIT,
|
CMD_OPT_DEBUGEXIT,
|
||||||
|
CMD_OPT_VMCFG,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
@ -734,6 +740,9 @@ static struct option long_options[] = {
|
|||||||
{"help", no_argument, 0, 'h' },
|
{"help", no_argument, 0, 'h' },
|
||||||
|
|
||||||
/* Following cmd option only has long option */
|
/* Following cmd option only has long option */
|
||||||
|
#ifdef CONFIG_VM_CFG
|
||||||
|
{"vmcfg", required_argument, 0, CMD_OPT_VMCFG},
|
||||||
|
#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},
|
||||||
{"enable_trusty", no_argument, 0,
|
{"enable_trusty", no_argument, 0,
|
||||||
@ -744,14 +753,15 @@ static struct option long_options[] = {
|
|||||||
{0, 0, 0, 0 },
|
{0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char optstr[] = "abehuwxACHIPSWYvk:r:B:p:g:c:s:m:l:U:G:i:";
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
dm_run(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c, error, gdb_port, err;
|
int c, error, gdb_port, err;
|
||||||
int max_vcpus, mptgen, memflags;
|
int max_vcpus, mptgen, memflags;
|
||||||
struct vmctx *ctx;
|
struct vmctx *ctx;
|
||||||
size_t memsize;
|
size_t memsize;
|
||||||
char *optstr;
|
|
||||||
int option_idx = 0;
|
int option_idx = 0;
|
||||||
|
|
||||||
progname = basename(argv[0]);
|
progname = basename(argv[0]);
|
||||||
@ -767,7 +777,6 @@ main(int argc, char *argv[])
|
|||||||
if (signal(SIGINT, sig_handler_term) == SIG_ERR)
|
if (signal(SIGINT, sig_handler_term) == SIG_ERR)
|
||||||
fprintf(stderr, "cannot register handler for SIGINT\n");
|
fprintf(stderr, "cannot register handler for SIGINT\n");
|
||||||
|
|
||||||
optstr = "abhuwxACSWYvE:k:r:B:p:g:c:s:m:l:U:G:i:";
|
|
||||||
while ((c = getopt_long(argc, argv, optstr, long_options,
|
while ((c = getopt_long(argc, argv, optstr, long_options,
|
||||||
&option_idx)) != -1) {
|
&option_idx)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -1023,3 +1032,50 @@ fail:
|
|||||||
vm_destroy(ctx);
|
vm_destroy(ctx);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
int option_idx = 0;
|
||||||
|
int dm_options = 0, vmcfg = 0;
|
||||||
|
int index = -1;
|
||||||
|
|
||||||
|
while ((c = getopt_long(argc, argv, optstr, long_options,
|
||||||
|
&option_idx)) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case CMD_OPT_VMCFG:
|
||||||
|
vmcfg = 1;
|
||||||
|
index = atoi(optarg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dm_options++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vmcfg) {
|
||||||
|
optind = 0;
|
||||||
|
return dm_run(argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dm_options)
|
||||||
|
fprintf(stderr, "Waring: --vmcfg override optional args\n");
|
||||||
|
|
||||||
|
if (index <= 0) {
|
||||||
|
vmcfg_list();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index > num_args_buildin) {
|
||||||
|
fprintf(stderr, "Error: --vmcfg %d, max index is %d\n",
|
||||||
|
index, num_args_buildin);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
optind = 0;
|
||||||
|
index--;
|
||||||
|
args_buildin[index]->argv[0] = argv[0];
|
||||||
|
if (args_buildin[index]->setup)
|
||||||
|
args_buildin[index]->setup();
|
||||||
|
|
||||||
|
return dm_run(args_buildin[index]->argc, args_buildin[index]->argv);
|
||||||
|
}
|
||||||
|
@ -17,4 +17,6 @@ extern struct vmcfg_arg **args_buildin;
|
|||||||
extern int num_args_buildin;
|
extern int num_args_buildin;
|
||||||
|
|
||||||
extern struct vmcfg_arg mrb_vm1_args;
|
extern struct vmcfg_arg mrb_vm1_args;
|
||||||
|
|
||||||
|
void vmcfg_list(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,6 +5,18 @@
|
|||||||
|
|
||||||
#include <vmcfg_config.h>
|
#include <vmcfg_config.h>
|
||||||
#include <vmcfg.h>
|
#include <vmcfg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void vmcfg_list(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
for (i = 0; i < num_args_buildin; i++) {
|
||||||
|
name = args_buildin[i]->argv[args_buildin[i]->argc - 1];
|
||||||
|
printf("%d: %s\n", i + 1, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct vmcfg_arg *vmcfg_buildin_args[] = {
|
static struct vmcfg_arg *vmcfg_buildin_args[] = {
|
||||||
#ifdef CONFIG_MRB_VM1
|
#ifdef CONFIG_MRB_VM1
|
||||||
|
Loading…
Reference in New Issue
Block a user