b38b0f
From 663daa42eaaff2b9c071764163005e04133af849 Mon Sep 17 00:00:00 2001
b38b0f
From: Cornelia Huck <cohuck@redhat.com>
b38b0f
Date: Wed, 17 Apr 2019 13:57:41 +0100
b38b0f
Subject: [PATCH 24/24] s390/ipl: fix ipl with -no-reboot
b38b0f
b38b0f
RH-Author: Cornelia Huck <cohuck@redhat.com>
b38b0f
Message-id: <20190417135741.25297-25-cohuck@redhat.com>
b38b0f
Patchwork-id: 85804
b38b0f
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH v2 24/24] s390/ipl: fix ipl with -no-reboot
b38b0f
Bugzilla: 1699070
b38b0f
RH-Acked-by: David Hildenbrand <david@redhat.com>
b38b0f
RH-Acked-by: Thomas Huth <thuth@redhat.com>
b38b0f
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
b38b0f
b38b0f
From: Christian Borntraeger <borntraeger@de.ibm.com>
b38b0f
b38b0f
kexec/kdump as well as the bootloader use a subcode of diagnose 308
b38b0f
that is supposed to reset the I/O subsystem but not comprise a full
b38b0f
"reboot". With the latest refactoring this is now broken when
b38b0f
-no-reboot is used or when libvirt acts on a reboot QMP event, for
b38b0f
example a virt-install from iso images.
b38b0f
b38b0f
We need to mark these "subsystem resets" as special.
b38b0f
b38b0f
Fixes: a30fb811cbe9 (s390x: refactor reset/reipl handling)
b38b0f
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
b38b0f
Reviewed-by: David Hildenbrand <david@redhat.com>
b38b0f
Message-Id: <20180622102928.173420-1-borntraeger@de.ibm.com>
b38b0f
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
b38b0f
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
b38b0f
(cherry picked from commit 76ed4b18debfe597329d1f6a9eb2ec9ffa751ecd)
b38b0f
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
b38b0f
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
b38b0f
---
b38b0f
 hw/s390x/ipl.c          | 8 +++++++-
b38b0f
 include/sysemu/sysemu.h | 4 ++++
b38b0f
 vl.c                    | 4 ++--
b38b0f
 3 files changed, 13 insertions(+), 3 deletions(-)
b38b0f
b38b0f
diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
b38b0f
index ee6701e..21f64ad 100644
b38b0f
--- a/hw/s390x/ipl.c
b38b0f
+++ b/hw/s390x/ipl.c
b38b0f
@@ -541,7 +541,13 @@ void s390_ipl_reset_request(CPUState *cs, enum s390_reset reset_type)
b38b0f
             ipl->iplb_valid = s390_gen_initial_iplb(ipl);
b38b0f
         }
b38b0f
     }
b38b0f
-    qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
b38b0f
+    if (reset_type == S390_RESET_MODIFIED_CLEAR ||
b38b0f
+        reset_type == S390_RESET_LOAD_NORMAL) {
b38b0f
+        /* ignore -no-reboot, send no event  */
b38b0f
+        qemu_system_reset_request(SHUTDOWN_CAUSE_SUBSYSTEM_RESET);
b38b0f
+    } else {
b38b0f
+        qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
b38b0f
+    }
b38b0f
     /* as this is triggered by a CPU, make sure to exit the loop */
b38b0f
     if (tcg_enabled()) {
b38b0f
         cpu_loop_exit(cs);
b38b0f
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
b38b0f
index 2b42151..f20e4f5 100644
b38b0f
--- a/include/sysemu/sysemu.h
b38b0f
+++ b/include/sysemu/sysemu.h
b38b0f
@@ -44,6 +44,10 @@ typedef enum ShutdownCause {
b38b0f
                                      turns that into a shutdown */
b38b0f
     SHUTDOWN_CAUSE_GUEST_PANIC,   /* Guest panicked, and command line turns
b38b0f
                                      that into a shutdown */
b38b0f
+    SHUTDOWN_CAUSE_SUBSYSTEM_RESET,/* Partial guest reset that does not trigger
b38b0f
+                                      QMP events and ignores --no-reboot. This
b38b0f
+                                      is useful for sanitize hypercalls on s390
b38b0f
+                                      that are used during kexec/kdump/boot */
b38b0f
     SHUTDOWN_CAUSE__MAX,
b38b0f
 } ShutdownCause;
b38b0f
 
b38b0f
diff --git a/vl.c b/vl.c
b38b0f
index 9d32921..c778594 100644
b38b0f
--- a/vl.c
b38b0f
+++ b/vl.c
b38b0f
@@ -1751,7 +1751,7 @@ void qemu_system_reset(ShutdownCause reason)
b38b0f
     } else {
b38b0f
         qemu_devices_reset();
b38b0f
     }
b38b0f
-    if (reason) {
b38b0f
+    if (reason != SHUTDOWN_CAUSE_SUBSYSTEM_RESET) {
b38b0f
         qapi_event_send_reset(shutdown_caused_by_guest(reason),
b38b0f
                               &error_abort);
b38b0f
     }
b38b0f
@@ -1797,7 +1797,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *info)
b38b0f
 
b38b0f
 void qemu_system_reset_request(ShutdownCause reason)
b38b0f
 {
b38b0f
-    if (no_reboot) {
b38b0f
+    if (no_reboot && reason != SHUTDOWN_CAUSE_SUBSYSTEM_RESET) {
b38b0f
         shutdown_requested = reason;
b38b0f
     } else {
b38b0f
         reset_requested = reason;
b38b0f
-- 
b38b0f
1.8.3.1
b38b0f