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
expire = 1;
if (acrnd_add_work(acrnd_vm_timer_func, &arg, expire))
ret = -1;
ret = acrnd_add_work(acrnd_vm_timer_func, &arg, expire);
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);
@ -585,21 +589,25 @@ static void handle_on_exit(void)
int init_vm(void)
{
unsigned int wakeup_reason;
struct stat st;
if (!stat(TIMER_LIST_FILE, &st))
if (S_ISREG(st.st_mode))
return load_timer_list();
int ret;
/* init all UOSs, according wakeup_reason */
wakeup_reason = get_sos_wakeup_reason();
if (wakeup_reason & CBC_WK_RSN_RTC)
return load_timer_list();
else {
/* TODO: auto start UOSs */
return active_all_vms();
if (wakeup_reason & CBC_WK_RSN_RTC) {
printf("Loading timer list to set vms wakeup time\n");
ret = load_timer_list();
if (ret == 0) {
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[])