Repository navigation
Conversation
updateVmSharesIfNeeded assumed <shares> is always present, but CpuTuneDef omits it when the calculated shares is 0. Add the element (and <cputune> if needed) when the destination requires shares, and leave the XML alone when it does not.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CpuTuneDef.toString()omits<shares>when the calculated shares is 0 (e.g. a 100 MHz offering with a high cluster CPU overcommit ratio), so the running domain XML can have no<shares>element. During live migration, if the shares computed on the source differ fromnewVmCpuSharesreturned by the destination (cgroup v1 to v2, or a lowered overcommit ratio),updateVmSharesIfNeededcalledgetTextContent()on a null node and the migration failed with a NullPointerException before libvirt was called.When
<shares>is missing, the method now creates it (and<cputune>if absent) with the value required by the destination. If the destination does not need shares (newVmCpuShares<= 0) the XML is left unchanged. Behaviour when<shares>exists is unchanged.Fixes: #14652
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Added three unit tests to
LibvirtMigrateCommandWrapperTest(no<shares>in an existing<cputune>, no<cputune>at all, and no new shares needed). They fail with the NPE without the fix.mvn -pl plugins/hypervisors/kvm test -Dtest=LibvirtMigrateCommandWrapperTest: 40 tests, 0 failures (checkstyle passes). That run was on main; this branch is the same commit cherry-picked onto 4.20 (using the localgetXml(document)helper, since 4.20 has noLibvirtXMLParser), and I did not re-run the build on 4.20 locally. Not tested on real cgroup v1 -> v2 hosts.How did you try to break this feature and the system with this change?
Existing cases (
<shares>present, shares equal on both hosts) are covered by the existing tests and still pass. I did not change how shares are calculated at VM start.