|
36 | 36 | #define CONTINUE_DESC "Start virtual machine from pause state"
|
37 | 37 | #define SUSPEND_DESC "Switch virtual machine to suspend state"
|
38 | 38 | #define RESUME_DESC "Resume virtual machine from suspend state"
|
| 39 | +#define RESET_DESC "Stop and then start virtual machine VM_NAME" |
39 | 40 |
|
40 | 41 | struct acrnctl_cmd {
|
41 | 42 | const char *cmd;
|
@@ -491,6 +492,35 @@ static int acrnctl_do_resume(int argc, char *argv[])
|
491 | 492 | return 0;
|
492 | 493 | }
|
493 | 494 |
|
| 495 | +static int acrnctl_do_reset(int argc, char *argv[]) |
| 496 | +{ |
| 497 | + struct vmmngr_struct *s; |
| 498 | + int i; |
| 499 | + |
| 500 | + for (i = 1; i < argc; i++) { |
| 501 | + s = vmmngr_find(argv[i]); |
| 502 | + if (!s) { |
| 503 | + printf("Can't find vm %s\n", argv[i]); |
| 504 | + continue; |
| 505 | + } |
| 506 | + |
| 507 | + switch(s->state) { |
| 508 | + case VM_CREATED: |
| 509 | + start_vm(argv[i]); |
| 510 | + break; |
| 511 | + case VM_STARTED: |
| 512 | + case VM_PAUSED: |
| 513 | + stop_vm(argv[i]); |
| 514 | + start_vm(argv[i]); |
| 515 | + break; |
| 516 | + default: |
| 517 | + printf("%s current state: %s, can't reset\n", |
| 518 | + argv[i], state_str[s->state]); |
| 519 | + } |
| 520 | + } |
| 521 | + return 0; |
| 522 | +} |
| 523 | + |
494 | 524 | /* Default args validation function */
|
495 | 525 | int df_valid_args(struct acrnctl_cmd *cmd, int argc, char *argv[])
|
496 | 526 | {
|
@@ -548,6 +578,7 @@ struct acrnctl_cmd acmds[] = {
|
548 | 578 | ACMD("continue", acrnctl_do_continue, CONTINUE_DESC, df_valid_args),
|
549 | 579 | ACMD("suspend", acrnctl_do_suspend, SUSPEND_DESC, df_valid_args),
|
550 | 580 | ACMD("resume", acrnctl_do_resume, RESUME_DESC, df_valid_args),
|
| 581 | + ACMD("reset", acrnctl_do_reset, RESET_DESC, df_valid_args), |
551 | 582 | };
|
552 | 583 |
|
553 | 584 | #define NCMD (sizeof(acmds)/sizeof(struct acrnctl_cmd))
|
|
0 commit comments