All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups
@ 2018-06-08 12:48 David Hildenbrand
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 1/6] spapr: no need to verify the node David Hildenbrand
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: David Hildenbrand @ 2018-06-08 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Alexander Graf, Igor Mammedov, david, Thomas Huth,
	David Gibson, Greg Kurz

I'll be messing with machine hotplug handlers of pc/spapr/s390x in the
context of
    [PATCH v4 00/14] MemoryDevice: use multi stage hotplug handlers

So this is a spin-off of the cleanup patches in the context of hotplug
handlers.

v1 -> v2:
- dropped the three "local_err" patches
- tweaked some patch descriptions
- Split "spapr: move all DIMM checks into spapr_memory_plug" up
-- Move the memory hotplug check into the pre_plug handler
- Use &error_abort instead of NULL

David Hildenbrand (6):
  spapr: no need to verify the node
  spapr: move lookup of the node into spapr_memory_plug()
  spapr: move memory hotplug support check into spapr_memory_pre_plug()
  spapr: introduce machine unplug handler
  spapr: handle pc-dimm unplug via hotplug handler chain
  spapr: handle cpu core unplug via hotplug handler chain

 hw/ppc/spapr.c | 67 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 43 insertions(+), 24 deletions(-)

-- 
2.17.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH v2 1/6] spapr: no need to verify the node
  2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
