Skip to contentSkip to conversation

guest panic information follow-up

PATCH In review Denis V. Lunev 4 participants 10 messages Feb 20, 2017 – Feb 21, 2017

lore
Share & tools
lore
#0 lore raw

cover guest panic information follow-up

This is a set of followup patches requested by Eric Blake.

Anton Nefedov (3):
i386/cpu: release GuestPanicInformation memory
qapi: flatten GuestPanicInformation union
qmp-events: fix GUEST_PANICKED description formatting

 kvm-all.c         |  5 ++++-
 qapi-schema.json  | 12 ++++++++++++
 qapi/event.json   |  4 ++--
 target/i386/cpu.c | 15 ++++++---------
 vl.c              | 22 +++++++++-------------
 5 files changed, 33 insertions(+), 25 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 i386/cpu: release GuestPanicInformation memory

From: Anton Nefedov <[email protected]>

Do not make some foreign function do it.

---
 kvm-all.c |  5 ++++-
 vl.c      | 22 +++++++++-------------
 2 files changed, 13 insertions(+), 14 deletions(-)
kvm-all.c +4 -1
index 0c94637..ac07902 100644
@@ -1909,6 +1909,7 @@ int kvm_cpu_exec(CPUState *cpu)
 
     do {
         MemTxAttrs attrs;
+        GuestPanicInformation *crash_info;
 
         if (cpu->kvm_vcpu_dirty) {
             kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE);
@@ -2001,9 +2002,11 @@ int kvm_cpu_exec(CPUState *cpu)
                 break;
             case KVM_SYSTEM_EVENT_CRASH:
                 kvm_cpu_synchronize_state(cpu);
+                crash_info = cpu_get_crash_info(cpu);
                 qemu_mutex_lock_iothread();
-                qemu_system_guest_panicked(cpu_get_crash_info(cpu));
+                qemu_system_guest_panicked(crash_info);
                 qemu_mutex_unlock_iothread();
+                qapi_free_GuestPanicInformation(crash_info);
                 ret = 0;
                 break;
             default:
vl.c +9 -13
index 27d9829..81382b6 100644
@@ -1682,6 +1682,15 @@ void qemu_system_reset(bool report)
 void qemu_system_guest_panicked(GuestPanicInformation *info)
 {
     qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n");
+    if (info && info->type == GUEST_PANIC_INFORMATION_KIND_HYPER_V) {
+        qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64
+                      " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n",
+                      info->u.hyper_v.data->arg1,
+                      info->u.hyper_v.data->arg2,
+                      info->u.hyper_v.data->arg3,
+                      info->u.hyper_v.data->arg4,
+                      info->u.hyper_v.data->arg5);
+    }
 
     if (current_cpu) {
         current_cpu->crash_occurred = true;
@@ -1694,19 +1703,6 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
                                        !!info, info, &error_abort);
         qemu_system_shutdown_request();
     }
-
-    if (info) {
-        if (info->type == GUEST_PANIC_INFORMATION_KIND_HYPER_V) {
-            qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64
-                          " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n",
-                          info->u.hyper_v.data->arg1,
-                          info->u.hyper_v.data->arg2,
-                          info->u.hyper_v.data->arg3,
-                          info->u.hyper_v.data->arg4,
-                          info->u.hyper_v.data->arg5);
-        }
-        qapi_free_GuestPanicInformation(info);
-    }
 }
 
 void qemu_system_reset_request(void)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 2/3 qapi: flatten GuestPanicInformation union

In reply to Denis V. Lunev

From: Anton Nefedov <[email protected]>

---
 qapi-schema.json  | 12 ++++++++++++
 target/i386/cpu.c | 15 ++++++---------
 vl.c              | 12 ++++++------
 3 files changed, 24 insertions(+), 15 deletions(-)
qapi-schema.json +12 -0
index e9a6364..b142e15 100644
@@ -5872,6 +5872,16 @@
   'data': [ 'pause', 'poweroff' ] }
 
 ##
