[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v1 11/11] pc-dimm: assign and verify the "slot" pr
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v1 11/11] pc-dimm: assign and verify the "slot" property during pre_plug |
Date: |
Tue, 12 Jun 2018 12:02:10 +1000 |
User-agent: |
Mutt/1.10.0 (2018-05-17) |
On Mon, Jun 11, 2018 at 02:16:55PM +0200, David Hildenbrand wrote:
> We can assign and verify the slot before realizing and trying to plug.
> reading/writing the slot property should never change, so let's reduce
> error handling a bit by using &error_abort.
>
> Signed-off-by: David Hildenbrand <address@hidden>
Reviewed-by: David Gibson <address@hidden>
> ---
> hw/mem/pc-dimm.c | 31 ++++++++++++++-----------------
> 1 file changed, 14 insertions(+), 17 deletions(-)
>
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 995ce22d8d..88423f95a3 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -30,12 +30,25 @@
> void pc_dimm_memory_pre_plug(DeviceState *dev, MachineState *machine,
> Error **errp)
> {
> + Error *local_err = NULL;
> + int slot;
> +
> + slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
> + &error_abort);
> + slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL :
> &slot,
> + machine->ram_slots, &local_err);
> + if (local_err) {
> + goto out;
> + }
> + object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP,
> &error_abort);
> + trace_mhp_pc_dimm_assigned_slot(slot);
> +out:
> + error_propagate(errp, local_err);
> }
>
> void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine,
> uint64_t align, Error **errp)
> {
> - int slot;
> PCDIMMDevice *dimm = PC_DIMM(dev);
> PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
> MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
> @@ -61,22 +74,6 @@ void pc_dimm_memory_plug(DeviceState *dev, MachineState
> *machine,
> }
> trace_mhp_pc_dimm_assigned_address(addr);
>
> - slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP,
> &local_err);
> - if (local_err) {
> - goto out;
> - }
> -
> - slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL :
> &slot,
> - machine->ram_slots, &local_err);
> - if (local_err) {
> - goto out;
> - }
> - object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP,
> &local_err);
> - if (local_err) {
> - goto out;
> - }
> - trace_mhp_pc_dimm_assigned_slot(slot);
> -
> memory_device_plug_region(machine, mr, addr);
> vmstate_register_ram(vmstate_mr, dev);
>
--
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
signature.asc
Description: PGP signature
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v1 07/11] pc-dimm: get_memory_region() can never fail, (continued)
[Qemu-ppc] [PATCH v1 10/11] pc-dimm: introduce and use pc_dimm_memory_pre_plug(), David Hildenbrand, 2018/06/11
[Qemu-ppc] [PATCH v1 11/11] pc-dimm: assign and verify the "slot" property during pre_plug, David Hildenbrand, 2018/06/11
- Re: [Qemu-ppc] [PATCH v1 11/11] pc-dimm: assign and verify the "slot" property during pre_plug,
David Gibson <=
Re: [Qemu-ppc] [Qemu-devel] [PATCH v1 00/11] pc-dimm: next bunch of cleanups, Igor Mammedov, 2018/06/13