@ 2018-06-08 12:48 ` David Hildenbrand
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 2/6] spapr: move lookup of the node into spapr_memory_plug() David Hildenbrand
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2018-06-08 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Alexander Graf, Igor Mammedov, david, Thomas Huth,
	David Gibson, Greg Kurz

The node property can always be queried and the value has already been
verified in pc_dimm_realize().

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/ppc/spapr.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 2375cbee12..f16a0b2870 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3578,14 +3578,8 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
             error_setg(errp, "Memory hotplug not supported for this machine");
             return;
         }
-        node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP, errp);
-        if (*errp) {
-            return;
-        }
-        if (node < 0 || node >= MAX_NODES) {
-            error_setg(errp, "Invaild node %d", node);
-            return;
-        }
+        node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP,
+                                        &error_abort);
 
         spapr_memory_plug(hotplug_dev, dev, node, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH v2 2/6] spapr: move lookup of the node into spapr_memory_plug()
  2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 1/6] spapr: no need to verify the node David Hildenbrand
@ 2018-06-08 12:48 ` David Hildenbrand
  2018-06-08 13:20   ` Greg Kurz
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 3/6] spapr: move memory hotplug support check into spapr_memory_pre_plug() David Hildenbrand
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand @ 2018-06-08 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Alexander Graf, Igor Mammedov, david, Thomas Huth,
	David Gibson, Greg Kurz

Let's clean the hotplug handler up by moving lookup of the node into
the function where it is actually being used.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/ppc/spapr.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f16a0b2870..1f577b274b 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3136,7 +3136,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
 }
 
 static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
-                              uint32_t node, Error **errp)
+                              Error **errp)
 {
     Error *local_err = NULL;
     sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev);
@@ -3144,6 +3144,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
     PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
     MemoryRegion *mr;
     uint64_t align, size, addr;
+    uint32_t node;
 
     mr = ddc->get_memory_region(dimm, &local_err);
     if (local_err) {
@@ -3163,6 +3164,8 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
         goto out_unplug;
     }
 
+    node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP,
+                                    &error_abort);
     spapr_add_lmbs(dev, addr, size, node,
                    spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT),
                    &local_err);
@@ -3572,16 +3575,11 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
     sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(ms);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-        int node;
-
         if (!smc->dr_lmb_enabled) {
             error_setg(errp, "Memory hotplug not supported for this machine");
             return;
         }
-        node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP,
-                                        &error_abort);
-
-        spapr_memory_plug(hotplug_dev, dev, node, errp);
+        spapr_memory_plug(hotplug_dev, dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
         spapr_core_plug(hotplug_dev, dev, errp);
     }
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH v2 3/6] spapr: move memory hotplug support check into spapr_memory_pre_plug()
  2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 1/6] spapr: no need to verify the node David Hildenbrand
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 2/6] spapr: move lookup of the node into spapr_memory_plug() David Hildenbrand
@ 2018-06-08 12:48 ` David Hildenbrand
  2018-06-08 13:36   ` Greg Kurz
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 4/6] spapr: introduce machine unplug handler David Hildenbrand
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand @ 2018-06-08 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Alexander Graf, Igor Mammedov, david, Thomas Huth,
	David Gibson, Greg Kurz

Let's finish cleaning up the hotplug handler. This check can be
performed in the pre_plug code as the very first thing.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/ppc/spapr.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 1f577b274b..9b8b4068b1 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3184,12 +3184,18 @@ out:
 static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                   Error **errp)
 {
+    const sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(hotplug_dev);
     PCDIMMDevice *dimm = PC_DIMM(dev);
     PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
     MemoryRegion *mr;
     uint64_t size;
     char *mem_dev;
 
+    if (!smc->dr_lmb_enabled) {
+        error_setg(errp, "Memory hotplug not supported for this machine");
+        return;
+    }
+
     mr = ddc->get_memory_region(dimm, errp);
     if (!mr) {
         return;
@@ -3571,14 +3577,7 @@ out:
 static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp)
 {
-    MachineState *ms = MACHINE(hotplug_dev);
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(ms);
-
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-        if (!smc->dr_lmb_enabled) {
-            error_setg(errp, "Memory hotplug not supported for this machine");
-            return;
-        }
         spapr_memory_plug(hotplug_dev, dev, errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
         spapr_core_plug(hotplug_dev, dev, errp);
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH v2 4/6] spapr: introduce machine unplug handler
  2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
                   ` (2 preceding siblings ...)
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 3/6] spapr: move memory hotplug support check into spapr_memory_pre_plug() David Hildenbrand
@ 2018-06-08 12:48 ` David Hildenbrand
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 5/6] spapr: handle pc-dimm unplug via hotplug handler chain David Hildenbrand
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2018-06-08 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Alexander Graf, Igor Mammedov, david, Thomas Huth,
	David Gibson, Greg Kurz

We'll be handling unplug of e.g. CPUs and PCDIMMs  via the general
hotplug handler soon, so let's add that handler function.

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/ppc/spapr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 9b8b4068b1..c45f8bc75b 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3584,6 +3584,11 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
     }
 }
 
+static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
+                                        DeviceState *dev, Error **errp)
+{
+}
+
 static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
                                                 DeviceState *dev, Error **errp)
 {
@@ -3978,6 +3983,7 @@ static void spapr_machine_class_init(ObjectClass *oc, void *data)
     mc->get_default_cpu_node_id = spapr_get_default_cpu_node_id;
     mc->possible_cpu_arch_ids = spapr_possible_cpu_arch_ids;
     hc->unplug_request = spapr_machine_device_unplug_request;
+    hc->unplug = spapr_machine_device_unplug;
 
     smc->dr_lmb_enabled = true;
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power8_v2.0");
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH v2 5/6] spapr: handle pc-dimm unplug via hotplug handler chain
  2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
                   ` (3 preceding siblings ...)
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 4/6] spapr: introduce machine unplug handler David Hildenbrand
@ 2018-06-08 12:48 ` David Hildenbrand
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 6/6] spapr: handle cpu core " David Hildenbrand
  2018-06-09  2:01 ` [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Gibson
  6 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2018-06-08 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Alexander Graf, Igor Mammedov, david, Thomas Huth,
	David Gibson, Greg Kurz

Factor out memory unplug into separate function from spapr_lmb_release().
Then use generic hotplug_handler_unplug() to trigger memory unplug,
which will call spapr_machine_device_unplug() -> spapr_memory_unplug()
in the end.

This way unplug operation is not buried in lmb internals and located in
the same place like in other targets, following similar logic/call chain
across targets.

Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/ppc/spapr.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index c45f8bc75b..404d887f4e 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3299,7 +3299,8 @@ static sPAPRDIMMState *spapr_recover_pending_dimm_state(sPAPRMachineState *ms,
 /* Callback to be called during DRC release. */
 void spapr_lmb_release(DeviceState *dev)
 {
-    sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_hotplug_handler(dev));
+    HotplugHandler *hotplug_ctrl = qdev_get_hotplug_handler(dev);
+    sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_ctrl);
     sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
 
     /* This information will get lost if a migration occurs
@@ -3317,9 +3318,17 @@ void spapr_lmb_release(DeviceState *dev)
 
     /*
      * Now that all the LMBs have been removed by the guest, call the
-     * pc-dimm unplug handler to cleanup up the pc-dimm device.
+     * unplug handler chain. This can never fail.
      */
-    pc_dimm_memory_unplug(dev, MACHINE(spapr));
+    hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort);
+}
+
+static void spapr_memory_unplug(HotplugHandler *hotplug_dev, DeviceState *dev)
+{
+    sPAPRMachineState *spapr = SPAPR_MACHINE(hotplug_dev);
+    sPAPRDIMMState *ds = spapr_pending_dimm_unplugs_find(spapr, PC_DIMM(dev));
+
+    pc_dimm_memory_unplug(dev, MACHINE(hotplug_dev));
     object_unparent(OBJECT(dev));
     spapr_pending_dimm_unplugs_remove(spapr, ds);
 }