+# @GuestPanicInformationType:
+#
+# An enumeration of the guest panic information types
+#
+# Since: 2.9
+##
+{ 'enum': 'GuestPanicInformationType',
+  'data': [ 'hyper-v'] }
+
+##
 # @GuestPanicInformation:
 #
 # Information about a guest panic
@@ -5879,6 +5889,8 @@
 # Since: 2.9
 ##
 {'union': 'GuestPanicInformation',
+ 'base': {'type': 'GuestPanicInformationType'},
+ 'discriminator': 'type',
  'data': { 'hyper-v': 'GuestPanicInformationHyperV' } }
 
 ##
target/i386/cpu.c +6 -9
index fd7add2..63be816 100644
@@ -3502,19 +3502,16 @@ static GuestPanicInformation *x86_cpu_get_crash_info(CPUState *cs)
     GuestPanicInformation *panic_info = NULL;
 
     if (env->features[FEAT_HYPERV_EDX] & HV_X64_GUEST_CRASH_MSR_AVAILABLE) {
-        GuestPanicInformationHyperV *panic_info_hv =
-            g_malloc0(sizeof(GuestPanicInformationHyperV));
         panic_info = g_malloc0(sizeof(GuestPanicInformation));
 
-        panic_info->type = GUEST_PANIC_INFORMATION_KIND_HYPER_V;
-        panic_info->u.hyper_v.data = panic_info_hv;
+        panic_info->type = GUEST_PANIC_INFORMATION_TYPE_HYPER_V;
 
         assert(HV_X64_MSR_CRASH_PARAMS >= 5);
-        panic_info_hv->arg1 = env->msr_hv_crash_params[0];
-        panic_info_hv->arg2 = env->msr_hv_crash_params[1];
-        panic_info_hv->arg3 = env->msr_hv_crash_params[2];
-        panic_info_hv->arg4 = env->msr_hv_crash_params[3];
-        panic_info_hv->arg5 = env->msr_hv_crash_params[4];
+        panic_info->u.hyper_v.arg1 = env->msr_hv_crash_params[0];
+        panic_info->u.hyper_v.arg2 = env->msr_hv_crash_params[1];
+        panic_info->u.hyper_v.arg3 = env->msr_hv_crash_params[2];
+        panic_info->u.hyper_v.arg4 = env->msr_hv_crash_params[3];
+        panic_info->u.hyper_v.arg5 = env->msr_hv_crash_params[4];
     }
 
     return panic_info;
vl.c +6 -6
index 81382b6..2781716 100644
@@ -1682,14 +1682,14 @@ void qemu_system_reset(bool report)
 void qemu_system_guest_panicked(GuestPanicInformation *info)
 {
     qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n");
-    if (info && info->type == GUEST_PANIC_INFORMATION_KIND_HYPER_V) {
+    if (info && info->type == GUEST_PANIC_INFORMATION_TYPE_HYPER_V) {
         qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64
                       " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n",
-                      info->u.hyper_v.data->arg1,
-                      info->u.hyper_v.data->arg2,
-                      info->u.hyper_v.data->arg3,
-                      info->u.hyper_v.data->arg4,
-                      info->u.hyper_v.data->arg5);
+                      info->u.hyper_v.arg1,
+                      info->u.hyper_v.arg2,
+                      info->u.hyper_v.arg3,
+                      info->u.hyper_v.arg4,
+                      info->u.hyper_v.arg5);
     }
 
     if (current_cpu) {
Signature · 1 line
2.7.4
#7 lore raw

PATCH 3/3 qmp-events: fix GUEST_PANICKED description formatting

In reply to Denis V. Lunev

From: Anton Nefedov <[email protected]>

---
 qapi/event.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qapi/event.json +2 -2
index 970ff02..e02852c 100644
@@ -488,9 +488,9 @@
 #
 # @action: action that has been taken, currently always "pause"
 #
-# @info: optional information about a panic
+# @info: #optional information about a panic (since 2.9)
 #
-# Since: 1.5 (@info since 2.9)
+# Since: 1.5
 #
 # Example:
 #
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] i386/cpu: release GuestPanicInformation memory

