Skip to content

Commit 04fef4f

Browse files
lyan3wenlingz
authored andcommitted
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>
1 parent 2f30dcd commit 04fef4f

File tree

5 files changed

+28
-31
lines changed

5 files changed

+28
-31
lines changed

tools/acrn-manager/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ The ``acrnd`` daemon process provides a way for launching or resuming a UOS
102102
should the UOS shut down, either planned or unexpected. A UOS can ask ``acrnd``
103103
to set up a timer to make sure the UOS is running, even if the SOS is
104104
suspended or stopped.
105-
The ``acrnd`` daemon stores pending UOS work to ``/opt/acrn/conf/timer_list``
105+
The ``acrnd`` daemon stores pending UOS work to ``/usr/share/acrn/conf/timer_list``
106106
and sets an RTC timer to wake up the SOS or bring the SOS back up again.
107107
When ``acrnd`` daemon is restarted, it restores the previously saved timer
108108
list and launches the UOSs at the right time.

tools/acrn-manager/acrn_vm_ops.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ static void _scan_alive_vm(void)
128128
int pid;
129129
int ret;
130130

131-
ret = check_dir(ACRN_DM_SOCK_ROOT);
131+
ret = check_dir(ACRN_DM_SOCK_PATH);
132132
if (ret) {
133133
pdebug();
134134
return;
135135
}
136136