@@ -3587,6 +3596,9 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
 static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
                                         DeviceState *dev, Error **errp)
 {
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        spapr_memory_unplug(hotplug_dev, dev);
+    }
 }
 
 static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Qemu-devel] [PATCH v2 6/6] spapr: handle cpu core unplug via hotplug handler chain
  2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
                   ` (4 preceding siblings ...)
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 5/6] spapr: handle pc-dimm unplug via hotplug handler chain David Hildenbrand
@ 2018-06-08 12:48 ` David Hildenbrand
  2018-06-09  2:01 ` [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Gibson
  6 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2018-06-08 12:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-ppc, Alexander Graf, Igor Mammedov, david, Thomas Huth,
	David Gibson, Greg Kurz

Factor out cpu core unplug into separate function from
spapr_core_release(). Then use generic hotplug_handler_unplug() to trigger
cpu core unplug, which would call spapr_machine_device_unplug() ->
spapr_core_unplug() in the end.

This way unplug operation is not buried in spapr internals and located
in the same place like in other targets, following similar
logic/call chain across targets.

Acked-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/ppc/spapr.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 404d887f4e..f59999daac 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3416,7 +3416,15 @@ static void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset,
 /* Callback to be called during DRC release. */
 void spapr_core_release(DeviceState *dev)
 {
-    MachineState *ms = MACHINE(qdev_get_hotplug_handler(dev));
+    HotplugHandler *hotplug_ctrl = qdev_get_hotplug_handler(dev);
+
+    /* Call the unplug handler chain. This can never fail. */
+    hotplug_handler_unplug(hotplug_ctrl, dev, &error_abort);
+}
+
+static void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev)
+{
+    MachineState *ms = MACHINE(hotplug_dev);
     sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(ms);
     CPUCore *cc = CPU_CORE(dev);
     CPUArchId *core_slot = spapr_find_cpu_slot(ms, cc->core_id, NULL);
@@ -3598,6 +3606,8 @@ static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
 {
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
         spapr_memory_unplug(hotplug_dev, dev);
+    } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
+        spapr_core_unplug(hotplug_dev, dev);
     }
 }
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/6] spapr: move lookup of the node into spapr_memory_plug()
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 2/6] spapr: move lookup of the node into spapr_memory_plug() David Hildenbrand
@ 2018-06-08 13:20   ` Greg Kurz
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2018-06-08 13:20 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: qemu-devel, qemu-ppc, Alexander Graf, Igor Mammedov, Thomas Huth,
	David Gibson

On Fri,  8 Jun 2018 14:48:12 +0200
David Hildenbrand <david@redhat.com> wrote:

