Files
acrn-hypervisor/tools/acrn-manager/acrnctl.h
yuhong.tao@intel.com c4f9a2fd70 tools: rework on vm ops
There are some problems to use VM operations in a deamon process,
such as Acrnd.  the list_vm() does not return VM informations, it
just print VM information to stdio, so we have get_vm_list()
to get VM list head vmngr_head; get_vm_list() always creates a
new fresh vm list every time, and must use put_vm_list() to delete
old list. So Acrnd need to create and destroy vm list frequently.
In fact we just need the vmngr_head to be an extern variable. And
to make it refreshable.We can insert new VMs, remove dead ones,
and update their state.

Reviewed-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
2018-07-16 16:04:34 +08:00

62 lines
1.6 KiB
C

/**
* Copyright (C) 2018 Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _ACRNCTL_H_
#define _ACRNCTL_H_
#include <sys/queue.h>
#define ACRNCTL_OPT_ROOT "/opt/acrn/conf"
#define ACRN_DM_SOCK_ROOT "/run/acrn/mngr"
#define MAX_NAME_LEN (16)
enum vm_state {
VM_STATE_UNKNOWN = 0,
VM_CREATED, /* VM created / awaiting start (boot) */
VM_STARTED, /* VM started (booted) */
VM_PAUSED, /* VM paused */
VM_UNTRACKED, /* VM not created by acrnctl, or its launch script can change vm name */
};
extern const char *state_str[];
/**
* @brief search vm indentified by vm from vmmngr_head
*
* @return vmmngr_struct * if find, NULL not find
*/
struct vmmngr_struct *vmmngr_find(char *vmname);
/* Per-vm vm managerment struct */
struct vmmngr_struct {
char name[MAX_NAME_LEN];
unsigned long state;
unsigned long update; /* update count, remove a vm if no update for it */
LIST_ENTRY(vmmngr_struct) list;
};
int shell_cmd(const char *cmd, char *outbuf, int len);
/* update names and states of VMs in SOS
* before you stop, start, pause, resume, suspend continue a VM
* use a name, it is better to run vmmngr_update() first
* and use vmngr_find() to check is this VM is still available
*/
void vmmngr_update(void);
extern LIST_HEAD(vmmngr_list_struct, vmmngr_struct) vmmngr_head;
/* vm life cycle ops */
int list_vm(void);
int stop_vm(char *vmname);
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_ */