137-
dir = opendir(ACRN_DM_SOCK_ROOT);
137+
dir = opendir(ACRN_DM_SOCK_PATH);
138138
if (!dir) {
139139
pdebug();
140140
return;
@@ -223,22 +223,19 @@ static void _scan_added_vm(void)
223223
char suffix[128];
224224
int ret;
225225

226-
if (check_dir("/opt") || check_dir("/opt/acrn"))
227-
return;
228-
229-
ret = check_dir(ACRNCTL_OPT_ROOT);
226+
ret = check_dir(ACRN_CONF_PATH);
230227
if (ret) {
231228
pdebug();
232229
return;
233230
}
234231

235-
ret = check_dir("/opt/acrn/conf/add");
232+
ret = check_dir(ACRN_CONF_PATH_ADD);
236233
if (ret) {
237234
pdebug();
238235
return;
239236
}
240237

241-
dir = opendir("/opt/acrn/conf/add");
238+
dir = opendir(ACRN_CONF_PATH_ADD);
242239
if (!dir) {
243240
pdebug();
244241
return;
@@ -374,8 +371,8 @@ int start_vm(const char *vmname)
374371
{
375372
char cmd[128];
376373

377-
if (snprintf(cmd, sizeof(cmd), "bash %s/add/%s.sh $(cat %s/add/%s.args)",
378-
ACRNCTL_OPT_ROOT, vmname, ACRNCTL_OPT_ROOT, vmname) >= sizeof(cmd)) {
374+
if (snprintf(cmd, sizeof(cmd), "bash %s/%s.sh $(cat %s/%s.args)",
375+
ACRN_CONF_PATH_ADD, vmname, ACRN_CONF_PATH_ADD, vmname) >= sizeof(cmd)) {
379376
printf("ERROR: command is truncated\n");
380377
return -1;
381378
}

tools/acrn-manager/acrnctl.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include "acrnctl.h"
2424
#include "ioc.h"
2525

26-
#define ACRNCTL_OPT_ROOT "/opt/acrn/conf"
27-
2826
#define ACMD(CMD,FUNC,DESC, VALID_ARGS) \
2927
{.cmd = CMD, .func = FUNC, .desc = DESC, .valid_args = VALID_ARGS}
3028

@@ -330,7 +328,7 @@ static int acrnctl_do_add(int argc, char *argv[])
330328
goto get_vmname;
331329
}
332330

333-
if (snprintf(cmd, sizeof(cmd), "mkdir -p %s/add", ACRNCTL_OPT_ROOT)
331+
if (snprintf(cmd, sizeof(cmd), "mkdir -p %s", ACRN_CONF_PATH_ADD)
334332
>= sizeof(cmd)) {
335333
printf("ERROR: cmd is truncated\n");
336334
ret = -1;
@@ -346,16 +344,16 @@ static int acrnctl_do_add(int argc, char *argv[])
346344
goto vm_exist;
347345
}
348346

349-
if (snprintf(cmd, sizeof(cmd), "cp %s.back %s/add/%s.sh", argv[1],
350-
ACRNCTL_OPT_ROOT, vmname) >= sizeof(cmd)) {
347+
if (snprintf(cmd, sizeof(cmd), "cp %s.back %s/%s.sh", argv[1],
348+
ACRN_CONF_PATH_ADD, vmname) >= sizeof(cmd)) {
351349
printf("ERROR: cmd is truncated\n");
352350
ret = -1;
353351
goto vm_exist;
354352
}
355353
system(cmd);
356354

357-
if (snprintf(cmd, sizeof(cmd), "echo %s >%s/add/%s.args", args,
358-
ACRNCTL_OPT_ROOT, vmname) >= sizeof(cmd)) {
355+
if (snprintf(cmd, sizeof(cmd), "echo %s >%s/%s.args", args,
356+
ACRN_CONF_PATH_ADD, vmname) >= sizeof(cmd)) {
359357
printf("ERROR: cmd is truncated\n");
360358
ret = -1;
361359
goto vm_exist;
@@ -438,14 +436,14 @@ static int acrnctl_do_del(int argc, char *argv[])
438436
state_str[s->state]);
439437
continue;
440438
}
441-
if (snprintf(cmd, sizeof(cmd), "rm -f %s/add/%s.sh",
442-
ACRNCTL_OPT_ROOT, argv[i]) >= sizeof(cmd)) {
439+
if (snprintf(cmd, sizeof(cmd), "rm -f %s/%s.sh",
440+
ACRN_CONF_PATH_ADD, argv[i]) >= sizeof(cmd)) {
443441
printf("WARN: cmd is truncated\n");
444442
return -1;
445443
}
446444
system(cmd);
447-
if (snprintf(cmd, sizeof(cmd), "rm -f %s/add/%s.args",
448-
ACRNCTL_OPT_ROOT, argv[i]) >= sizeof(cmd)) {
445+
if (snprintf(cmd, sizeof(cmd), "rm -f %s/%s.args",
446+
ACRN_CONF_PATH_ADD, argv[i]) >= sizeof(cmd)) {
449447
printf("WARN: cmd is truncated\n");
450448
return -1;
451449
}

tools/acrn-manager/acrnctl.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
#include <sys/queue.h>
1010

11-
#define ACRNCTL_OPT_ROOT "/opt/acrn/conf"
12-
#define ACRN_DM_SOCK_ROOT "/run/acrn/mngr"
11+
#define ACRN_CONF_PATH "/usr/share/acrn/conf"
12+
#define ACRN_CONF_PATH_ADD ACRN_CONF_PATH "/add"
13+
#define ACRN_CONF_TIMER_LIST ACRN_CONF_PATH "/timer_list"
14+
15+
#define ACRN_DM_SOCK_PATH "/run/acrn/mngr"
1316

1417
#define MAX_NAME_LEN (32)
1518

tools/acrn-manager/acrnd.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ void acrnd_vm_timer_func(struct work_arg *arg)
143143
}
144144
}
145145

146-
#define TIMER_LIST_FILE "/opt/acrn/conf/timer_list"
147146
static pthread_mutex_t timer_file_mutex = PTHREAD_MUTEX_INITIALIZER;
148147

149148
/* load/store_timer_list to file to keep timers if SOS poweroff */
@@ -157,7 +156,7 @@ static int load_timer_list(void)
157156

158157
pthread_mutex_lock(&timer_file_mutex);
159158

160-
fp = fopen(TIMER_LIST_FILE, "r");
159+
fp = fopen(ACRN_CONF_TIMER_LIST, "r");
161160
if (!fp) {
162161
perror("Open timer list file");
163162
ret = -1;
@@ -402,7 +401,7 @@ static int store_timer_list(void)
402401
int ret = 0;
403402

404403
pthread_mutex_lock(&timer_file_mutex);
405-
fp = fopen(TIMER_LIST_FILE, "w+");
404+
fp = fopen(ACRN_CONF_TIMER_LIST, "w+");
406405
if (!fp) {
407406
perror("Open timer list file");
408407
ret = -1;
@@ -429,7 +428,7 @@ static int store_timer_list(void)
429428
if (sys_wakeup) {
430429
set_sos_timer(sys_wakeup);
431430
} else {
432-
unlink(TIMER_LIST_FILE);
431+
unlink(ACRN_CONF_TIMER_LIST);
433432
}
434433

435434
fclose(fp);
@@ -584,7 +583,7 @@ void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)
584583

585584
if (wakeup_reason & CBC_WK_RSN_RTC) {
586585
/* wakeup by RTC timer */
587-
if (!stat(TIMER_LIST_FILE, &st)
586+
if (!stat(ACRN_CONF_TIMER_LIST, &st)
588587
&& S_ISREG(st.st_mode)) {
589588
ack.data.err = load_timer_list();
590589
if (ack.data.err == 0) {
@@ -602,7 +601,7 @@ void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)
602601
}
603602

604603
reply_ack:
605-
unlink(TIMER_LIST_FILE);
604+
unlink(ACRN_CONF_TIMER_LIST);
606605

607606
if (client_fd > 0)
608607
mngr_send_msg(client_fd, &ack, NULL, 0);
@@ -677,7 +676,7 @@ int main(int argc, char *argv[])
677676
return -1;
678677
}
679678

680-
unlink(TIMER_LIST_FILE);
679+
unlink(ACRN_CONF_TIMER_LIST);
681680

682681
atexit(handle_on_exit);
683682

0 commit comments

Comments
 (0)