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