* [Qemu-devel] [PATCH v1] pc-dimm: fix error messages if no slots were defined
@ 2018-04-26 10:34 David Hildenbrand
2018-04-26 11:41 ` Marcel Apfelbaum
0 siblings, 1 reply; 3+ messages in thread
From: David Hildenbrand @ 2018-04-26 10:34 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-s390x, Michael S . Tsirkin, Igor Mammedov, Marcel Apfelbaum,
Paolo Bonzini, Richard Henderson, Eduardo Habkost, David Gibson,
Markus Armbruster, qemu-ppc, Pankaj Gupta, Alexander Graf,
David Hildenbrand
If not slots were defined we try to allocate an empty bitmap, which
fails.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
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(-)
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 0119c68e01..f2c140947d 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -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 */
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v1] pc-dimm: fix error messages if no slots were defined
2018-04-26 10:34 [Qemu-devel] [PATCH v1] pc-dimm: fix error messages if no slots were defined David Hildenbrand
@ 2018-04-26 11:41 ` Marcel Apfelbaum
2018-04-26 13:12 ` David Hildenbrand
0 siblings, 1 reply; 3+ messages in thread
From: Marcel Apfelbaum @ 2018-04-26 11:41 UTC (permalink / raw)
To: David Hildenbrand, qemu-devel
Cc: Pankaj Gupta, Eduardo Habkost, Michael S . Tsirkin,
Markus Armbruster, Alexander Graf, qemu-s390x, qemu-ppc,
Paolo Bonzini, Marcel Apfelbaum, Igor Mammedov, David Gibson,
Richard Henderson
Hi David,
On 26/04/2018 13:34, David Hildenbrand wrote:
> If not slots were defined we try to allocate an empty bitmap, which
not -> no
> fails.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>
> 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(-)
>
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 0119c68e01..f2c140947d 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -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
> + return slot;
> + }
> +
> + bitmap = bitmap_new(max_slots);
> object_child_foreach(qdev_get_machine(), pc_dimm_slot2bitmap, bitmap);
>
> /* check if requested slot is not occupied */
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v1] pc-dimm: fix error messages if no slots were defined
2018-04-26 11:41 ` Marcel Apfelbaum
@ 2018-04-26 13:12 ` David Hildenbrand
0 siblings, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2018-04-26 13:12 UTC (permalink / raw)
To: Marcel Apfelbaum, qemu-devel
Cc: Pankaj Gupta, Eduardo Habkost, Michael S . Tsirkin,
Markus Armbruster, Alexander Graf, qemu-s390x, qemu-ppc,
Paolo Bonzini, Marcel Apfelbaum, Igor Mammedov, David Gibson,
Richard Henderson
On 26.04.2018 13:41, Marcel Apfelbaum wrote:
> Hi David,
>
> On 26/04/2018 13:34, David Hildenbrand wrote:
>> If not slots were defined we try to allocate an empty bitmap, which
>
> not -> no
>
>> fails.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>
>> 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(-)
>>
>> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
>> index 0119c68e01..f2c140947d 100644
>> --- a/hw/mem/pc-dimm.c
>> +++ b/hw/mem/pc-dimm.c
>> @@ -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.
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!
>
> Thanks,
> Marcel
>
>> + return slot;
>> + }
>> +
>> + bitmap = bitmap_new(max_slots);
>> object_child_foreach(qdev_get_machine(), pc_dimm_slot2bitmap, bitmap);
>>
>> /* check if requested slot is not occupied */
>>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-26 13:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-26 10:34 [Qemu-devel] [PATCH v1] pc-dimm: fix error messages if no slots were defined David Hildenbrand
2018-04-26 11:41 ` Marcel Apfelbaum
2018-04-26 13:12 ` David Hildenbrand
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.