Skip to contentSkip to conversation

trace-cmd: Fix reporting of unknown SVM exit reasons

PATCH In review Jan Kiszka 2 participants 3 messages May 22, 2016 – Jun 1, 2016 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 trace-cmd: Fix reporting of unknown SVM exit reasons

From: Jan Kiszka <[email protected]>

On AMD, exist code -1 is also a possible value, but we use it for terminating the list of known exit reasons. This leads to EXIT_ERR being reported for unkown ones. Fix this by using an NULL string pointer as terminal.

---
 plugin_kvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
plugin_kvm.c +3 -3
index 15a6f4c..99e920f 100644
@@ -208,12 +208,12 @@ struct str_values {
 
 static struct str_values vmx_exit_reasons[] = {
 	VMX_EXIT_REASONS
-	{ NULL, -1}
+	{ }
 };
 
 static struct str_values svm_exit_reasons[] = {
 	SVM_EXIT_REASONS
-	{ NULL, -1}
+	{ }
 };
 
 static struct isa_exit_reasons {
@@ -237,7 +237,7 @@ static const char *find_exit_reason(unsigned isa, int val)
 		}
 	if (!strings)
 		return "UNKNOWN-ISA";
-	for (i = 0; strings[i].val >= 0; i++)
+	for (i = 0; strings[i].str; i++)
 		if (strings[i].val == val)
 			break;
 
Signature · 1 line
2.6.6
#1 lore raw

On Sun, 22 May 2016 18:02:31 +0200
Jan Kiszka <[email protected]> wrote:

Hi Jan,

I finally got around to looking at your patches (not much to do on a 12 hour layover :-p).

Quoted 17 lines

From: Jan Kiszka <[email protected]>

On AMD, exist code -1 is also a possible value, but we use it for terminating the list of known exit reasons. This leads to EXIT_ERR being reported for unkown ones. Fix this by using an NULL string pointer as terminal.

---
 plugin_kvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
plugin_kvm.c +0 -0
index 15a6f4c..99e920f 100644

plugin_kvm.c struct str_values { · line 211

Quoted 5 lines
plugin_kvm.c +1 -1
@@ -208,12 +208,12 @@ struct str_values {
 
 static struct str_values vmx_exit_reasons[] = {
 	VMX_EXIT_REASONS
-	{ NULL, -1}
+	{ }

Just a preference, but I would rather this still explicitly show the NULL. The second value is meaningless with the change below. Thus, I'm going to nuke these two hunks and just add the last one, which should still work for you.

If not, let me know, or just tell me this weekend ;-) (I wont be pushing this to my main server till I get back anyway)

-- Steve

Quoted 18 lines
plugin_kvm.c +2 -2
 };
 
 static struct str_values svm_exit_reasons[] = {
 	SVM_EXIT_REASONS
-	{ NULL, -1}
+	{ }
 };
 
 static struct isa_exit_reasons {
@@ -237,7 +237,7 @@ static const char *find_exit_reason(unsigned isa, int val)
 		}
 	if (!strings)
 		return "UNKNOWN-ISA";
-	for (i = 0; strings[i].val >= 0; i++)
+	for (i = 0; strings[i].str; i++)
 		if (strings[i].val == val)
 			break;
 
author
#2 lore raw
Quoted 26 lines · Steven Rostedt

On Sun, 22 May 2016 18:02:31 +0200
Jan Kiszka <[email protected]> wrote:

Hi Jan,

I finally got around to looking at your patches (not much to do on a 12 hour layover :-p).

Quoted 18 lines

From: Jan Kiszka <[email protected]>

On AMD, exist code -1 is also a possible value, but we use it for terminating the list of known exit reasons. This leads to EXIT_ERR being reported for unkown ones. Fix this by using an NULL string pointer as terminal.

---
 plugin_kvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
plugin_kvm.c +0 -0
index 15a6f4c..99e920f 100644
@@ -208,12 +208,12 @@ struct str_values {
 
Quoted 9 lines

plugin_kvm.c struct str_values { · line 211

Quoted 4 lines
plugin_kvm.c +1 -1
 static struct str_values vmx_exit_reasons[] = {
 	VMX_EXIT_REASONS
-	{ NULL, -1}
+	{ }

Just a preference, but I would rather this still explicitly show the NULL. The second value is meaningless with the change below. Thus, I'm going to nuke these two hunks and just add the last one, which should still work for you.

Fine for me.

Thanks,
Jan

Quoted 25 lines

If not, let me know, or just tell me this weekend ;-) (I wont be pushing this to my main server till I get back anyway)

-- Steve

Quoted 18 lines
plugin_kvm.c +2 -2
 };
 
 static struct str_values svm_exit_reasons[] = {
 	SVM_EXIT_REASONS
-	{ NULL, -1}
+	{ }
 };
 
 static struct isa_exit_reasons {
@@ -237,7 +237,7 @@ static const char *find_exit_reason(unsigned isa, int val)
 		}
 	if (!strings)
 		return "UNKNOWN-ISA";
-	for (i = 0; strings[i].val >= 0; i++)
+	for (i = 0; strings[i].str; i++)
 		if (strings[i].val == val)
 			break;