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]",
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"),
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;
dbg_type = params->dbg_type;
vcpu = params->cpu;
+ if (dbg_type & KVM_DEBUG_CMD_TYPE_SYSRQ)
+ serial8250__inject_sysrq(kvm, params->sysrq);
+
if (dbg_type & KVM_DEBUG_CMD_TYPE_NMI) {
if ((int)vcpu >= kvm->nrcpus)
return;
close(fd);
- serial8250__inject_sysrq(kvm);
+ serial8250__inject_sysrq(kvm, 'p');
}
static void handle_sigalrm(int sig)
}
#define SYSRQ_PENDING_NONE 0
-#define SYSRQ_PENDING_BREAK 1
static int sysrq_pending;
static void serial8250__sysrq(struct kvm *kvm, struct serial8250_device *dev)
{
dev->lsr |= UART_LSR_DR | UART_LSR_BI;
- dev->rxbuf[dev->rxcnt++] = 'p';
+ dev->rxbuf[dev->rxcnt++] = sysrq_pending;
sysrq_pending = SYSRQ_PENDING_NONE;
}
}
}
-void serial8250__inject_sysrq(struct kvm *kvm)
+void serial8250__inject_sysrq(struct kvm *kvm, char sysrq)
{
- sysrq_pending = SYSRQ_PENDING_BREAK;
+ sysrq_pending = sysrq;
}
static struct serial8250_device *find_device(u16 port)
int serial8250__init(struct kvm *kvm);
int serial8250__exit(struct kvm *kvm);
void serial8250__update_consoles(struct kvm *kvm);
-void serial8250__inject_sysrq(struct kvm *kvm);
+void serial8250__inject_sysrq(struct kvm *kvm, char sysrq);
#endif /* KVM__8250_SERIAL_H */
#define KVM_DEBUG_CMD_TYPE_DUMP (1 << 0)
#define KVM_DEBUG_CMD_TYPE_NMI (1 << 1)
+#define KVM_DEBUG_CMD_TYPE_SYSRQ (1 << 2)
struct debug_cmd_params {
u32 dbg_type;
u32 cpu;
+ char sysrq;
};
int kvm_cmd_debug(int argc, const char **argv, const char *prefix);