mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-09 12:08:30 +00:00
tools: acrnd: the deamon for acrn-manager
There will be a daemon running on SOS: to forward wakeup_reason to acrn-dm; to co-ordinate the lifecycle of VMs and SOS; to handle ioc-timed wakeup/poweron. 1.to forward wakeup_reason to acrn-dm acrnd is responsible to retrive wakeup_reason from SOS lifecycle service and attach the wakeup_reason to acrn-dm parameter for ioc-dm; 2.co-ordinate the lifecycle of VMs and SOS When SOS is about to suspend/shutdown, SOS lifecycle service will send a request to acrnd to guarantee all guest VMs are suspended or shutdown before SOS suspending/shutdown process continue. On receiver the request, acrnd starts polling the guest VMs state, and notify SOS lifecycle service when all guest VMs are put in proper state gracefully. 3.handle ioc-timed wakeup/poweron For vechile specific mode like garage mode, guest UOS may need to wakeup/poweron in a future time for tasks such as map updating etc. To setup a timed wakeup/poweron, ioc-dm will send request to acrnd, acrnd maintains a list of timed requests from guest VMs, and acrnd selects the nearest request and send it to SOS lifecycle service who will setup the physical IOC. Reviewed-by: Yan Like <like.yan@intel.com> Acked-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com> Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
This commit is contained in:
parent
c4f9a2fd70
commit
bcb101f4f0
@ -4,6 +4,8 @@ OUT_DIR ?= .
|
||||
CFLAGS := -Wall
|
||||
CFLAGS += -I../../devicemodel/include
|
||||
CFLAGS += -I../../devicemodel/include/public
|
||||
CFLAGS += -I../../hypervisor/include
|
||||
|
||||
ifeq ($(RELEASE),0)
|
||||
CFLAGS += -g -DMNGR_DEBUG
|
||||
endif
|
||||
@ -13,7 +15,7 @@ LDFLAGS += -lacrn-mngr
|
||||
LDFLAGS += -lpthread
|
||||
|
||||
.PHONY: all
|
||||
all: $(OUT_DIR)/libacrn-mngr.a $(OUT_DIR)/acrn_mngr.h $(OUT_DIR)/acrnctl
|
||||
all: $(OUT_DIR)/libacrn-mngr.a $(OUT_DIR)/acrn_mngr.h $(OUT_DIR)/acrnctl $(OUT_DIR)/acrnd
|
||||
|
||||
$(OUT_DIR)/libacrn-mngr.a: acrn_mngr.c acrn_mngr.h
|
||||
$(CC) $(CFLAGS) -c acrn_mngr.c -o $(OUT_DIR)/acrn_mngr.o
|
||||
@ -27,6 +29,12 @@ endif
|
||||
$(OUT_DIR)/acrnctl: acrnctl.c acrn_mngr.h $(OUT_DIR)/libacrn-mngr.a
|
||||
$(CC) -o $(OUT_DIR)/acrnctl acrnctl.c acrn_vm_ops.c $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
$(OUT_DIR)/acrnd: acrnd.c $(OUT_DIR)/libacrn-mngr.a
|
||||
$(CC) -o $(OUT_DIR)/acrnd acrnd.c acrn_vm_ops.c $(CFLAGS) $(LDFLAGS)
|
||||
ifneq ($(OUT_DIR),.)
|
||||
cp ./acrnd.service $(OUT_DIR)/acrnd.service
|
||||
endif
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(OUT_DIR)/acrnctl
|
||||
@ -34,9 +42,14 @@ clean:
|
||||
rm -f $(OUT_DIR)/libacrn-mngr.a
|
||||
ifneq ($(OUT_DIR),.)
|
||||
rm -f $(OUT_DIR)/acrn_mngr.h
|
||||
rm -f $(OUT_DIR)/acrnd.service
|
||||
endif
|
||||
rm -f $(OUT_DIR)/acrnd
|
||||
|
||||
.PHONY: install
|
||||
install: $(OUT_DIR)/acrnctl
|
||||
install -d $(DESTDIR)/usr/bin
|
||||
install -d $(DESTDIR)/usr/lib/systemd/system
|
||||
install -t $(DESTDIR)/usr/bin $(OUT_DIR)/acrnctl
|
||||
install -t $(DESTDIR)/usr/bin $(OUT_DIR)/acrnd
|
||||
install -p -D -m 0644 $(OUT_DIR)/acrnd.service $(DESTDIR)/usr/lib/systemd/system
|
||||
|
114
tools/acrn-manager/acrnd.c
Normal file
114
tools/acrn-manager/acrnd.c
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (C)2018 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include "mevent.h"
|
||||
#include "acrnctl.h"
|
||||
#include "acrn_mngr.h"
|
||||
#include "ioc.h"
|
||||
|
||||
#define TIMER_LIST_FILE "/opt/acrn/conf/timer_list"
|
||||
|
||||
/* load/store_timer_list to file to keep timers if SOS poweroff */
|
||||
int load_timer_list(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int active_all_vms(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define SOS_LCS_SOCK "sos-lcs"
|
||||
#define ACRND_NAME "acrnd"
|
||||
static int acrnd_fd = -1;
|
||||
|
||||
unsigned get_sos_wakeup_reason(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void handle_timer_req(struct mngr_msg *msg, int client_fd, void *param)
|
||||
{
|
||||
}
|
||||
|
||||
static int store_timer_list(void)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void handle_acrnd_stop(struct mngr_msg *msg, int client_fd, void *param)
|
||||
{
|
||||
}
|
||||
|
||||
void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)
|
||||
{
|
||||
}
|
||||
|
||||
static void handle_on_exit(void)
|
||||
{
|
||||
store_timer_list();
|
||||
|
||||
if (acrnd_fd > 0) {
|
||||
mngr_close(acrnd_fd);
|
||||
acrnd_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
/* 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();
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* create listening thread */
|
||||
acrnd_fd = mngr_open_un(ACRND_NAME, MNGR_SERVER);
|
||||
if (acrnd_fd < 0) {
|
||||
pdebug();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (init_vm()) {
|
||||
pdebug();
|
||||
return -1;
|
||||
}
|
||||
|
||||
unlink(TIMER_LIST_FILE);
|
||||
|
||||
atexit(handle_on_exit);
|
||||
|
||||
mngr_add_handler(acrnd_fd, ACRND_TIMER, handle_timer_req, NULL);
|
||||
mngr_add_handler(acrnd_fd, ACRND_STOP, handle_acrnd_stop, NULL);
|
||||
mngr_add_handler(acrnd_fd, ACRND_RESUME, handle_acrnd_resume, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
11
tools/acrn-manager/acrnd.service
Normal file
11
tools/acrn-manager/acrnd.service
Normal file
@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=ACRN manager deamon
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/acrnd
|
||||
ExecStop=/usr/bin/killall -s TERM acrnd
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
Loading…
Reference in New Issue
Block a user