]> Git Repo - qemu.git/commitdiff
memory-device: Support big alignment requirements
authorDavid Hildenbrand <[email protected]>
Thu, 8 Oct 2020 08:30:27 +0000 (10:30 +0200)
committerMichael S. Tsirkin <[email protected]>
Tue, 3 Nov 2020 12:19:26 +0000 (07:19 -0500)
Let's warn instead of bailing out - the worst thing that can happen is
that we'll fail hot/coldplug later. The user got warned, and this should
be rare.

This will be necessary for memory devices with rather big (user-defined)
alignment requirements - say a virtio-mem device with a 2G block size -
which will become important, for example, when supporting vfio in the
future.

Reviewed-by: Pankaj Gupta <[email protected]>
Cc: "Michael S. Tsirkin" <[email protected]>
Cc: Wei Yang <[email protected]>
Cc: Dr. David Alan Gilbert <[email protected]>
Cc: Igor Mammedov <[email protected]>
Cc: Pankaj Gupta <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Message-Id: <20201008083029[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
hw/mem/memory-device.c

index 4bc9cf0917bf5734fb22af4e0be0102ad5b59122..8a736f1a26b0c463379456b75510de868a826009 100644 (file)
@@ -119,9 +119,10 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
 
     /* start of address space indicates the maximum alignment we expect */
     if (!QEMU_IS_ALIGNED(range_lob(&as), align)) {
-        error_setg(errp, "the alignment (0x%" PRIx64 ") is not supported",
-                   align);
-        return 0;
+        warn_report("the alignment (0x%" PRIx64 ") exceeds the expected"
+                    " maximum alignment, memory will get fragmented and not"
+                    " all 'maxmem' might be usable for memory devices.",
+                    align);
     }
 
     memory_device_check_addable(ms, size, &err);
@@ -151,7 +152,7 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
             return 0;
         }
     } else {
-        if (range_init(&new, range_lob(&as), size)) {
+        if (range_init(&new, QEMU_ALIGN_UP(range_lob(&as), align), size)) {
             error_setg(errp, "can't add memory device, device too big");
             return 0;
         }
This page took 0.027638 seconds and 4 git commands to generate.