mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-16 02:15:47 +00:00
kvm tools: carefully send and handle debug ipc
Remove struct debug_cmd and use kvm_ipc__send_msg(). Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
496692990b
commit
a59cdf4466
+5
-5
@@ -50,18 +50,18 @@ void kvm_debug_help(void)
|
||||
static int do_debug(const char *name, int sock)
|
||||
{
|
||||
char buff[BUFFER_SIZE];
|
||||
struct debug_cmd cmd = {KVM_IPC_DEBUG, 2 * sizeof(u32)};
|
||||
struct debug_cmd_params cmd = {.dbg_type = 0};
|
||||
int r;
|
||||
|
||||
if (dump)
|
||||
cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_DUMP;
|
||||
cmd.dbg_type |= KVM_DEBUG_CMD_TYPE_DUMP;
|
||||
|
||||
if (nmi != -1) {
|
||||
cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_NMI;
|
||||
cmd.params.cpu = nmi;
|
||||
cmd.dbg_type |= KVM_DEBUG_CMD_TYPE_NMI;
|
||||
cmd.cpu = nmi;
|
||||
}
|
||||
|
||||
r = xwrite(sock, &cmd, sizeof(cmd));
|
||||
r = kvm_ipc__send_msg(sock, KVM_IPC_DEBUG, sizeof(cmd), (u8 *)&cmd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
+10
-3
@@ -521,9 +521,16 @@ static void handle_pause(int fd, u32 type, u32 len, u8 *msg)
|
||||
static void handle_debug(int fd, u32 type, u32 len, u8 *msg)
|
||||
{
|
||||
int i;
|
||||
struct debug_cmd_params *params = (void *)msg;
|
||||
u32 dbg_type = params->dbg_type;
|
||||
u32 vcpu = params->cpu;
|
||||
struct debug_cmd_params *params;
|
||||
u32 dbg_type;
|
||||
u32 vcpu;
|
||||
|
||||
if (WARN_ON(type != KVM_IPC_DEBUG || len != sizeof(*params)))
|
||||
return;
|
||||
|
||||
params = (void *)msg;
|
||||
dbg_type = params->dbg_type;
|
||||
vcpu = params->cpu;
|
||||
|
||||
if (dbg_type & KVM_DEBUG_CMD_TYPE_NMI) {
|
||||
if ((int)vcpu >= kvm->nrcpus)
|
||||
|
||||
@@ -12,12 +12,6 @@ struct debug_cmd_params {
|
||||
u32 cpu;
|
||||
};
|
||||
|
||||
struct debug_cmd {
|
||||
u32 type;
|
||||
u32 len;
|
||||
struct debug_cmd_params params;
|
||||
};
|
||||
|
||||
int kvm_cmd_debug(int argc, const char **argv, const char *prefix);
|
||||
void kvm_debug_help(void) NORETURN;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user