Commit 3ff333ef authored by David Hildenbrand's avatar David Hildenbrand Committed by Paolo Bonzini
Browse files

pc-dimm: fix error messages if no slots were defined



If no slots were defined we try to allocate an empty bitmap, which
fails.

Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarMarcel Apfelbaum <marcel@redhat.com>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Message-Id: <20180427120515.24067-1-david@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 814e1110
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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 */