thebeanogamer / rpms / qemu-kvm

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