tools: acrn-manager: change path of vm conf files

The path of vm conf files changed from "/opt/acrn/conf" to "/usr/share/acrn/conf",
since "/opt" is not generally used on clearlinux.

Tracked-On: #2040
Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
Yan, Like 2018-12-12 15:25:05 +08:00 committed by wenlingz
parent 2f30dcdb37
commit 04fef4f363
5 changed files with 28 additions and 31 deletions

View File

@ -102,7 +102,7 @@ The ``acrnd`` daemon process provides a way for launching or resuming a UOS
should the UOS shut down, either planned or unexpected. A UOS can ask ``acrnd`` should the UOS shut down, either planned or unexpected. A UOS can ask ``acrnd``
to set up a timer to make sure the UOS is running, even if the SOS is to set up a timer to make sure the UOS is running, even if the SOS is
suspended or stopped. suspended or stopped.
The ``acrnd`` daemon stores pending UOS work to ``/opt/acrn/conf/timer_list`` The ``acrnd`` daemon stores pending UOS work to ``/usr/share/acrn/conf/timer_list``
and sets an RTC timer to wake up the SOS or bring the SOS back up again. and sets an RTC timer to wake up the SOS or bring the SOS back up again.
When ``acrnd`` daemon is restarted, it restores the previously saved timer When ``acrnd`` daemon is restarted, it restores the previously saved timer
list and launches the UOSs at the right time. list and launches the UOSs at the right time.

View File