> Let's clean the hotplug handler up by moving lookup of the node into
> the function where it is actually being used.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  hw/ppc/spapr.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f16a0b2870..1f577b274b 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3136,7 +3136,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t size,
>  }
>  
>  static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> -                              uint32_t node, Error **errp)
> +                              Error **errp)
>  {
>      Error *local_err = NULL;
>      sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev);
> @@ -3144,6 +3144,7 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>      PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
>      MemoryRegion *mr;
>      uint64_t align, size, addr;
> +    uint32_t node;
>  
>      mr = ddc->get_memory_region(dimm, &local_err);
>      if (local_err) {
> @@ -3163,6 +3164,8 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>          goto out_unplug;
>      }
>  
> +    node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP,
> +                                    &error_abort);
>      spapr_add_lmbs(dev, addr, size, node,
>                     spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT),
>                     &local_err);
> @@ -3572,16 +3575,11 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
>      sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(ms);
>  
>      if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> -        int node;
> -
>          if (!smc->dr_lmb_enabled) {
>              error_setg(errp, "Memory hotplug not supported for this machine");
>              return;
>          }
> -        node = object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP,
> -                                        &error_abort);
> -
> -        spapr_memory_plug(hotplug_dev, dev, node, errp);
> +        spapr_memory_plug(hotplug_dev, dev, errp);
>      } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
>          spapr_core_plug(hotplug_dev, dev, errp);
>      }

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH v2 3/6] spapr: move memory hotplug support check into spapr_memory_pre_plug()
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 3/6] spapr: move memory hotplug support check into spapr_memory_pre_plug() David Hildenbrand
@ 2018-06-08 13:36   ` Greg Kurz
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kurz @ 2018-06-08 13:36 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: qemu-devel, qemu-ppc, Alexander Graf, Igor Mammedov, Thomas Huth,
	David Gibson

On Fri,  8 Jun 2018 14:48:13 +0200
David Hildenbrand <david@redhat.com> wrote:

> Let's finish cleaning up the hotplug handler. This check can be
> performed in the pre_plug code as the very first thing.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  hw/ppc/spapr.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 1f577b274b..9b8b4068b1 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -3184,12 +3184,18 @@ out:
>  static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                                    Error **errp)
>  {
> +    const sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(hotplug_dev);

Even if const is valid here, it doesn't seem to be widely used in similar
situations:

$ git grep 'Class.* = .*GET_CLASS' | grep const | wc -l
14
$ git grep 'Class.* = .*GET_CLASS' | grep -v const | wc -l
642

>      PCDIMMDevice *dimm = PC_DIMM(dev);
>      PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);

... like here for example. This inconsistency is a bit weird.

The patch is good anyway so:

Reviewed-by: Greg Kurz <groug@kaod.org>

>      MemoryRegion *mr;
>      uint64_t size;
>      char *mem_dev;
>  
> +    if (!smc->dr_lmb_enabled) {
> +        error_setg(errp, "Memory hotplug not supported for this machine");
> +        return;
> +    }
> +
>      mr = ddc->get_memory_region(dimm, errp);
>      if (!mr) {
>          return;
> @@ -3571,14 +3577,7 @@ out:
>  static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
>                                        DeviceState *dev, Error **errp)
>  {
> -    MachineState *ms = MACHINE(hotplug_dev);
> -    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(ms);
> -
>      if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> -        if (!smc->dr_lmb_enabled) {
> -            error_setg(errp, "Memory hotplug not supported for this machine");
> -            return;
> -        }
>          spapr_memory_plug(hotplug_dev, dev, errp);
>      } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) {
>          spapr_core_plug(hotplug_dev, dev, errp);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups
  2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
                   ` (5 preceding siblings ...)
  2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 6/6] spapr: handle cpu core " David Hildenbrand
@ 2018-06-09  2:01 ` David Gibson
  6 siblings, 0 replies; 10+ messages in thread
From: David Gibson @ 2018-06-09  2:01 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: qemu-devel, qemu-ppc, Alexander Graf, Igor Mammedov, Thomas Huth,
	Greg Kurz

[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]

On Fri, Jun 08, 2018 at 02:48:10PM +0200, David Hildenbrand wrote:
> I'll be messing with machine hotplug handlers of pc/spapr/s390x in the
> context of
>     [PATCH v4 00/14] MemoryDevice: use multi stage hotplug handlers
> 
> So this is a spin-off of the cleanup patches in the context of hotplug
> handlers.

Applied to ppc-for-3.0, thanks.

> 
> v1 -> v2:
> - dropped the three "local_err" patches
> - tweaked some patch descriptions
> - Split "spapr: move all DIMM checks into spapr_memory_plug" up
> -- Move the memory hotplug check into the pre_plug handler
> - Use &error_abort instead of NULL
> 
> David Hildenbrand (6):
>   spapr: no need to verify the node
>   spapr: move lookup of the node into spapr_memory_plug()
>   spapr: move memory hotplug support check into spapr_memory_pre_plug()
>   spapr: introduce machine unplug handler
>   spapr: handle pc-dimm unplug via hotplug handler chain
>   spapr: handle cpu core unplug via hotplug handler chain
> 
>  hw/ppc/spapr.c | 67 ++++++++++++++++++++++++++++++++------------------
>  1 file changed, 43 insertions(+), 24 deletions(-)
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-06-09  2:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-08 12:48 [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Hildenbrand
2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 1/6] spapr: no need to verify the node David Hildenbrand
2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 2/6] spapr: move lookup of the node into spapr_memory_plug() David Hildenbrand
2018-06-08 13:20   ` Greg Kurz
2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 3/6] spapr: move memory hotplug support check into spapr_memory_pre_plug() David Hildenbrand
2018-06-08 13:36   ` Greg Kurz
2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 4/6] spapr: introduce machine unplug handler David Hildenbrand
2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 5/6] spapr: handle pc-dimm unplug via hotplug handler chain David Hildenbrand
2018-06-08 12:48 ` [Qemu-devel] [PATCH v2 6/6] spapr: handle cpu core " David Hildenbrand
2018-06-09  2:01 ` [Qemu-devel] [PATCH v2 0/6] spapr: machine hotplug handler cleanups David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.