tools: acrnd: handle stop request from SOS-LCS

SOS-Life-Cycle-Service can ask acrnd to stop UOSs, by sending
ACRND_STOP to Acrnd. Acrnd handles this request by:
1. Try stop all running VMs, and return the result to SOS-LCS.
2. Store pending works of restarting/resuming VMs to file

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
This commit is contained in:
yuhong.tao@intel.com 2018-06-26 18:49:02 +08:00 committed by lijinxia
parent bcb101f4f0
commit 04ed916f26

View File

@ -50,8 +50,50 @@ static int store_timer_list(void)
return -1;
}
static int check_vms_status(unsigned int status)
{
struct vmmngr_struct *s;
vmmngr_update();
LIST_FOREACH(s, &vmmngr_head, list)
if (s->state != status && s->state != VM_CREATED)
return -1;
return 0;
}
static int _handle_acrnd_stop(unsigned int timeout)
{
unsigned long t = timeout;
/*Let ospm stopping UOSs */
/* list and update the vm status */
do {
if (check_vms_status(VM_CREATED) == 0)
return 0;
sleep(1);
}
while (t--);
return -1;
}
static void handle_acrnd_stop(struct mngr_msg *msg, int client_fd, void *param)
{
struct req_acrnd_stop *req = (void *)msg;
struct ack_acrnd_stop ack;
ack.msg.msgid = req->msg.msgid;
ack.msg.len = sizeof(ack);
ack.msg.timestamp = req->msg.timestamp;
ack.err = _handle_acrnd_stop(req->timeout);
store_timer_list();
if (client_fd > 0)
mngr_send_msg(client_fd, (void *)&ack, NULL, 0, 0);
}
void handle_acrnd_resume(struct mngr_msg *msg, int client_fd, void *param)