@ -128,13 +128,13 @@ static void _scan_alive_vm(void)
int pid; int pid;
int ret; int ret;
ret = check_dir(ACRN_DM_SOCK_ROOT); ret = check_dir(ACRN_DM_SOCK_PATH);
if (ret) { if (ret) {
pdebug(); pdebug();
return; return;
} }
dir = opendir(ACRN_DM_SOCK_ROOT); dir = opendir(ACRN_DM_SOCK_PATH);
if (!dir) { if (!dir) {
pdebug(); pdebug();
return; return;
@ -223,22 +223,19 @@ static void _scan_added_vm(void)
char suffix[128]; char suffix[128];
int ret; int ret;
if (check_dir("/opt") || check_dir("/opt/acrn")) ret = check_dir(ACRN_CONF_PATH);
return;
ret = check_dir(ACRNCTL_OPT_ROOT);
if (ret) { if (ret) {
pdebug(); pdebug();
return; return;
} }
ret = check_dir("/opt/acrn/conf/add"); ret = check_dir(ACRN_CONF_PATH_ADD);
if (ret) { if (ret) {
pdebug(); pdebug();
return; return;
} }
dir = opendir("/opt/acrn/conf/add"); dir = opendir(ACRN_CONF_PATH_ADD);
if (!dir) { if (!dir) {
pdebug(); pdebug();
return; return;
@ -374,8 +371,8 @@ int start_vm(const char *vmname)
{ {
char cmd[128]; char cmd[128];
if (snprintf(cmd, sizeof(cmd), "bash %s/add/%s.sh $(cat %s/add/%s.args)", if (snprintf(cmd, sizeof(cmd), "bash %s/%s.sh $(cat %s/%s.args)",
ACRNCTL_OPT_ROOT, vmname, ACRNCTL_OPT_ROOT, vmname) >= sizeof(cmd)) { ACRN_CONF_PATH_ADD, vmname, ACRN_CONF_PATH_ADD, vmname) >= sizeof(cmd)) {
printf("ERROR: command is truncated\n"); printf("ERROR: command is truncated\n");
return -1; return -1;
} }

View File

@ -23,8 +23,6 @@
#include "acrnctl.h" #include "acrnctl.h"
#include "ioc.h" #include "ioc.h"
#define ACRNCTL_OPT_ROOT "/opt/acrn/conf"
#define ACMD(CMD,FUNC,DESC, VALID_ARGS) \ #define ACMD(CMD,FUNC,DESC, VALID_ARGS) \
{.cmd = CMD, .func = FUNC, .desc = DESC, .valid_args = VALID_ARGS} {.cmd = CMD, .func = FUNC, .desc = DESC, .valid_args = VALID_ARGS}
@ -330,7 +328,7 @@ static int acrnctl_do_add(int argc, char *argv[])
goto get_vmname; goto get_vmname;
} }
if (snprintf(cmd, sizeof(cmd), "mkdir -p %s/add", ACRNCTL_OPT_ROOT) if (snprintf(cmd, sizeof(cmd), "mkdir -p %s", ACRN_CONF_PATH_ADD)
>= sizeof(cmd)) { >= sizeof(cmd)) {
printf("ERROR: cmd is truncated\n"); printf("ERROR: cmd is truncated\n");
ret = -1; ret = -1;
@ -346,16 +344,16 @@ static int acrnctl_do_add(int argc, char *argv[])
goto vm_exist; goto vm_exist;
} }
if (snprintf(cmd, sizeof(cmd), "cp %s.back %s/add/%s.sh", argv[1], if (snprintf(cmd, sizeof(cmd), "cp %s.back %s/%s.sh", argv[1],
ACRNCTL_OPT_ROOT, vmname) >= sizeof(cmd)) { ACRN_CONF_PATH_ADD, vmname) >= sizeof(cmd)) {
printf("ERROR: cmd is truncated\n"); printf("ERROR: cmd is truncated\n");
ret = -1; ret = -1;
goto vm_exist; goto vm_exist;
} }
system(cmd); system(cmd);
if (snprintf(cmd, sizeof(cmd), "echo %s >%s/add/%s.args", args, if (snprintf(cmd, sizeof(cmd), "echo %s >%s/%s.args", args,
ACRNCTL_OPT_ROOT, vmname) >= sizeof(cmd)) { ACRN_CONF_PATH_ADD, vmname) >= sizeof(cmd)) {
printf("ERROR: cmd is truncated\n"); printf("ERROR: cmd is truncated\n");
ret = -1; ret = -1;
goto vm_exist; goto vm_exist;
@ -438,14 +436,14 @@ static int acrnctl_do_del(int argc, char *argv[])
state_str[s->state]); state_str[s->state]);
continue; continue;
} }
if (snprintf(cmd, sizeof(cmd), "rm -f %s/add/%s.sh", if (snprintf(cmd, sizeof(cmd), "rm -f %s/%s.sh",
ACRNCTL_OPT_ROOT, argv[i]) >= sizeof(cmd)) { ACRN_CONF_PATH_ADD, argv[i]) >= sizeof(cmd)) {
printf("WARN: cmd is truncated\n"); printf("WARN: cmd is truncated\n");
return -1; return -1;
} }
system(cmd); system(cmd);
if (snprintf(cmd, sizeof(cmd), "rm -f %s/add/%s.args", if (snprintf(cmd, sizeof(cmd), "rm -f %s/%s.args",
ACRNCTL_OPT_ROOT, argv[i]) >= sizeof(cmd)) { ACRN_CONF_PATH_ADD, argv[i]) >= sizeof(cmd)) {
printf("WARN: cmd is truncated\n"); printf("WARN: cmd is truncated\n");
return -1; return -1;
} }

View File

@ -8,8 +8,11 @@
#include <sys/queue.h> #include <sys/queue.h>
#define ACRNCTL_OPT_ROOT "/opt/acrn/conf" #define ACRN_CONF_PATH "/usr/share/acrn/conf"
#define ACRN_DM_SOCK_ROOT "/run/acrn/mngr" #define ACRN_CONF_PATH_ADD ACRN_CONF_PATH "/add"
#define ACRN_CONF_TIMER_LIST ACRN_CONF_PATH "/timer_list"
#define ACRN_DM_SOCK_PATH "/run/acrn/mngr"
#define MAX_NAME_LEN (32) #define MAX_NAME_LEN (32)

View File

@ -143,7 +143,6 @@ void acrnd_vm_timer_func(struct work_arg *arg)
} }
} }
#define TIMER_LIST_FILE "/opt/acrn/conf/timer_list"
static pthread_mutex_t timer_file_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t timer_file_mutex = PTHREAD_MUTEX_INITIALIZER;
/* load/store_timer_list to file to keep timers if SOS poweroff */ /* load/store_timer_list to file to keep timers if SOS poweroff */
@ -157,7 +156,7 @@ static int load_timer_list(void)
pthread_mutex_lock(&timer_file_mutex); pthread_mutex_lock(&timer_file_mutex);
fp = fopen(TIMER_LIST_FILE, "r"); fp = fopen(ACRN_CONF_TIMER_LIST, "r");
if (!fp) { if (!fp) {
perror("Open timer list file"); perror("Open timer list file");
ret = -1; ret = -1;
@ -402,7 +401,7 @@ static int store_timer_list(void)
int ret = 0; int ret = 0;
pthread_mutex_lock(&timer_file_mutex); pthread_mutex_lock(&timer_file_mutex);
fp = fopen(TIMER_LIST_FILE, "w+"); fp = fopen(ACRN_CONF_TIMER_LIST, "w+");
if (!fp) { if (!fp) {
perror("Open timer list file"); perror("Open timer list file");
ret = -1; ret = -1;
@ -429,7 +428,7 @@ static int store_timer_list(void)
if (sys_wakeup) { if (sys_wakeup) {
set_sos_timer(sys_wakeup); set_sos_timer(sys_wakeup);
} else { } else {
unlink(TIMER_LIST_FILE); unlink(ACRN_CONF_TIMER_LIST);
} }
fclose(fp); fclose(fp);
@ -584,7 +583,7 @@ void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)
if (wakeup_reason & CBC_WK_RSN_RTC) { if (wakeup_reason & CBC_WK_RSN_RTC) {
/* wakeup by RTC timer */ /* wakeup by RTC timer */
if (!stat(TIMER_LIST_FILE, &st) if (!stat(ACRN_CONF_TIMER_LIST, &st)
&& S_ISREG(st.st_mode)) { && S_ISREG(st.st_mode)) {
ack.data.err = load_timer_list(); ack.data.err = load_timer_list();
if (ack.data.err == 0) { if (ack.data.err == 0) {
@ -602,7 +601,7 @@ void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)
} }
reply_ack: reply_ack:
unlink(TIMER_LIST_FILE); unlink(ACRN_CONF_TIMER_LIST);
if (client_fd > 0) if (client_fd > 0)
mngr_send_msg(client_fd, &ack, NULL, 0); mngr_send_msg(client_fd, &ack, NULL, 0);
@ -677,7 +676,7 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
unlink(TIMER_LIST_FILE); unlink(ACRN_CONF_TIMER_LIST);
atexit(handle_on_exit); atexit(handle_on_exit);