In reply to Denis V. Lunev
Quoted 18 lines · Denis V. Lunev

From: Anton Nefedov <[email protected]>

Do not make some foreign function do it.

---
 kvm-all.c |  5 ++++-
 vl.c      | 22 +++++++++-------------
 2 files changed, 13 insertions(+), 14 deletions(-)

+++ b/vl.c

vl.c +0 -0
@@ -1682,6 +1682,15 @@ void qemu_system_reset(bool report)
 void qemu_system_guest_panicked(GuestPanicInformation *info)
 {

vl.c void qemu_system_reset(bool report) · line 1693

Quoted 10 lines
vl.c +9 -0
     qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed\n");
+    if (info && info->type == GUEST_PANIC_INFORMATION_KIND_HYPER_V) {
+        qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64
+                      " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n",
+                      info->u.hyper_v.data->arg1,
+                      info->u.hyper_v.data->arg2,
+                      info->u.hyper_v.data->arg3,
+                      info->u.hyper_v.data->arg4,
+                      info->u.hyper_v.data->arg5);
+    }

Why are we hoisting this code earlier in the function (which changes the log order, if I'm reading correctly)...

Quoted 10 lines
vl.c +0 -3
     if (current_cpu) {
         current_cpu->crash_occurred = true;
@@ -1694,19 +1703,6 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
                                        !!info, info, &error_abort);
         qemu_system_shutdown_request();
     }
-
-    if (info) {
-        if (info->type == GUEST_PANIC_INFORMATION_KIND_HYPER_V) {

vl.c void qemu_system_guest_panicked(GuestPanicInformation *info) · line 1709

Quoted 10 lines
vl.c +0 -10
-            qemu_log_mask(LOG_GUEST_ERROR, "HV crash parameters: (%#"PRIx64
-                          " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n",
-                          info->u.hyper_v.data->arg1,
-                          info->u.hyper_v.data->arg2,
-                          info->u.hyper_v.data->arg3,
-                          info->u.hyper_v.data->arg4,
-                          info->u.hyper_v.data->arg5);
-        }
-        qapi_free_GuestPanicInformation(info);
-    }

...instead of just cleaning up this code in place?

But the rest of the patch looks fine.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 2/3
#4 lore raw

Re: [Qemu-devel] [PATCH 2/3] qapi: flatten GuestPanicInformation union

In reply to Denis V. Lunev
Quoted 18 lines · Denis V. Lunev

From: Anton Nefedov <[email protected]>

---
 qapi-schema.json  | 12 ++++++++++++
 target/i386/cpu.c | 15 ++++++---------
 vl.c              | 12 ++++++------
 3 files changed, 24 insertions(+), 15 deletions(-)
qapi-schema.json +0 -0
index e9a6364..b142e15 100644
@@ -5872,6 +5872,16 @@
   'data': [ 'pause', 'poweroff' ] }

qapi-schema.json line 5882

Quoted 10 lines
qapi-schema.json +8 -0
 
 ##
+# @GuestPanicInformationType:
+#
+# An enumeration of the guest panic information types
+#
+# Since: 2.9
+##
+{ 'enum': 'GuestPanicInformationType',
+  'data': [ 'hyper-v'] }

Perhaps 'hyperv' is better? It's the difference between GUEST_PANIC_INFORMATION_TYPE_HYPER_V and GUEST_PANIC_INFORMATION_TYPE_HYPERV. But that's bikeshedding, so no need to change it.

Must go into 2.9, so we aren't baking in bad API.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 3/3
#8 lore raw

Re: [Qemu-devel] [PATCH 3/3] qmp-events: fix GUEST_PANICKED description formatting

In reply to Denis V. Lunev
Quoted 9 lines · Denis V. Lunev

From: Anton Nefedov <[email protected]>

---
 qapi/event.json | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw

