thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
a19a21
From 1fc9b693c54c93736c6f902f3df8b94440e8cc5d Mon Sep 17 00:00:00 2001
a19a21
From: Greg Kurz <gkurz@redhat.com>
a19a21
Date: Tue, 19 Jan 2021 15:09:53 -0500
a19a21
Subject: [PATCH 5/9] spapr: Allow memory unplug to always succeed
a19a21
a19a21
RH-Author: Greg Kurz <gkurz@redhat.com>
a19a21
Message-id: <20210119150954.1017058-6-gkurz@redhat.com>
a19a21
Patchwork-id: 100686
a19a21
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 5/6] spapr: Allow memory unplug to always succeed
a19a21
Bugzilla: 1901837
a19a21
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
a19a21
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
a19a21
RH-Acked-by: David Gibson <dgibson@redhat.com>
a19a21
a19a21
From: Greg Kurz <groug@kaod.org>
a19a21
a19a21
It is currently impossible to hot-unplug a memory device between
a19a21
machine reset and CAS.
a19a21
a19a21
(qemu) device_del dimm1
a19a21
Error: Memory hot unplug not supported for this guest
a19a21
a19a21
This limitation was introduced in order to provide an explicit
a19a21
error path for older guests that didn't support hot-plug event
a19a21
sources (and thus memory hot-unplug).
a19a21
a19a21
The linux kernel has been supporting these since 4.11. All recent
a19a21
enough guests are thus capable of handling the removal of a memory
a19a21
device at all time, including during early boot.
a19a21
a19a21
Lift the limitation for the latest machine type. This means that
a19a21
trying to unplug memory from a guest that doesn't support it will
a19a21
likely just do nothing and the memory will only get removed at
a19a21
next reboot. Such older guests can still get the existing behavior
a19a21
by using an older machine type.
a19a21
a19a21
Signed-off-by: Greg Kurz <groug@kaod.org>
a19a21
Message-Id: <160794035064.23292.17560963281911312439.stgit@bahia.lan>
a19a21
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
a19a21
(cherry picked from commit 1e8b5b1aa16b7d73ba8ba52c95d0b52329d5c9d0)
a19a21
Signed-off-by: Greg Kurz <gkurz@redhat.com>
a19a21
a19a21
Conflicts:
a19a21
	hw/ppc/spapr.c
a19a21
	include/hw/ppc/spapr.h
a19a21
a19a21
Conflicts around the addition of pre_6_0_memory_unplug. Ignore the
a19a21
change that sets pre_6_0_memory_unplug for older machine types.
a19a21
This is ok because pre_6_0_memory_unplug is removed in a subsequent
a19a21
patch anyway.
a19a21
a19a21
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
a19a21
---
a19a21
 hw/ppc/spapr.c         | 3 ++-
a19a21
 hw/ppc/spapr_events.c  | 3 ++-
a19a21
 include/hw/ppc/spapr.h | 1 +
a19a21
 3 files changed, 5 insertions(+), 2 deletions(-)
a19a21
a19a21
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
a19a21
index 992bd08aaa..f8de33e3e5 100644
a19a21
--- a/hw/ppc/spapr.c
a19a21
+++ b/hw/ppc/spapr.c
a19a21
@@ -4001,7 +4001,8 @@ static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
a19a21
     SpaprMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
a19a21
 
a19a21
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
a19a21
-        if (spapr_ovec_test(sms->ov5_cas, OV5_HP_EVT)) {
a19a21
+        if (!smc->pre_6_0_memory_unplug ||
a19a21
+            spapr_ovec_test(sms->ov5_cas, OV5_HP_EVT)) {
a19a21
             spapr_memory_unplug_request(hotplug_dev, dev, errp);
a19a21
         } else {
a19a21
             /* NOTE: this means there is a window after guest reset, prior to
a19a21
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
a19a21
index 15b92b63ad..6e284aa4bc 100644
a19a21
--- a/hw/ppc/spapr_events.c
a19a21
+++ b/hw/ppc/spapr_events.c
a19a21
@@ -547,7 +547,8 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint8_t hp_action,
a19a21
         /* we should not be using count_indexed value unless the guest
a19a21
          * supports dedicated hotplug event source
a19a21
          */
a19a21
-        g_assert(spapr_ovec_test(spapr->ov5_cas, OV5_HP_EVT));
a19a21
+        g_assert(!SPAPR_MACHINE_GET_CLASS(spapr)->pre_6_0_memory_unplug ||
a19a21
+                 spapr_ovec_test(spapr->ov5_cas, OV5_HP_EVT));
a19a21
         hp->drc_id.count_indexed.count =
a19a21
             cpu_to_be32(drc_id->count_indexed.count);
a19a21
         hp->drc_id.count_indexed.index =
a19a21
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
a19a21
index e5e2a99046..ac6961ed16 100644
a19a21
--- a/include/hw/ppc/spapr.h
a19a21
+++ b/include/hw/ppc/spapr.h
a19a21
@@ -124,6 +124,7 @@ struct SpaprMachineClass {
a19a21
     bool pre_4_1_migration; /* don't migrate hpt-max-page-size */
a19a21
     bool linux_pci_probe;
a19a21
     bool smp_threads_vsmt; /* set VSMT to smp_threads by default */
a19a21
+    bool pre_6_0_memory_unplug;
a19a21
 
a19a21
     bool has_power9_support;
a19a21
     void (*phb_placement)(SpaprMachineState *spapr, uint32_t index,
a19a21
-- 
a19a21
2.18.2
a19a21