jmsperu commented on PR #12826:
URL: https://github.com/apache/cloudstack/pull/12826#issuecomment-4547298132

   Thanks for the catch @DaanHoogland 🙏
   
   You were right — `findNextAvailablePciSlot` was piping `vm.getXMLDesc(0)` 
straight into `Pattern.matcher(...)`, which NPEs when libvirt returns null 
(and, in the test, when the Domain mock isn't stubbed for that call).
   
   Just pushed two fixes:
   
   1. **Production:** added a null check in `findNextAvailablePciSlot` — when 
the domain XML is unavailable we now log and return `null`, which falls through 
to libvirt's auto-assignment (same behaviour as before this PR when no PCI slot 
is calculated). This makes the path safe whether libvirt returns null on error 
or the parser fails for any reason.
   
   2. **Test:** stubbed `Domain.getXMLDesc(0)` in 
`testPlugNicCommandNoMatchMack` with a minimal `<domain>` XML containing one 
PCI-addressed NIC. This way the test exercises the parser path (rather than 
just falling through the null guard), which more closely matches real PlugNic 
invocations.
   
   Will keep an eye on the next SL run.


-- 
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]

Reply via email to