Commit 8326618
committed
fix(kvm): NPE in PlugNic when libvirt domain XML is unavailable
LibvirtPlugNicCommandWrapper.findNextAvailablePciSlot calls
vm.getXMLDesc(0) and pipes the result straight into Pattern.matcher,
which NPEs if libvirt returned null (or, in the
LibvirtComputingResourceTest.testPlugNicCommandNoMatchMack unit test,
when the Domain mock isn't stubbed for getXMLDesc). Reported by
@DaanHoogland after the SL packaging run on #12826.
Defensive null check returns null from findNextAvailablePciSlot when
the domain XML can't be parsed, which falls through to libvirt's
auto-assignment of the PCI slot — same behaviour as before this PR
when nextSlot is null.
Also stubs Domain.getXMLDesc(0) in testPlugNicCommandNoMatchMack with
a minimal <domain> XML that exercises the parser path (rather than
just relying on the null-fallback), so the test continues to cover
the happy path of the new logic.1 parent c572b98 commit 8326618
2 files changed
Lines changed: 17 additions & 0 deletions
File tree
- plugins/hypervisors/kvm/src
- main/java/com/cloud/hypervisor/kvm/resource/wrapper
- test/java/com/cloud/hypervisor/kvm/resource
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3548 | 3548 | | |
3549 | 3549 | | |
3550 | 3550 | | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
3551 | 3560 | | |
3552 | 3561 | | |
3553 | 3562 | | |
| |||
0 commit comments