s390x: Reject unaligned RAM sizes
PATCH 1/1 s390x: Reject unaligned RAM sizes
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit 3a12fc61af5c ("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.
Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup maxram_size as well, make other users use ram_size instead. Keep using maxram_size when setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
2. Migrating upstream QEMU to upstream QEMU (e.g., with "-m 1235M"), as we receive storage attributes for memory we don't expect (as we fixed up ram_size and maxram_size).
--- hw/s390x/s390-skeys.c | 4 +--- hw/s390x/s390-stattrib-kvm.c | 7 ++----- hw/s390x/sclp.c | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-)
hw/s390x/s390-skeys.c +1 -3
@@ -11,7 +11,6 @@#include "qemu/osdep.h" #include "qemu/units.h" -#include "hw/boards.h" #include "hw/s390x/storage-keys.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc-target.h"
@@ -174,9 +173,8 @@ out:static void qemu_s390_skeys_init (Object *obj) {QEMUS390SKeysState *skeys =QEMU_S390_SKEYS (obj); -MachineState *machine =MACHINE (qdev_get_machine ()); - skeys->key_count = machine->maxram_size /TARGET_PAGE_SIZE ; + skeys->key_count = ram_size /TARGET_PAGE_SIZE ; skeys->keydata =g_malloc0 (skeys->key_count); }
hw/s390x/s390-stattrib-kvm.c +2 -5
@@ -10,7 +10,6 @@*/ #include "qemu/osdep.h" -#include "hw/boards.h" #include "migration/qemu-file.h" #include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h"
@@ -84,8 +83,7 @@ static int kvm_s390_stattrib_set_stattr(S390StAttribState *sa, uint8_t *values) {KVMS390StAttribState *sas =KVM_S390_STATTRIB (sa); -MachineState *machine =MACHINE (qdev_get_machine ()); -unsigned long max = machine->maxram_size /TARGET_PAGE_SIZE ; +unsigned long max = ram_size /TARGET_PAGE_SIZE ;if (start_gfn + count > max) {error_report ("Out of memory bounds when setting storage attributes" );
@@ -103,8 +101,7 @@ static int kvm_s390_stattrib_set_stattr(S390StAttribState *sa,static void kvm_s390_stattrib_synchronize (S390StAttribState *sa) {KVMS390StAttribState *sas =KVM_S390_STATTRIB (sa); -MachineState *machine =MACHINE (qdev_get_machine ()); -unsigned long max = machine->maxram_size /TARGET_PAGE_SIZE ; +unsigned long max = ram_size /TARGET_PAGE_SIZE ;/* We do not need to reach the maximum buffer size allowed */ unsigned long cx, len =KVM_S390_SKEYS_MAX /2 ;int r;
hw/s390x/sclp.c +11 -10
@@ -326,8 +326,7 @@ out:static void sclp_memory_init (SCLPDevice *sclp) { -MachineState *machine =MACHINE (qdev_get_machine ()); -ram_addr_t initial_mem = machine->ram_size; +uint64_t initial_mem = ram_size;int increment_size =20 ;/* The storage increment size is a multiple of 1M and is a power of 2.
@@ -339,15 +338,17 @@ static void sclp_memory_init(SCLPDevice *sclp) } sclp->increment_size = increment_size; -/* The core memory area needs to be aligned with the increment size. -* In effect, this can cause the user-specified memory size to be rounded -* down to align with the nearest increment boundary. */ +/* +* The core memory area needs to be aligned to the increment size. In +* case it's not aligned, bail out. +*/ initial_mem = initial_mem >> increment_size << increment_size; - - machine->ram_size = initial_mem; - machine->maxram_size = initial_mem; -/* let's propagate the changed ram size into the global variable. */ - ram_size = initial_mem; +if (initial_mem != ram_size) { +error_report ("RAM size not aligned to storage increments." +" Possible aligned RAM size: %" PRIu64" MB" , + initial_mem / MiB); +exit (1 ); + } }static void sclp_init (Object *obj)
Signature · 1 line
2.25.1
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).
Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 10 lines
2. Migrating upstream QEMU to upstream QEMU (e.g., with "-m 1235M"), as we receive storage attributes for memory we don't expect (as we fixed up
ram_sizeandmaxram_size).Fixes 3a12fc61af5c ("390x/s390-virtio-ccw: use memdev for RAM")Reported-by Lukáš Doktor <[email protected]>Cc Igor Mammedov <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Quoted 21 lines · Christian Borntraeger
Quoted 18 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).This fixes (or rather rejects early):
Quoted 7 lines
Quoted 2 lines
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Not sure how many such weird-size VMs we actually do have in practice.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 30 lines · David Hildenbrand
Quoted 21 lines · Christian Borntraeger
Quoted 18 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).This fixes (or rather rejects early):
Quoted 7 lines
Quoted 2 lines
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
Quoted 2 lines
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
Quoted 4 lines
Quoted 1 line
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Quoted 34 lines · Igor Mammedov
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 12 lines
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
Quoted 4 lines
Quoted 1 line
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
IIRC, e.g., Kata usually uses 2048MB. Not sure about others, but I'd be surprised if it's not multiples of, say, 128MB.
Quoted 3 lines
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Yeah, and mention it in the cover letter, +eventually a "fixup" table (e.g., old_size < X, has to be aligned to Y).
One alternative is to have an early fixup hack in QEMU, that fixes up the sizes as we did before (and eventually warns the user). Not sure if we really want/need that.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 35 lines · On Fri, 27 Mar 2020 17:53:39 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 34 lines · Igor Mammedov
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
it works
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
IIRC, e.g., Kata usually uses 2048MB. Not sure about others, but I'd be surprised if it's not multiples of, say, 128MB.
Quoted 3 lines
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Quoted 6 lines
Yeah, and mention it in the cover letter, +eventually a "fixup" table (e.g.,
old_size< X, has to be aligned to Y).One alternative is to have an early fixup hack in QEMU, that fixes up the sizes as we did before (and eventually warns the user). Not sure if we really want/need that.
That would require at least a callback at machine level, also practice shows warnings are of no use.
If someone insist on using wrong size with new QEMU, one can write a wrapper script to workaround the issue (if they don't wish to fix configs/tooling). I don't like keeping hacks to fix user mistakes in QEMU and on top of that adding infrastructure for that (QEMU is already too much complicated). Since in this case it break migration only partially, it's sufficient to print error message that suggest correct size to use (like it's been done for other boards, s390 is the last remaining that is doing ram_size fixups). That way user could fix config and restart migration.
Quoted 61 lines · Igor Mammedov
Quoted 35 lines · On Fri, 27 Mar 2020 17:53:39 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 34 lines · Igor Mammedov
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
it works
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
IIRC, e.g., Kata usually uses 2048MB. Not sure about others, but I'd be surprised if it's not multiples of, say, 128MB.
Quoted 3 lines
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Quoted 8 lines
Quoted 6 lines
Yeah, and mention it in the cover letter, +eventually a "fixup" table (e.g.,
old_size< X, has to be aligned to Y).One alternative is to have an early fixup hack in QEMU, that fixes up the sizes as we did before (and eventually warns the user). Not sure if we really want/need that.
That would require at least a callback at machine level, also practice shows warnings are of no use.
I would strongly prefer to not break setups that used to work and do an early fixup (a machine callback). I will have a look.
Quoted 10 lines
If someone insist on using wrong size with new QEMU, one can write a wrapper script to workaround the issue (if they don't wish to fix configs/tooling). I don't like keeping hacks to fix user mistakes in QEMU and on top of that adding infrastructure for that (QEMU is already too much complicated). Since in this case it break migration only partially, it's sufficient to print error message that suggest correct size to use (like it's been done for other boards, s390 is the last remaining that is doing
ram_sizefixups). That way user could fix config and restart migration.
Quoted 65 lines · On Tue, 31 Mar 2020 13:17:38 +0200 Christian Borntraeger…
Quoted 64 lines · Igor Mammedov
Quoted 35 lines · On Fri, 27 Mar 2020 17:53:39 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 34 lines · Igor Mammedov
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
it works
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
IIRC, e.g., Kata usually uses 2048MB. Not sure about others, but I'd be surprised if it's not multiples of, say, 128MB.
Quoted 3 lines
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Yeah, and mention it in the cover letter, +eventually a "fixup" table (e.g.,
old_size< X, has to be aligned to Y).
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
One alternative is to have an early fixup hack in QEMU, that fixes up the sizes as we did before (and eventually warns the user). Not sure if we really want/need that.
That would require at least a callback at machine level, also practice shows warnings are of no use.
I would strongly prefer to not break setups that used to work and do an early fixup (a machine callback). I will have a look.
If it were breaking migration stream or guest ABI, I'd agree with you but it isn't.
So in this case, it's a bug that qemu wasn't checking size for alignment and making workaround to keep the bug around looks wrong to me.
It is fixable on user side (one has to fix VM's config), so it should be fixed there and not in QEMU. And any automatic tooling that generates invalid size should be fixed as well.
(I think it's not QEMU's job to mask users errors and doing something that user not asked for)
Quoted 11 lines
Quoted 9 lines
If someone insist on using wrong size with new QEMU, one can write a wrapper script to workaround the issue (if they don't wish to fix configs/tooling). I don't like keeping hacks to fix user mistakes in QEMU and on top of that adding infrastructure for that (QEMU is already too much complicated). Since in this case it break migration only partially, it's sufficient to print error message that suggest correct size to use (like it's been done for other boards, s390 is the last remaining that is doing
ram_sizefixups). That way user could fix config and restart migration.
Quoted 80 lines · Igor Mammedov
Quoted 65 lines · On Tue, 31 Mar 2020 13:17:38 +0200 Christian Borntraeger…
Quoted 64 lines · Igor Mammedov
Quoted 35 lines · On Fri, 27 Mar 2020 17:53:39 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 34 lines · Igor Mammedov
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
it works
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
IIRC, e.g., Kata usually uses 2048MB. Not sure about others, but I'd be surprised if it's not multiples of, say, 128MB.
Quoted 3 lines
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Yeah, and mention it in the cover letter, +eventually a "fixup" table (e.g.,
old_size< X, has to be aligned to Y).Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
One alternative is to have an early fixup hack in QEMU, that fixes up the sizes as we did before (and eventually warns the user). Not sure if we really want/need that.
That would require at least a callback at machine level, also practice shows warnings are of no use.
I would strongly prefer to not break setups that used to work and do an early fixup (a machine callback). I will have a look.
If it were breaking migration stream or guest ABI, I'd agree with you but it isn't.
Quoted 9 lines
So in this case, it's a bug that qemu wasn't checking size for alignment and making workaround to keep the bug around looks wrong to me.
It is fixable on user side (one has to fix VM's config), so it should be fixed there and not in QEMU. And any automatic tooling that generates invalid size should be fixed as well.
(I think it's not QEMU's job to mask users errors and doing something that user not asked for)
Dave G mentioned, that e.g., via Cockpit it can be fairly easy to produce weird RAM sizes (via a slider). So I guess this "issue" could be more widespread than I initially thought.
I agree that it's a BUG that we didn't bail out but instead decided to fix it up.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 91 lines · David Hildenbrand
Quoted 80 lines · Igor Mammedov
Quoted 65 lines · On Tue, 31 Mar 2020 13:17:38 +0200 Christian Borntraeger…
Quoted 64 lines · Igor Mammedov
Quoted 35 lines · On Fri, 27 Mar 2020 17:53:39 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 34 lines · Igor Mammedov
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
it works
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
IIRC, e.g., Kata usually uses 2048MB. Not sure about others, but I'd be surprised if it's not multiples of, say, 128MB.
Quoted 3 lines
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Yeah, and mention it in the cover letter, +eventually a "fixup" table (e.g.,
old_size< X, has to be aligned to Y).Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
One alternative is to have an early fixup hack in QEMU, that fixes up the sizes as we did before (and eventually warns the user). Not sure if we really want/need that.
That would require at least a callback at machine level, also practice shows warnings are of no use.
I would strongly prefer to not break setups that used to work and do an early fixup (a machine callback). I will have a look.
If it were breaking migration stream or guest ABI, I'd agree with you but it isn't.
Quoted 9 lines
So in this case, it's a bug that qemu wasn't checking size for alignment and making workaround to keep the bug around looks wrong to me.
It is fixable on user side (one has to fix VM's config), so it should be fixed there and not in QEMU. And any automatic tooling that generates invalid size should be fixed as well.
(I think it's not QEMU's job to mask users errors and doing something that user not asked for)
Quoted 6 lines
Dave G mentioned, that e.g., via Cockpit it can be fairly easy to produce weird RAM sizes (via a slider). So I guess this "issue" could be more widespread than I initially thought.
I agree that it's a BUG that we didn't bail out but instead decided to fix it up.
It was a decision back than. Likely a wrong one.
Now insisting on "lets breaking user setups because it violates my feeling of perfection" is not the right answer though.
Quoted 77 lines · Igor Mammedov
Quoted 65 lines · On Tue, 31 Mar 2020 13:17:38 +0200 Christian Borntraeger…
Quoted 64 lines · Igor Mammedov
Quoted 35 lines · On Fri, 27 Mar 2020 17:53:39 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 34 lines · Igor Mammedov
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
it works
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
IIRC, e.g., Kata usually uses 2048MB. Not sure about others, but I'd be surprised if it's not multiples of, say, 128MB.
Quoted 3 lines
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
Yeah, and mention it in the cover letter, +eventually a "fixup" table (e.g.,
old_size< X, has to be aligned to Y).Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
One alternative is to have an early fixup hack in QEMU, that fixes up the sizes as we did before (and eventually warns the user). Not sure if we really want/need that.
That would require at least a callback at machine level, also practice shows warnings are of no use.
I would strongly prefer to not break setups that used to work and do an early fixup (a machine callback). I will have a look.
Quoted 6 lines
If it were breaking migration stream or guest ABI, I'd agree with you but it isn't.
So in this case, it's a bug that qemu wasn't checking size for alignment and making workaround to keep the bug around looks wrong to me.
QEMU did check for alignment and fixed it up. So it was an intentional decision (maybe a bad one). Your change broke working setups and I really do not like that. See my new patch for proper handling for machine types 5.0 and later + compat handling for older machines.
Quoted 40 lines · On Fri, 27 Mar 2020 17:46:20 +0100 Igor Mammedov <[email protected]> wrote:
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
Quoted 9 lines
I'm in process of testing it.
Quoted 4 lines
Quoted 1 line
Not sure how many such weird-size VMs we actually do have in practice.
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
@David: I'm a little confused. Is this fix about adding user input validation, or is it about changing what valid inputs are?
I don't see this alignment requirement documented, so my guess is the latter. And then, I'm not sure I'm sold on this.
Regards,
Halil
Quoted 47 lines · Halil Pasic
Quoted 44 lines · On Fri, 27 Mar 2020 17:46:20 +0100 Igor Mammedov <[email protected]> wrote:
Quoted 31 lines · On Fri, 27 Mar 2020 17:05:34 +0100 Christian Borntraeger…
Quoted 30 lines · David Hildenbrand
Quoted 28 lines · Christian Borntraeger
Quoted 16 lines · David Hildenbrand
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).Quoted 4 lines
This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
Not sure I like this variant. Instead of breaking migration (that was accidentially done by Igors changes) we now reject migration from older QEMUs to 5.0. This is not going to help those that still have such guests running and want to migrate.
Quoted 6 lines
Quoted 4 lines
As Igor mentioned on another channel, you most probably can migrate an older guest by starting it on the target with a fixed-up size.
E.g., migrate an old QEMU "-m 1235M" to a new QEMU "-m 1234M"
Yes, that should probably work.
I'm in process of testing it.
Quoted 2 lines
Quoted 1 line
Not sure how many such weird-size VMs we actually do have in practice.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I am worried about some automated deployments where tooling has created these sizes for dozens or hundreds of containers in VMS and so.
Yep, it's possible but then that tooling/configs should be fixed to work with new QEMU that validates user's input.
@David: I'm a little confused. Is this fix about adding user input validation, or is it about changing what valid inputs are?
We used to silently fixup the user input instead of bailing out. So it's rather the latter. It was never the right choice to silently fixup instead of just bailing out. We never should have done that.
Quoted 3 lines
I don't see this alignment requirement documented, so my guess is the latter. And then, I'm not sure I'm sold on this.
Well, we can add documentation with the next release. It's something to end up in the release notes.
If somebody specified "-m 1235", he always received "1234 MB" and never "1235 MB". You could also call that a BUG, which should have bailed out right from the start (there wasn't even a warning).
Signature · 3 lines
Thanks, David / dhildenb
Quoted 49 lines · On Fri, 27 Mar 2020 16:29:30 +0100 David Hildenbrand <[email protected]> wrote:
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
2. Migrating upstream QEMU to upstream QEMU (e.g., with "-m 1235M"), as we receive storage attributes for memory we don't expect (as we fixed up
ram_sizeandmaxram_size).Fixes 3a12fc61af5c ("390x/s390-virtio-ccw: use memdev for RAM")Reported-by Lukáš Doktor <[email protected]>Cc Igor Mammedov <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-skeys.c | 4 +--- hw/s390x/s390-stattrib-kvm.c | 7 ++----- hw/s390x/sclp.c | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-)hw/s390x/s390-skeys.c +0
-1@@ -11,7 +11,6 @@#include "qemu/osdep.h" #include "qemu/units.h" -#include "hw/boards.h" #include "hw/s390x/storage-keys.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc-target.h"
hw/s390x/s390-skeys.c out: · line 177
Quoted 7 lines
hw/s390x/s390-skeys.c +1
-2@@ -174,9 +173,8 @@ out:static void qemu_s390_skeys_init (Object *obj) {QEMUS390SKeysState *skeys =QEMU_S390_SKEYS (obj); -MachineState *machine =MACHINE (qdev_get_machine ()); - skeys->key_count = machine->maxram_size /TARGET_PAGE_SIZE ; + skeys->key_count = ram_size /TARGET_PAGE_SIZE ;
why are you dropping machine->foo all around and switching to global ram_size? (I'd rather do other way around)
Quoted 75 lines
hw/s390x/s390-skeys.c +0
-0skeys->keydata =g_malloc0 (skeys->key_count); }hw/s390x/s390-stattrib-kvm.c +2
-5@@ -10,7 +10,6 @@*/ #include "qemu/osdep.h" -#include "hw/boards.h" #include "migration/qemu-file.h" #include "hw/s390x/storage-attributes.h" #include "qemu/error-report.h" @@ -84,8 +83,7 @@ static int kvm_s390_stattrib_set_stattr(S390StAttribState *sa, uint8_t *values) {KVMS390StAttribState *sas =KVM_S390_STATTRIB (sa); -MachineState *machine =MACHINE (qdev_get_machine ()); -unsigned long max = machine->maxram_size /TARGET_PAGE_SIZE ; +unsigned long max = ram_size /TARGET_PAGE_SIZE ;if (start_gfn + count > max) {error_report ("Out of memory bounds when setting storage attributes" );@@ -103,8 +101,7 @@ static int kvm_s390_stattrib_set_stattr(S390StAttribState *sa,static void kvm_s390_stattrib_synchronize (S390StAttribState *sa) {KVMS390StAttribState *sas =KVM_S390_STATTRIB (sa); -MachineState *machine =MACHINE (qdev_get_machine ()); -unsigned long max = machine->maxram_size /TARGET_PAGE_SIZE ; +unsigned long max = ram_size /TARGET_PAGE_SIZE ;/* We do not need to reach the maximum buffer size allowed */ unsigned long cx, len =KVM_S390_SKEYS_MAX /2 ;int r;hw/s390x/sclp.c +11
-10@@ -326,8 +326,7 @@ out:static void sclp_memory_init (SCLPDevice *sclp) { -MachineState *machine =MACHINE (qdev_get_machine ()); -ram_addr_t initial_mem = machine->ram_size; +uint64_t initial_mem = ram_size;int increment_size =20 ;/* The storage increment size is a multiple of 1M and is a power of 2. @@ -339,15 +338,17 @@ static void sclp_memory_init(SCLPDevice *sclp) } sclp->increment_size = increment_size; -/* The core memory area needs to be aligned with the increment size. -* In effect, this can cause the user-specified memory size to be rounded -* down to align with the nearest increment boundary. */ +/* +* The core memory area needs to be aligned to the increment size. In +* case it's not aligned, bail out. +*/ initial_mem = initial_mem >> increment_size << increment_size; - - machine->ram_size = initial_mem; - machine->maxram_size = initial_mem; -/* let's propagate the changed ram size into the global variable. */ - ram_size = initial_mem; +if (initial_mem != ram_size) { +error_report ("RAM size not aligned to storage increments." +" Possible aligned RAM size: %" PRIu64" MB" , + initial_mem / MiB); +exit (1 ); + } }static void sclp_init (Object *obj)
Quoted 57 lines · Igor Mammedov
Quoted 54 lines · On Fri, 27 Mar 2020 16:29:30 +0100 David Hildenbrand <[email protected]> wrote:
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
2. Migrating upstream QEMU to upstream QEMU (e.g., with "-m 1235M"), as we receive storage attributes for memory we don't expect (as we fixed up
ram_sizeandmaxram_size).Fixes 3a12fc61af5c ("390x/s390-virtio-ccw: use memdev for RAM")Reported-by Lukáš Doktor <[email protected]>Cc Igor Mammedov <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-skeys.c | 4 +--- hw/s390x/s390-stattrib-kvm.c | 7 ++----- hw/s390x/sclp.c | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-)hw/s390x/s390-skeys.c +0
-2@@ -11,7 +11,6 @@#include "qemu/osdep.h" #include "qemu/units.h" -#include "hw/boards.h" #include "hw/s390x/storage-keys.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc-target.h" @@ -174,9 +173,8 @@ out:static void qemu_s390_skeys_init (Object *obj) {QEMUS390SKeysState *skeys =QEMU_S390_SKEYS (obj); -MachineState *machine =MACHINE (qdev_get_machine ());
Quoted 5 lines
hw/s390x/s390-skeys.c out: · line 177
Quoted 2 lines
hw/s390x/s390-skeys.c +1
-1- skeys->key_count = machine->maxram_size /TARGET_PAGE_SIZE ; + skeys->key_count = ram_size /TARGET_PAGE_SIZE ;why are you dropping
machine->fooall around and switching to globalram_size? (I'd rather do other way around)
Not sure what the latest best practice is. I can also simply convert to machine->ram_size if that's the right thing to do.
Signature · 3 lines
Thanks, David / dhildenb
Quoted 58 lines · On Fri, 27 Mar 2020 17:51:23 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 57 lines · Igor Mammedov
Quoted 54 lines · On Fri, 27 Mar 2020 16:29:30 +0100 David Hildenbrand <[email protected]> wrote:
Historically, we fixed up the RAM size (rounded it down), to fit into storage increments. Since commit
3a12fc61af5c("390x/s390-virtio-ccw: use memdev for RAM"), we no longer consider the fixed-up size when allcoating the RAM block - which will break migration.Let's simply drop that manual fixup code and let the user supply sane RAM sizes. This will bail out early when trying to migrate (and make an existing guest with e.g., 12345 MB non-migratable), but maybe we should have rejected such RAM sizes right from the beginning.
As we no longer fixup
maxram_sizeas well, make other users useram_sizeinstead. Keep usingmaxram_sizewhen setting the maximum ram size in KVM, as that will come in handy in the future when supporting memory hotplug (in contrast, storage keys and storage attributes for hotplugged memory
will have to be migrated per RAM block in the future).This fixes (or rather rejects early):
1. Migrating older QEMU to upstream QEMU (e.g., with "-m 1235M"), as the RAM block size changed.
2. Migrating upstream QEMU to upstream QEMU (e.g., with "-m 1235M"), as we receive storage attributes for memory we don't expect (as we fixed up
ram_sizeandmaxram_size).Fixes 3a12fc61af5c ("390x/s390-virtio-ccw: use memdev for RAM")Reported-by Lukáš Doktor <[email protected]>Cc Igor Mammedov <[email protected]>Cc Dr. David Alan Gilbert <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-skeys.c | 4 +--- hw/s390x/s390-stattrib-kvm.c | 7 ++----- hw/s390x/sclp.c | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-)hw/s390x/s390-skeys.c +0
-2@@ -11,7 +11,6 @@#include "qemu/osdep.h" #include "qemu/units.h" -#include "hw/boards.h" #include "hw/s390x/storage-keys.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc-target.h" @@ -174,9 +173,8 @@ out:static void qemu_s390_skeys_init (Object *obj) {QEMUS390SKeysState *skeys =QEMU_S390_SKEYS (obj); -MachineState *machine =MACHINE (qdev_get_machine ());
Quoted 8 lines
Quoted 5 lines
hw/s390x/s390-skeys.c out: · line 177
Quoted 2 lines
hw/s390x/s390-skeys.c +1
-1- skeys->key_count = machine->maxram_size /TARGET_PAGE_SIZE ; + skeys->key_count = ram_size /TARGET_PAGE_SIZE ;why are you dropping
machine->fooall around and switching to globalram_size? (I'd rather do other way around)Not sure what the latest best practice is. I can also simply convert to
machine->ram_sizeif that's the right thing to do.
My understanding of it was not to use globals if possible.
(I planned on removing global ram_size an leave only machine->ram_size but that a bit tricky since things tend to explode once a global touched, so it needs some more thought/patience)