tools: add force parameter to acrn VM stop operations

Add 'force' parameter to acrn_stop(), which will be write to request
message, the value of data.acrnd_stop.force. So we can tell DM to
force stop VM, instead of telling UOS to shutdown itself.

Tracked-On: #3484
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
This commit is contained in:
yuhong.tao@intel.com 2019-06-27 14:05:02 +00:00 committed by ACRN System Integration
parent d1c8a514f6
commit 59fd4202d3
4 changed files with 7 additions and 5 deletions

View File

@ -366,7 +366,7 @@ int start_vm(const char *vmname)
return system(cmd);
}
int stop_vm(const char *vmname)
int stop_vm(const char *vmname, int force)
{
struct mngr_msg req;
struct mngr_msg ack;
@ -374,6 +374,7 @@ int stop_vm(const char *vmname)
req.magic = MNGR_MSG_MAGIC;
req.msgid = DM_STOP;
req.timestamp = time(NULL);
req.data.acrnd_stop.force = force;
send_msg(vmname, &req, &ack);
if (ack.data.err) {

View File

@ -442,6 +442,7 @@ static int acrnctl_do_blkrescan(int argc, char *argv[])
static int acrnctl_do_stop(int argc, char *argv[])
{
struct vmmngr_struct *s;
int force = 0;
s = vmmngr_find(argv[1]);
if (!s) {
@ -452,7 +453,7 @@ static int acrnctl_do_stop(int argc, char *argv[])
printf("%s is already (%s)\n", argv[1], state_str[s->state]);
return -1;
}
return stop_vm(argv[1]);
return stop_vm(argv[1], force);
}
@ -697,7 +698,7 @@ static int acrnctl_do_reset(int argc, char *argv[])
switch(s->state) {
case VM_STARTED:
case VM_SUSPENDED:
ret = stop_vm(argv[1]);
ret = stop_vm(argv[1], 0);
if (ret != 0) {
break;
}

View File

@ -52,7 +52,7 @@ extern struct vmmngr_list_struct vmmngr_head;
/* vm life cycle ops */
int list_vm(void);
int stop_vm(const char *vmname);
int stop_vm(const char *vmname, int force);
int start_vm(const char *vmname);
int pause_vm(const char *vmname);
int continue_vm(const char *vmname);

View File

@ -289,7 +289,7 @@ static void stop_all_vms(void)
vmmngr_update();
LIST_FOREACH(vm, &vmmngr_head, list) {
err = stop_vm(vm->name);
err = stop_vm(vm->name, 0);
if (err != 0) {
fprintf(stderr, "Fail to send stop cmd to vm %s\n", vm->name);
} else {