pc-dimm: fix error messages if no slots were defined
PATCH 1/1 pc-dimm: fix error messages if no slots were defined
If not slots were defined we try to allocate an empty bitmap, which fails.
---
This fixes the queued patch "exec: Allow memory regions with size 0"
hw/mem/pc-dimm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/mem/pc-dimm.c +7 -1
@@ -118,9 +118,15 @@ 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 free slots available" ); +return slot; + } + + bitmap =bitmap_new (max_slots);object_child_foreach (qdev_get_machine (), pc_dimm_slot2bitmap, bitmap);/* check if requested slot is not occupied */
Signature · 1 line
2.14.3
Hi David,
Quoted 1 line · David Hildenbrand
If not slots were defined we try to allocate an empty bitmap, which
not -> no
Quoted 15 lines
fails.
Signed-off-by David Hildenbrand <[email protected]>---
This fixes the queued patch "exec: Allow memory regions with size 0"
hw/mem/pc-dimm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)hw/mem/pc-dimm.c +0
-0
hw/mem/pc-dimm.c static int pc_dimm_slot2bitmap(Object *obj, void *opaque) · line 125
Quoted 9 lines
hw/mem/pc-dimm.c +3
-1@@ -118,9 +118,15 @@ 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 free slots available" );
Maybe a better error message would be "no slots were allocated" since max_slots is 0.
Thanks,
Marcel
Quoted 8 lines
hw/mem/pc-dimm.c +4
-0+return slot; + } + + bitmap =bitmap_new (max_slots);object_child_foreach (qdev_get_machine (), pc_dimm_slot2bitmap, bitmap);/* check if requested slot is not occupied */
Quoted 29 lines · Marcel Apfelbaum
Hi David,
Quoted 1 line · David Hildenbrand
If not slots were defined we try to allocate an empty bitmap, which
not -> no
Quoted 22 lines
fails.
Signed-off-by David Hildenbrand <[email protected]>---
This fixes the queued patch "exec: Allow memory regions with size 0"
hw/mem/pc-dimm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)hw/mem/pc-dimm.c +1
-1@@ -118,9 +118,15 @@ 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 ;
Quoted 5 lines
hw/mem/pc-dimm.c static int pc_dimm_slot2bitmap(Object *obj, void *opaque) · line 125
Quoted 2 lines
hw/mem/pc-dimm.c +2
-0+if (max_slots <=0 ) { +error_setg (errp,"no free slots available" );Maybe a better error message would be "no slots were allocated" since
max_slotsis 0.
I am using the same error message as if there are no more slots available. If can change it to "no slots where allocated, please specify the 'slots' option.
Using max_slots would be wrong.
Thanks!
Quoted 12 lines
Thanks,
MarcelQuoted 8 lines
hw/mem/pc-dimm.c +4
-0+return slot; + } + + bitmap =bitmap_new (max_slots);object_child_foreach (qdev_get_machine (), pc_dimm_slot2bitmap, bitmap);/* check if requested slot is not occupied */
Signature · 3 lines
Thanks, David / dhildenb