Skip to content

Commit 653aa85

Browse files
taoyuhongacrnsi
authored andcommitted
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>
1 parent 8b27daa commit 653aa85

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

devicemodel/core/monitor.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,42 @@ static void name(struct mngr_msg *msg, int client_fd, void *param) \
337337
mngr_send_msg(client_fd, &ack, NULL, ACK_TIMEOUT); \
338338
}
339339

340-
DEFINE_HANDLER(handle_stop, stop);
341340
DEFINE_HANDLER(handle_suspend, suspend);
342341
DEFINE_HANDLER(handle_pause, pause);
343342
DEFINE_HANDLER(handle_continue, unpause);
344343

344+
static void handle_stop(struct mngr_msg *msg, int client_fd, void *param)
345+
{
346+
struct mngr_msg ack;
347+
struct vm_ops *ops;
348+
int ret = 0;
349+
int count = 0;
350+
351+
ack.magic = MNGR_MSG_MAGIC;
352+
ack.msgid = msg->msgid;
353+
ack.timestamp = msg->timestamp;
354+
355+
if (msg->data.acrnd_stop.force) {
356+
vm_set_suspend_mode(VM_SUSPEND_POWEROFF);
357+
ack.data.err = 0;
358+
} else {
359+
LIST_FOREACH(ops, &vm_ops_head, list) {
360+
if (ops->ops->stop) {
361+
ret += ops->ops->stop(ops->arg);
362+
count++;
363+
}
364+
}
365+
366+
if (!count) {
367+
ack.data.err = -1;
368+
pr_err("No handler for id:%u\r\n", msg->msgid);
369+
} else
370+
ack.data.err = ret;
371+
}
372+
373+
mngr_send_msg(client_fd, &ack, NULL, ACK_TIMEOUT);
374+
}
375+
345376
static void handle_resume(struct mngr_msg *msg, int client_fd, void *param)
346377
{
347378
struct mngr_msg ack;

0 commit comments

Comments
 (0)