DM: monitor support force stop

When someone send DM message DM_STOP, with a non-zero data.acrnd_stop.force
value, DM set suspend mode to VM_SUSPEND_POWEROFF directly, that will
cause DM quit main loop. That can force stop VM

Tracked-On: #3484
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
This commit is contained in:
yuhong.tao@intel.com 2019-06-27 14:44:18 +00:00 committed by ACRN System Integration
parent 8b27daa778
commit 653aa859b1
1 changed files with 32 additions and 1 deletions

View File

@ -337,11 +337,42 @@ static void name(struct mngr_msg *msg, int client_fd, void *param) \
mngr_send_msg(client_fd, &ack, NULL, ACK_TIMEOUT); \
}
DEFINE_HANDLER(handle_stop, stop);
DEFINE_HANDLER(handle_suspend, suspend);
DEFINE_HANDLER(handle_pause, pause);
DEFINE_HANDLER(handle_continue, unpause);
static void handle_stop(struct mngr_msg *msg, int client_fd, void *param)
{
struct mngr_msg ack;
struct vm_ops *ops;
int ret = 0;
int count = 0;
ack.magic = MNGR_MSG_MAGIC;
ack.msgid = msg->msgid;
ack.timestamp = msg->timestamp;
if (msg->data.acrnd_stop.force) {
vm_set_suspend_mode(VM_SUSPEND_POWEROFF);
ack.data.err = 0;
} else {
LIST_FOREACH(ops, &vm_ops_head, list) {
if (ops->ops->stop) {
ret += ops->ops->stop(ops->arg);
count++;
}
}
if (!count) {
ack.data.err = -1;
pr_err("No handler for id:%u\r\n", msg->msgid);
} else
ack.data.err = ret;
}
mngr_send_msg(client_fd, &ack, NULL, ACK_TIMEOUT);
}
static void handle_resume(struct mngr_msg *msg, int client_fd, void *param)
{
struct mngr_msg ack;