[PATCH 1/2] kvm tools: Clean up 'kvm debug'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/builtin-debug.c             |   13 +++++++------
 tools/kvm/builtin-run.c               |    7 ++++---
 tools/kvm/include/kvm/builtin-debug.h |   13 +++++++++----
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/tools/kvm/builtin-debug.c b/tools/kvm/builtin-debug.c
index eee26c3..292172a 100644
--- a/tools/kvm/builtin-debug.c
+++ b/tools/kvm/builtin-debug.c
@@ -19,16 +19,17 @@ static bool dump;
 static const char *instance_name;
 
 static const char * const debug_usage[] = {
-	"kvm debug [--all] [-n name]",
+	"kvm debug [--all] [-n name] [-d] [-m vcpu]",
 	NULL
 };
 
 static const struct option debug_options[] = {
 	OPT_GROUP("General options:"),
-	OPT_BOOLEAN('a', "all", &all, "Debug all instances"),
-	OPT_STRING('n', "name", &instance_name, "name", "Instance name"),
 	OPT_BOOLEAN('d', "dump", &dump, "Generate a debug dump from guest"),
 	OPT_INTEGER('m', "nmi", &nmi, "Generate NMI on VCPU"),
+	OPT_GROUP("Instance options:"),
+	OPT_BOOLEAN('a', "all", &all, "Debug all instances"),
+	OPT_STRING('n', "name", &instance_name, "name", "Instance name"),
 	OPT_END()
 };
 
@@ -54,11 +55,11 @@ static int do_debug(const char *name, int sock)
 	int r;
 
 	if (dump)
-		cmd.dbg_type |= KVM_DEBUG_CMD_TYPE_DUMP;
+		cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_DUMP;
 
 	if (nmi != -1) {
-		cmd.dbg_type |= KVM_DEBUG_CMD_TYPE_NMI;
-		cmd.cpu = nmi;
+		cmd.params.dbg_type |= KVM_DEBUG_CMD_TYPE_NMI;
+		cmd.params.cpu = nmi;
 	}
 
 	r = xwrite(sock, &cmd, sizeof(cmd));
diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 4411c9e..5045278 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -510,11 +510,12 @@ 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;
-	u32 dbg_type = *(u32 *)msg;
-	int vcpu = *(((u32 *)msg) + 1);
+	struct debug_cmd_params *params = (void *)msg;
+	u32 dbg_type = params->dbg_type;
+	u32 vcpu = params->cpu;
 
 	if (dbg_type & KVM_DEBUG_CMD_TYPE_NMI) {
-		if (vcpu >= kvm->nrcpus)
+		if ((int)vcpu >= kvm->nrcpus)
 			return;
 
 		kvm_cpus[vcpu]->needs_nmi = 1;
diff --git a/tools/kvm/include/kvm/builtin-debug.h b/tools/kvm/include/kvm/builtin-debug.h
index b24b501..0aafef9 100644
--- a/tools/kvm/include/kvm/builtin-debug.h
+++ b/tools/kvm/include/kvm/builtin-debug.h
@@ -3,15 +3,20 @@
 
 #include <linux/types.h>
 
-struct debug_cmd {
-	u32 type;
-	u32 len;
-	u32 dbg_type;
 #define KVM_DEBUG_CMD_TYPE_DUMP	(1 << 0)
 #define KVM_DEBUG_CMD_TYPE_NMI	(1 << 1)
+
+struct debug_cmd_params {
+	u32 dbg_type;
 	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);
 
-- 
1.7.8

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux