代码拉取完成,页面将自动刷新
同步操作将从 会飞的小胖/kvmtool 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <kvm/util.h>
#include <kvm/kvm-cmd.h>
#include <kvm/builtin-debug.h>
#include <kvm/kvm.h>
#include <kvm/parse-options.h>
#include <kvm/kvm-ipc.h>
#include <kvm/read-write.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#define BUFFER_SIZE 100
static bool all;
static int nmi = -1;
static bool dump;
static const char *instance_name;
static const char *sysrq;
static const char * const debug_usage[] = {
"lkvm debug [--all] [-n name] [-d] [-m vcpu]",
NULL
};
static const struct option debug_options[] = {
OPT_GROUP("General options:"),
OPT_BOOLEAN('d', "dump", &dump, "Generate a debug dump from guest"),
OPT_INTEGER('m', "nmi", &nmi, "Generate NMI on VCPU"),
OPT_STRING('s', "sysrq", &sysrq, "sysrq", "Inject a sysrq"),
OPT_GROUP("Instance options:"),
OPT_BOOLEAN('a', "all", &all, "Debug all instances"),
OPT_STRING('n', "name", &instance_name, "name", "Instance name"),
OPT_END()
};
static void parse_debug_options(int argc, const char **argv)
{
while (argc != 0) {
argc = parse_options(argc, argv, debug_options, debug_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
if (argc != 0)
kvm_debug_help();
}
}
void kvm_debug_help(void)
{
usage_with_options(debug_usage, debug_options);
}
static int do_debug(const char *name, int sock)
{
char buff[BUFFER_SIZE];
struct debug_cmd_params cmd = {.dbg_type = 0};
int r;
if (dump)
cmd.dbg_type |= KVM_DEBUG_CMD_TYPE_DUMP;
if (nmi != -1) {
cmd.dbg_type |= KVM_DEBUG_CMD_TYPE_NMI;
cmd.cpu = nmi;
}
if (sysrq) {
cmd.dbg_type |= KVM_DEBUG_CMD_TYPE_SYSRQ;
cmd.sysrq = sysrq[0];
}
r = kvm_ipc__send_msg(sock, KVM_IPC_DEBUG, sizeof(cmd), (u8 *)&cmd);
if (r < 0)
return r;
if (!dump)
return 0;
do {
r = xread(sock, buff, BUFFER_SIZE);
if (r < 0)
return 0;
printf("%.*s", r, buff);
} while (r > 0);
return 0;
}
int kvm_cmd_debug(int argc, const char **argv, const char *prefix)
{
parse_debug_options(argc, argv);
int instance;
int r;
if (all)
return kvm__enumerate_instances(do_debug);
if (instance_name == NULL)
kvm_debug_help();
instance = kvm__get_sock_by_instance(instance_name);
if (instance <= 0)
die("Failed locating instance");
r = do_debug(instance_name, instance);
close(instance);
return r;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。