* [Qemu-devel] [PATCH v2] pc-dimm: fix error messages if no slots were defined
@ 2018-04-27 12:05 David Hildenbrand
2018-04-27 12:36 ` Marcel Apfelbaum
2018-04-27 16:25 ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
0 siblings, 2 replies; 4+ messages in thread
From: David Hildenbrand @ 2018-04-27 12:05 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 no slots were defined we try to allocate an empty bitmap, which
fails.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
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 */
--
2.14.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] pc-dimm: fix error messages if no slots were defined
2018-04-27 12:05 [Qemu-devel] [PATCH v2] pc-dimm: fix error messages if no slots were defined David Hildenbrand
@ 2018-04-27 12:36 ` Marcel Apfelbaum
2018-04-27 16:25 ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
1 sibling, 0 replies; 4+ messages in thread
From: Marcel Apfelbaum @ 2018-04-27 12:36 UTC (permalink / raw)
To: David Hildenbrand, qemu-devel
Cc: qemu-s390x, Michael S . Tsirkin, Igor Mammedov, Paolo Bonzini,
Richard Henderson, Eduardo Habkost, David Gibson,
Markus Armbruster, qemu-ppc, Pankaj Gupta, Alexander Graf
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 <david@redhat.com>
> ---
>
> 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 <marcel@redhat.com>
Thanks,
Marcel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v2] pc-dimm: fix error messages if no slots were defined
2018-04-27 12:05 [Qemu-devel] [PATCH v2] pc-dimm: fix error messages if no slots were defined David Hildenbrand
2018-04-27 12:36 ` Marcel Apfelbaum
@ 2018-04-27 16:25 ` Thomas Huth
2018-05-02 11:10 ` Paolo Bonzini
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2018-04-27 16:25 UTC (permalink / raw)
To: David Hildenbrand, qemu-devel
Cc: Pankaj Gupta, Eduardo Habkost, Michael S . Tsirkin,
Markus Armbruster, qemu-s390x, qemu-ppc, Paolo Bonzini,
Marcel Apfelbaum, Igor Mammedov, David Gibson, Richard Henderson
On 27.04.2018 14:05, David Hildenbrand wrote:
> If no slots were defined we try to allocate an empty bitmap, which
> fails.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>
> 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;
In case you respin, I'd maybe rather return -1 here.
But since this is not used by the caller anyway in case of errors:
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v2] pc-dimm: fix error messages if no slots were defined
2018-04-27 16:25 ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
@ 2018-05-02 11:10 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2018-05-02 11:10 UTC (permalink / raw)
To: Thomas Huth, David Hildenbrand, qemu-devel
Cc: Pankaj Gupta, Eduardo Habkost, Michael S . Tsirkin,
Markus Armbruster, qemu-s390x, qemu-ppc, Marcel Apfelbaum,
Igor Mammedov, David Gibson, Richard Henderson
On 27/04/2018 18:25, Thomas Huth wrote:
> On 27.04.2018 14:05, David Hildenbrand wrote:
>> If no slots were defined we try to allocate an empty bitmap, which
>> fails.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>
>> 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;
>
> In case you respin, I'd maybe rather return -1 here.
>
> But since this is not used by the caller anyway in case of errors:
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
Queued, thanks all.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-05-02 11:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-27 12:05 [Qemu-devel] [PATCH v2] pc-dimm: fix error messages if no slots were defined David Hildenbrand
2018-04-27 12:36 ` Marcel Apfelbaum
2018-04-27 16:25 ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
2018-05-02 11:10 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).