#define SUPPORT_LEGACY_ARGS
+#define ARGS_LIMIT 128
#define LEN_MARU_KERNEL_CMDLINE 512
char maru_kernel_cmdline[LEN_MARU_KERNEL_CMDLINE];
// if "log_path" is not exist, make it first
if (!log_path) {
- char *vm_path = get_variable("vm_path");
- if (!vm_path) {
- vm_path = g_strdup("");
+ char *vms_path = get_variable("vms_path");
+ char *vm_name = get_variable("vm_name");
+ if (!vms_path || !vm_name) {
+ log_path = NULL;
+ }
+ else {
+ log_path = g_strdup_printf("%s/%s/logs", vms_path, vm_name);
}
- log_path = g_strdup_printf("%s/logs", vm_path);
set_variable("log_path", log_path, false);
}
#endif
gchar *profile = NULL;
+ gchar *conf = NULL;
+
int c = 0;
- _qemu_argv = g_malloc(sizeof(char*) * 256);
- _skin_argv = g_malloc(sizeof(char*) * 256);
+ _qemu_argv = g_malloc(sizeof(char*) * ARGS_LIMIT);
+ _skin_argv = g_malloc(sizeof(char*) * ARGS_LIMIT);
// parse arguments
// prevent the error message for undefined options
while (c != -1) {
static struct option long_options[] = {
+ {"conf", required_argument, 0, 'c' },
{"profile", required_argument, 0, 'p' },
{"additional", required_argument, 0, 'a' },
{0, 0, 0, 0 }
};
- c = getopt_long(argc, argv, "p:v:", long_options, NULL);
+ c = getopt_long(argc, argv, "c:p:a:", long_options, NULL);
if (c == -1)
break;
case '?':
set_variable(argv[optind - 1], argv[optind], true);
break;
+ case 'c':
+ set_variable("conf", optarg, true);
+ conf = g_strdup(optarg);
+ break;
case 'p':
set_variable("profile", optarg, true);
profile = g_strdup(optarg);
}
}
- if (!profile) {
- fprintf(stderr, "Usage: %s {-p|--profile} profile\n", argv[0]);
+ if (!profile && !conf) {
+ fprintf(stderr, "Usage: %s {-c|--conf} conf_file ...\n"
+ " %s {-p|--profile} profile ...\n",
+ basename(argv[0]), basename(argv[0]));
return -1;
}
set_bin_path(_qemu_argv[0]);
- if (!load_profile_default(profile)) {
+ if (!load_profile_default(conf, profile)) {
return -1;
}
return str;
}
-bool load_profile_default(const char * const profile)
+bool load_profile_default(const char * const conf, const char * const profile)
{
int classification = 0;
char str[LINE_LIMIT];
char *filename;
FILE *file = NULL;
- filename = g_strdup_printf("%s/%s.profile", get_bin_path(), profile);
+ // if "conf" is exist, ignore "profile"
+ if (conf) {
+ filename = g_strdup(conf);
+ } else {
+ filename = g_strdup_printf("%s/%s.conf", get_bin_path(), profile);
+ }
file = fopen(filename, "r");
if (!file) {