mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-02 20:35:32 +00:00
acrn-dm: add some logs for vm state transition
add logs for vm state transition to help analyze some problems. Tracked-On: #4098 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
parent
e58609ad1f
commit
4d3221a7f3
@ -615,6 +615,7 @@ vm_system_reset(struct vmctx *ctx)
|
||||
|
||||
vm_reset_vdevs(ctx);
|
||||
vm_reset(ctx);
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_NONE));
|
||||
vm_set_suspend_mode(VM_SUSPEND_NONE);
|
||||
|
||||
/* set the BSP init state */
|
||||
@ -711,7 +712,8 @@ num_vcpus_allowed(struct vmctx *ctx)
|
||||
static void
|
||||
sig_handler_term(int signo)
|
||||
{
|
||||
printf("Receive SIGINT to terminate application...\n");
|
||||
pr_info("Received SIGINT to terminate application...\n");
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_POWEROFF));
|
||||
vm_set_suspend_mode(VM_SUSPEND_POWEROFF);
|
||||
mevent_notify();
|
||||
}
|
||||
@ -1065,6 +1067,7 @@ main(int argc, char *argv[])
|
||||
vm_destroy(ctx);
|
||||
_ctx = 0;
|
||||
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_NONE));
|
||||
vm_set_suspend_mode(VM_SUSPEND_NONE);
|
||||
}
|
||||
|
||||
|
@ -351,6 +351,7 @@ static void handle_stop(struct mngr_msg *msg, int client_fd, void *param)
|
||||
ack.timestamp = msg->timestamp;
|
||||
|
||||
if (msg->data.acrnd_stop.force && !is_rtvm) {
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_POWEROFF));
|
||||
vm_set_suspend_mode(VM_SUSPEND_POWEROFF);
|
||||
ack.data.err = 0;
|
||||
} else {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
#include "vmmapi.h"
|
||||
#include "log.h"
|
||||
|
||||
static pthread_cond_t suspend_cond = PTHREAD_COND_INITIALIZER;
|
||||
static pthread_mutex_t suspend_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@ -27,6 +28,7 @@ int
|
||||
vm_resume(struct vmctx *ctx)
|
||||
{
|
||||
pthread_mutex_lock(&suspend_mutex);
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_NONE));
|
||||
vm_set_suspend_mode(VM_SUSPEND_NONE);
|
||||
pthread_cond_signal(&suspend_cond);
|
||||
pthread_mutex_unlock(&suspend_mutex);
|
||||
|
@ -60,6 +60,22 @@
|
||||
#define SUPPORT_VHM_API_VERSION_MAJOR 1
|
||||
#define SUPPORT_VHM_API_VERSION_MINOR 0
|
||||
|
||||
#define VM_STATE_STR_LEN 16
|
||||
static const char vm_state_str[VM_SUSPEND_LAST][VM_STATE_STR_LEN] = {
|
||||
[VM_SUSPEND_NONE] = "RUNNING",
|
||||
[VM_SUSPEND_SYSTEM_RESET] = "SYSTEM_RESET",
|
||||
[VM_SUSPEND_FULL_RESET] = "FULL_RESET",
|
||||
[VM_SUSPEND_POWEROFF] = "POWEROFF",
|
||||
[VM_SUSPEND_SUSPEND] = "SUSPEND",
|
||||
[VM_SUSPEND_HALT] = "HALT",
|
||||
[VM_SUSPEND_TRIPLEFAULT] = "TRIPLEFAULT"
|
||||
};
|
||||
|
||||
const char *vm_state_to_str(enum vm_suspend_how idx)
|
||||
{
|
||||
return (idx < VM_SUSPEND_LAST) ? vm_state_str[idx] : "UNKNOWN";
|
||||
}
|
||||
|
||||
static int
|
||||
check_api(int fd)
|
||||
{
|
||||
@ -494,12 +510,12 @@ vm_clear_ioreq(struct vmctx *ctx)
|
||||
ioctl(ctx->fd, IC_CLEAR_VM_IOREQ, NULL);
|
||||
}
|
||||
|
||||
static int suspend_mode = VM_SUSPEND_NONE;
|
||||
static enum vm_suspend_how suspend_mode = VM_SUSPEND_NONE;
|
||||
|
||||
void
|
||||
vm_set_suspend_mode(enum vm_suspend_how how)
|
||||
{
|
||||
pr_notice("vm mode changed from %d to %d\n", suspend_mode, how);
|
||||
pr_notice("VM state changed from[ %s ] to [ %s ]\n", vm_state_to_str(suspend_mode), vm_state_to_str(how));
|
||||
suspend_mode = how;
|
||||
}
|
||||
|
||||
@ -512,6 +528,7 @@ vm_get_suspend_mode(void)
|
||||
int
|
||||
vm_suspend(struct vmctx *ctx, enum vm_suspend_how how)
|
||||
{
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(how));
|
||||
vm_set_suspend_mode(how);
|
||||
mevent_notify();
|
||||
|
||||
|
@ -136,10 +136,12 @@ wdt_expired_handler(void *arg, uint64_t nexp)
|
||||
|
||||
/* watchdog timer out, set the uos to reboot */
|
||||
#ifdef DM_DEBUG
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_SYSTEM_RESET));
|
||||
vm_set_suspend_mode(VM_SUSPEND_SYSTEM_RESET);
|
||||
/* Notify vm thread to handle VM_SUSPEND_SYSTEM_RESET request */
|
||||
notify_vmloop_thread();
|
||||
#else
|
||||
pr_info("%s: setting VM state to %s\n", __func__, vm_state_to_str(VM_SUSPEND_FULL_RESET));
|
||||
vm_set_suspend_mode(VM_SUSPEND_FULL_RESET);
|
||||
#endif
|
||||
mevent_notify();
|
||||
|
@ -56,7 +56,7 @@
|
||||
#define IDT_XF 19 /* #XF: SIMD Floating-Point Exception */
|
||||
|
||||
enum vm_suspend_how {
|
||||
VM_SUSPEND_NONE,
|
||||
VM_SUSPEND_NONE = 0,
|
||||
VM_SUSPEND_SYSTEM_RESET,
|
||||
VM_SUSPEND_FULL_RESET,
|
||||
VM_SUSPEND_POWEROFF,
|
||||
|
@ -100,6 +100,7 @@ int vm_destroy_ioreq_client(struct vmctx *ctx);
|
||||
int vm_attach_ioreq_client(struct vmctx *ctx);
|
||||
int vm_notify_request_done(struct vmctx *ctx, int vcpu);
|
||||
void vm_clear_ioreq(struct vmctx *ctx);
|
||||
const char *vm_state_to_str(enum vm_suspend_how idx);
|
||||
void vm_set_suspend_mode(enum vm_suspend_how how);
|
||||
#ifdef DM_DEBUG
|
||||
void notify_vmloop_thread(void);
|
||||
|
Loading…
Reference in New Issue
Block a user