tools: acrnctl: Add support for resuming vm
Add command resume to resume vm from suspend state. Signed-off-by: Kaige Fu <kaige.fu@intel.com> Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com> Reviewed-by: Yan, Like <like.yan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
d6eb39daf4
commit
7a0e8ddeec
|
@ -30,6 +30,7 @@ You can see the available ``acrnctl`` commands by running:
|
|||
pause
|
||||
continue
|
||||
suspend
|
||||
resume
|
||||
Use acrnctl [cmd] help for details
|
||||
|
||||
Here are some usage examples:
|
||||
|
|
|
@ -260,3 +260,23 @@ int suspend_vm(char *vmname)
|
|||
|
||||
return ack.err;
|
||||
}
|
||||
|
||||
int resume_vm(char *vmname)
|
||||
{
|
||||
struct req_dm_resume req;
|
||||
struct ack_dm_resume ack;
|
||||
|
||||
req.msg.magic = MNGR_MSG_MAGIC;
|
||||
req.msg.msgid = DM_RESUME;
|
||||
req.msg.timestamp = time(NULL);
|
||||
req.msg.len = sizeof(req);
|
||||
|
||||
send_msg(vmname, (struct mngr_msg *)&req,
|
||||
(struct mngr_msg *)&ack, sizeof(ack));
|
||||
|
||||
if (ack.err) {
|
||||
printf("Unable to resume vm. errno(%d)\n", ack.err);
|
||||
}
|
||||
|
||||
return ack.err;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#define PAUSE_DESC "Block all vCPUs of virtual machine VM_NAME"
|
||||
#define CONTINUE_DESC "Start virtual machine from pause state"
|
||||
#define SUSPEND_DESC "Switch virtual machine to suspend state"
|
||||
#define RESUME_DESC "Resume virtual machine from suspend state"
|
||||
|
||||
struct acrnctl_cmd {
|
||||
const char *cmd;
|
||||
|
@ -461,6 +462,35 @@ static int acrnctl_do_suspend(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int acrnctl_do_resume(int argc, char *argv[])
|
||||
{
|
||||
struct vmmngr_struct *s;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
s = vmmngr_find(argv[i]);
|
||||
if (!s) {
|
||||
printf("Can't find vm %s\n", argv[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Per current implemention, we can't know if vm is in suspended
|
||||
state. Send reume cmd to acrn-dm when VM_STARTED and will
|
||||
correct it later when we have a way to check if vm has been
|
||||
suspended */
|
||||
switch (s->state) {
|
||||
case VM_STARTED:
|
||||
resume_vm(argv[i]);
|
||||
break;
|
||||
default:
|
||||
printf("%s current state %s, can't resume\n",
|
||||
argv[i], state_str[s->state]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Default args validation function */
|
||||
int df_valid_args(struct acrnctl_cmd *cmd, int argc, char *argv[])
|
||||
{
|
||||
|
@ -517,6 +547,7 @@ struct acrnctl_cmd acmds[] = {
|
|||
ACMD("pause", acrnctl_do_pause, PAUSE_DESC, df_valid_args),
|
||||
ACMD("continue", acrnctl_do_continue, CONTINUE_DESC, df_valid_args),
|
||||
ACMD("suspend", acrnctl_do_suspend, SUSPEND_DESC, df_valid_args),
|
||||
ACMD("resume", acrnctl_do_resume, RESUME_DESC, df_valid_args),
|
||||
};
|
||||
|
||||
#define NCMD (sizeof(acmds)/sizeof(struct acrnctl_cmd))
|
||||
|
|
|
@ -62,5 +62,6 @@ int start_vm(char *vmname);
|
|||
int pause_vm(char *vmname);
|
||||
int continue_vm(char *vmname);
|
||||
int suspend_vm(char *vmname);
|
||||
int resume_vm(char *vmname);
|
||||
|
||||
#endif /* _ACRNCTL_H_ */
|
||||
|
|
Loading…
Reference in New Issue