s390x/s390-virtio-ccw: don't crash on weird RAM sizes
authorDavid Hildenbrand <david@redhat.com>
Thu, 19 Dec 2024 14:41:02 +0000 (15:41 +0100)
committerDavid Hildenbrand <david@redhat.com>
Sat, 21 Dec 2024 14:59:59 +0000 (15:59 +0100)
commit14e568ab4836347481af2e334009c385f456a734
treef7f3414e3fa11dca8f30690fe6638124ce895fa4
parent713484d0389c9d1cbb87eca060361281248b69f5
s390x/s390-virtio-ccw: don't crash on weird RAM sizes

KVM is not happy when starting a VM with weird RAM sizes:

  # qemu-system-s390x --enable-kvm --nographic -m 1234K
  qemu-system-s390x: kvm_set_user_memory_region: KVM_SET_USER_MEMORY_REGION
    failed, slot=0, start=0x0, size=0x244000: Invalid argument
  kvm_set_phys_mem: error registering slot: Invalid argument
  Aborted (core dumped)

Let's handle that in a better way by rejecting such weird RAM sizes
right from the start:

  # qemu-system-s390x --enable-kvm --nographic -m 1234K
  qemu-system-s390x: ram size must be multiples of 1 MiB

Message-ID: <20241219144115.2820241-2-david@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
hw/s390x/s390-virtio-ccw.c