HawkForge opened a new pull request, #14685: URL: https://github.com/apache/cloudstack/pull/14685
### 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 from `newVmCpuShares` returned by the destination (cgroup v1 to v2, or a lowered overcommit ratio), `updateVmSharesIfNeeded` called `getTextContent()` 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 - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [x] Bug fix (non-breaking change which fixes an issue) - [ ] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) - [ ] Build/CI - [ ] Test (unit or integration test code) ### Feature/Enhancement Scale or Bug Severity #### Bug Severity - [ ] BLOCKER - [ ] Critical - [x] Major - [ ] Minor - [ ] Trivial ### 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 local `getXml(document)` helper, since 4.20 has no `LibvirtXMLParser`), 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. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
