tools: acrnd: check weakup reason first in init_vm

This patch is mainly for:
  1. Check weakup reason first and only load timer list when reason is CBC_WK_RSN_RTC.
  2. If failing to load timer list or reason != CBC_WK_RSN_RTC, activate all vms.
  3. Add info about when we are about to activate vms reading from timer_list file.

Tracked-On: #1517
Signed-off-by: Kaige Fu <kaige.fu@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
This commit is contained in:
Kaige Fu 2018-10-18 16:06:18 +00:00 committed by Xie, Nanlin
parent acc51877f1
commit a45d961bf8

View File

@ -189,8 +189,12 @@ static int load_timer_list(void)
else else
expire = 1; expire = 1;
if (acrnd_add_work(acrnd_vm_timer_func, &arg, expire)) ret = acrnd_add_work(acrnd_vm_timer_func, &arg, expire);
ret = -1; if (ret != 0) {
fprintf(stderr, "Failed to add vm timer, errno %d", ret);
} else {
printf("vm %s will be activated at %ld seconds later\n", s1, expire);
}
} }
fclose(fp); fclose(fp);
@ -585,21 +589,25 @@ static void handle_on_exit(void)
int init_vm(void) int init_vm(void)
{ {
unsigned int wakeup_reason; unsigned int wakeup_reason;
struct stat st; int ret;
if (!stat(TIMER_LIST_FILE, &st))
if (S_ISREG(st.st_mode))
return load_timer_list();
/* init all UOSs, according wakeup_reason */ /* init all UOSs, according wakeup_reason */
wakeup_reason = get_sos_wakeup_reason(); wakeup_reason = get_sos_wakeup_reason();
if (wakeup_reason & CBC_WK_RSN_RTC) if (wakeup_reason & CBC_WK_RSN_RTC) {
return load_timer_list(); printf("Loading timer list to set vms wakeup time\n");
else { ret = load_timer_list();
/* TODO: auto start UOSs */ if (ret == 0) {
return active_all_vms(); printf("Successfully activate vms from timer list\n");
return 0;
} else {
printf("Error happens when load timer list, errno %d\n", ret);
}
} }
/* TODO: auto start UOSs */
printf("Activating all vms\n");
return active_all_vms();
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])