[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] Python binding APIs strict or loose






           Hi

There is a question. we need strict python binding API or loose one.

                For example:
The setSchedulerParameters(), it accepts one of parameters: 'vcpu_quota' In C its type is of 'long long', then we need a conversion from PyInt/PyLong to 'long long' by using cpython function 'PyLong_AsLongLong'. The problem is when the user python pass in a value of type Pyfloat instead of PyInt/PyLong, the cpython function drops the fraction part of the value automatically, Is it what we want or we need to add a type checking to ensure that the type of value passed in is PyInt/PyLong, otherwise, we raise an exception.

>> dom.schedulerParameters()
{'vcpu_quota': -1L, 'vcpu_period': 100000L, 'cpu_shares': 500L}

>> dom.setSchedulerParameters({'vcpu_quota': 10.88})
                works as dom.setSchedulerParameters({'vcpu_quota': 10})

                Any idea?

                Guannan Ren


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]