HE> I saw that virDomainInfo contains a field nrVirtCpu. Maybe this is
HE> an alternative.
Okay, that was stupid of me :)
HE> Wouldn't the case "virDomainGetVcpus = 32" cause an endless loop ?
HE> On the other hand ... I can not quite follow the reason of this
HE> for loop, which exits right after the first run in case of "count
HE> < 32" ?
No, max gets incremented by 32 each time. The only time we loop again
is if count is equal to max. So, if there are, say 65 vcpus, then the
first time through, we set max=32, and we get back our maximum. That
means count == max == 32. The next time, max is 64, and we get back
64 as well. The next time, max is 96, but we only get back 65, so we
exit the loop.
However, as you pointed out, there is a *much* better way. I just
didn't see it grepping through the API, but I was looking for a
function instead of virDomainInfo, so I missed it :)
HE> This function returns -1 in case of failure. Shouldn't this error
HE> case be reported to the caller ? With the current setup the caller
HE> expects that everything worked.
The caller actually shouldn't care if this fails, because this is only
the dynamic part. If this fails, we still re-write the XML as
expected. However, for the sake of correctness, you're absolutely
right.
Thanks a lot!
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com