[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v2] pc-dimm: fix error messages if no slots were d
From: |
Marcel Apfelbaum |
Subject: |
Re: [Qemu-ppc] [PATCH v2] pc-dimm: fix error messages if no slots were defined |
Date: |
Fri, 27 Apr 2018 15:36:25 +0300 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
On 27/04/2018 15:05, David Hildenbrand wrote:
> If no slots were defined we try to allocate an empty bitmap, which
> fails.
>
> Signed-off-by: David Hildenbrand <address@hidden>
> ---
>
> v1 -> v2: more detailed error message
>
> hw/mem/pc-dimm.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 0119c68e01..12da89d562 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -118,9 +118,16 @@ static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
>
> int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp)
> {
> - unsigned long *bitmap = bitmap_new(max_slots);
> + unsigned long *bitmap;
> int slot = 0;
>
> + if (max_slots <= 0) {
> + error_setg(errp, "no slots where allocated, please specify "
> + "the 'slots' option");
> + return slot;
> + }
> +
> + bitmap = bitmap_new(max_slots);
> object_child_foreach(qdev_get_machine(), pc_dimm_slot2bitmap, bitmap);
>
> /* check if requested slot is not occupied */
>
Reviewed-by: Marcel Apfelbaum <address@hidden>
Thanks,
Marcel