Re: [Qemu-devel] [PATCH 2/3] qapi: flatten GuestPanicInformation union

In reply to Eric Blake
Quoted 34 lines · Eric Blake
Quoted 18 lines · Denis V. Lunev

From: Anton Nefedov <[email protected]>

---
 qapi-schema.json  | 12 ++++++++++++
 target/i386/cpu.c | 15 ++++++---------
 vl.c              | 12 ++++++------
 3 files changed, 24 insertions(+), 15 deletions(-)
qapi-schema.json +0 -0
index e9a6364..b142e15 100644
@@ -5872,6 +5872,16 @@
   'data': [ 'pause', 'poweroff' ] }

qapi-schema.json line 5882

Quoted 10 lines
qapi-schema.json +8 -0
 
 ##
+# @GuestPanicInformationType:
+#
+# An enumeration of the guest panic information types
+#
+# Since: 2.9
+##
+{ 'enum': 'GuestPanicInformationType',
+  'data': [ 'hyper-v'] }

Perhaps 'hyperv' is better? It's the difference between GUEST_PANIC_INFORMATION_TYPE_HYPER_V and GUEST_PANIC_INFORMATION_TYPE_HYPERV. But that's bikeshedding, so no need to change it.

Quoted 4 lines

Must go into 2.9, so we aren't baking in bad API.

We can you plain 'hv', like all command line options controlling HyperV features.

Roman, Evgeniy, do you have any opinion on that?

Den

#9 lore raw
In reply to Denis V. Lunev
Quoted 12 lines · Denis V. Lunev

This is a set of followup patches requested by Eric Blake.

Anton Nefedov (3):
i386/cpu: release GuestPanicInformation memory
qapi: flatten GuestPanicInformation union
qmp-events: fix GUEST_PANICKED description formatting

Quoted 7 lines
 kvm-all.c         |  5 ++++-
 qapi-schema.json  | 12 ++++++++++++
 qapi/event.json   |  4 ++--
 target/i386/cpu.c | 15 ++++++---------
 vl.c              | 22 +++++++++-------------
 5 files changed, 33 insertions(+), 25 deletions(-)

I am queuing patches 2 and 3. For patch 1, I've just sent an alternative idea.

Paolo

#6 lore raw

Re: [Qemu-devel] [PATCH 2/3] qapi: flatten GuestPanicInformation union

In reply to Denis V. Lunev
Quoted 35 lines · Denis V. Lunev
Quoted 34 lines · Eric Blake
Quoted 18 lines · Denis V. Lunev

From: Anton Nefedov <[email protected]>

---
  qapi-schema.json  | 12 ++++++++++++
  target/i386/cpu.c | 15 ++++++---------
  vl.c              | 12 ++++++------
  3 files changed, 24 insertions(+), 15 deletions(-)
qapi-schema.json +0 -0
index e9a6364..b142e15 100644
@@ -5872,6 +5872,16 @@
    'data': [ 'pause', 'poweroff' ] }

qapi-schema.json line 5882

Quoted 10 lines
qapi-schema.json +8 -0
 
  ##
+# @GuestPanicInformationType:
+#
+# An enumeration of the guest panic information types
+#
+# Since: 2.9
+##
+{ 'enum': 'GuestPanicInformationType',
+  'data': [ 'hyper-v'] }

Perhaps 'hyperv' is better? It's the difference between GUEST_PANIC_INFORMATION_TYPE_HYPER_V and GUEST_PANIC_INFORMATION_TYPE_HYPERV. But that's bikeshedding, so no need to change it.

Quoted 8 lines
Quoted 4 lines

Must go into 2.9, so we aren't baking in bad API.

We can you plain 'hv', like all command line options controlling HyperV features.

Roman, Evgeniy, do you have any opinion on that?

In vmbus we've settled on using "hyperv-" prefixes for stuff related to QAPI namespace and QOM objects' property names: "hyperv-synic", "hyperv-sint-route", etc. We might as well stick to it.

Quoted 2 lines

Den