[PATCH 1/1] NEWS.rst: update with pSeries initial memory fix

Daniel Henrique Barboza danielhb413 at gmail.com
Wed Jan 6 15:50:13 UTC 2021

On 1/6/21 12:03 PM, Daniel P. Berrangé wrote:
> On Wed, Jan 06, 2021 at 12:00:30PM -0300, Daniel Henrique Barboza wrote:
>> On 1/6/21 11:47 AM, Daniel P. Berrangé wrote:
>>> On Wed, Jan 06, 2021 at 11:42:09AM -0300, Daniel Henrique Barboza wrote:
>>>> Commit v6.10.0-103-g198c1eb6b4 fixed this issue.
>>>> Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
>>>> ---
>>>> I forgot to update NEWS.rst back then :/
>>>>    NEWS.rst | 7 +++++++
>>>>    1 file changed, 7 insertions(+)
>>>> diff --git a/NEWS.rst b/NEWS.rst
>>>> index da88b19d0a..2c5cee77db 100644
>>>> --- a/NEWS.rst
>>>> +++ b/NEWS.rst
>>>> @@ -23,6 +23,13 @@ v7.0.0 (unreleased)
>>>>    * **Bug fixes**
>>>> +  * Avoid taking extra host memory when launching pSeries guests
>>>> +
>>>> +    Under certain conditions, pSeries guests were being launched with more
>>>> +    RAM than it was specified in the domain XML by the user. New pSeries
>>>> +    domains created with libvirt 7.0.0 will always launch with the right
>>>> +    amount of initial memory.
>>> Surely this is going to break live migration from old to new libvirt,
>>> as the QEMU started in the dest host will have a smaller -m arg.
>> This bug fix is being effective just when VIR_DOMAIN_DEF_PARSE_ABI_UPDATE is set.
>> The migration code doesn't set this flag.
> That doesn't make it safe.

Let me give a quick context since v6.10.0-103-g198c1eb6b4 commit msg explains
it in detail. There is (still) an issue with the order we're doing things
inside qemuDomainAlignMemorySizes(). We're calculating initialmem before
aligning the memory modules, but the memory modules sizes are used in the
initialmem calc, i.e. initialmem = total_mem - sum_of_mem_modules

ppc64 has a 256Mb alignment, and prior to this change the mem modules were left
unaligned for the initialmem calc in this function. So for a 2Gb totalmem guest
with a 100Mb (unaligned) mem module:

initialmem = 2Gb - 100Mb = 1.9Gb

Later in the same function we align the memory modules, and then re-calculate
the totalmem, and we'll have:

totalmem = initialmem + aligned_mem_modules = 1.9 + 256Mb = 2156Mb, i.e. we
overshot the intended memory in 156Mb. Aligning the memory modules in
PostParse prevent this from happening.

Now note that qemuDomainAlignMemorySizes() is called only when VIR_QEMU_PROCESS_START_NEW
is set. This flag is not being set during migration or snapshot reload (as seen
in qemuProcessStart(). This logic was originally set by Peter in commit

This means that the change made for pSeries guests will only occur when:

- VIR_DOMAIN_DEF_PARSE_ABI_UPDATE is set, so PostParse alignment happens;

- VIR_QEMU_PROCESS_START_NEW is set, otherwise qemuDomainAlignMemorySizes()
will not execute.

> virDomainCreateXML on the source Libvirt 7.0.0 on the source  will set
> PARSE_ABI_UPDATE and thus set the new smaller RAM size.
> Now we live migrate to libvirt 6.9.0 on dest host, and that will not
> set PARSE_ABI_UPDATE and thus set the larger RAM size.

In this scenario, yes, the memory modules on the destination will not be aligned in
PostParse time, but they'll not be used to calculate initialmem/totalmem again
because we don't align memory during live migration.



> QEMU will fail to load the migration stream since the source and dest
> RAM sizes differ.> 
> Regards,
> Daniel

More information about the libvir-list mailing list