|
29 | 29 | /* vm life cycle cmd description */
|
30 | 30 | #define LIST_DESC "List all the virtual machines added"
|
31 | 31 | #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]" |
33 | 33 | #define DEL_DESC "Delete virtual machine VM_NAME"
|
34 | 34 | #define ADD_DESC "Add one virtual machine with SCRIPTS and OPTIONS"
|
35 | 35 | #define PAUSE_DESC "Block all vCPUs of virtual machine VM_NAME"
|
@@ -442,18 +442,34 @@ static int acrnctl_do_blkrescan(int argc, char *argv[])
|
442 | 442 | static int acrnctl_do_stop(int argc, char *argv[])
|
443 | 443 | {
|
444 | 444 | struct vmmngr_struct *s;
|
445 |
| - int force = 0; |
| 445 | + int i, force = 0; |
| 446 | + const char *vmname = NULL; |
446 | 447 |
|
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); |
448 | 463 | if (!s) {
|
449 |
| - printf("can't find %s\n", argv[1]); |
| 464 | + printf("can't find %s\n", vmname); |
450 | 465 | return -1;
|
451 | 466 | }
|
452 | 467 | 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]); |
454 | 469 | return -1;
|
455 | 470 | }
|
456 |
| - return stop_vm(argv[1], force); |
| 471 | + |
| 472 | + return stop_vm(vmname, force); |
457 | 473 |
|
458 | 474 | }
|
459 | 475 |
|
|
0 commit comments