Skip to content

Commit 8b27daa

Browse files
taoyuhongacrnsi
authored andcommitted
tools: acrnctl add '--force' option to 'stop' cmd
Run 'acrnctl stop VM_NAME --force‘ to force stop VM When run 'acrnctl stop VM_NAME', acrn-dm let guest OS to shutdown itself. If something wrong with guest OS, it can't shutdown, we can run 'acrnctl stop VM_NAME --force', thus acrn-dm directly set suspend mode to VM_SUSPEND_POWEROFF and quit main loop. Tracked-On: #3484 Signed-off-by: Tao Yuhong <yuhong.tao@intel.com> Reviewed-by: Yan, Like <like.yan@intel.com>
1 parent 59fd420 commit 8b27daa

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

misc/acrn-manager/acrnctl.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/* vm life cycle cmd description */
3030
#define LIST_DESC "List all the virtual machines added"
3131
#define START_DESC "Start virtual machine VM_NAME"
32-
#define STOP_DESC "Stop virtual machine VM_NAME"
32+
#define STOP_DESC "Stop virtual machine VM_NAME, [--force/-f, force to stop VM]"
3333
#define DEL_DESC "Delete virtual machine VM_NAME"
3434
#define ADD_DESC "Add one virtual machine with SCRIPTS and OPTIONS"
3535
#define PAUSE_DESC "Block all vCPUs of virtual machine VM_NAME"
@@ -442,18 +442,34 @@ static int acrnctl_do_blkrescan(int argc, char *argv[])
442442
static int acrnctl_do_stop(int argc, char *argv[])
443443
{
444444
struct vmmngr_struct *s;
445-
int force = 0;
445+
int i, force = 0;
446+
const char *vmname = NULL;
446447

447-
s = vmmngr_find(argv[1]);
448+
for (i = 1; i < argc; i++) {
449+
if (strcmp(argv[i], "--force") && strcmp(argv[i], "-f")) {
450+
if (vmname == NULL)
451+
vmname = argv[i];
452+
} else {
453+
force = 1;
454+
}
455+
}
456+
457+
if (!vmname) {
458+
printf("Please give a VM name\n");
459+
return -1;
460+
}
461+
462+
s = vmmngr_find(vmname);
448463
if (!s) {
449-
printf("can't find %s\n", argv[1]);
464+
printf("can't find %s\n", vmname);
450465
return -1;
451466
}
452467
if (s->state == VM_CREATED) {
453-
printf("%s is already (%s)\n", argv[1], state_str[s->state]);
468+
printf("%s is already (%s)\n", vmname, state_str[s->state]);
454469
return -1;
455470
}
456-
return stop_vm(argv[1], force);
471+
472+
return stop_vm(vmname, force);
457473

458474
}
459475

0 commit comments

Comments
 (0)