From a45d961bf83e41ab0871be459e101b375af11945 Mon Sep 17 00:00:00 2001 From: Kaige Fu Date: Thu, 18 Oct 2018 16:06:18 +0000 Subject: [PATCH] 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 Acked-by: Yan, Like --- tools/acrn-manager/acrnd.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/tools/acrn-manager/acrnd.c b/tools/acrn-manager/acrnd.c index 979c06c54..bc4dac595 100644 --- a/tools/acrn-manager/acrnd.c +++ b/tools/acrn-manager/acrnd.c @@ -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[])