<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/libvirt-python.git/libvirt-utils.c, branch v9.3.0</title>
<subtitle>libvirt.org: git/libvirt-python.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/'/>
<entry>
<title>libvirt-utils: Clear error when guessing typed param type</title>
<updated>2022-07-08T06:21:58+00:00</updated>
<author>
<name>Michal Privoznik</name>
<email>mprivozn@redhat.com</email>
</author>
<published>2022-07-08T06:21:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=3532ba2b8c804894a7e23e50380823ff055cd22f'/>
<id>3532ba2b8c804894a7e23e50380823ff055cd22f</id>
<content type='text'>
Our APIs which accept typed parameters are usually exposed in
python as accepting dictionary, for instance:

  virDomainSetIOThreadParams(..., virTypedParameterPtr params, ...) -&gt;
  virDomain.setIOThreadParams(..., {}, ...)

Now, before calling the C API, the dictionary is processed by
virPyDictToTypedParams() which accepts an additional argument:
array that hints types for each typed parameter. However, if a
key is not in the array we guess what the correct type might be.
This is done by attempting conversion from python into string, if
that fails then into boolean, then into long, only to fall back
to double. Now, for the long type we can have two cases: the
value is non-negative (ULL) or it is negative (LL). Therefore, we
firstly attempt ULL case and if that fails we stick with the
latter.

However, after we attempted the ULL conversion, python records an
error internally (which is then queried via PyErr_Occurred()),
but the error is never cleared out. This leads to spurious paths
taken afterwards: e.g. when libvirt_longlongUnwrap() is trying to
convert -1, it fails. But not rightfully - the PyErr_Occurred()
check it performs has nothing to do with any of its actions,
rather than our guessing work done before.

Therefore, clear the error after we've guessed the type.

Signed-off-by: Michal Privoznik &lt;mprivozn@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Our APIs which accept typed parameters are usually exposed in
python as accepting dictionary, for instance:

  virDomainSetIOThreadParams(..., virTypedParameterPtr params, ...) -&gt;
  virDomain.setIOThreadParams(..., {}, ...)

Now, before calling the C API, the dictionary is processed by
virPyDictToTypedParams() which accepts an additional argument:
array that hints types for each typed parameter. However, if a
key is not in the array we guess what the correct type might be.
This is done by attempting conversion from python into string, if
that fails then into boolean, then into long, only to fall back
to double. Now, for the long type we can have two cases: the
value is non-negative (ULL) or it is negative (LL). Therefore, we
firstly attempt ULL case and if that fails we stick with the
latter.

However, after we attempted the ULL conversion, python records an
error internally (which is then queried via PyErr_Occurred()),
but the error is never cleared out. This leads to spurious paths
taken afterwards: e.g. when libvirt_longlongUnwrap() is trying to
convert -1, it fails. But not rightfully - the PyErr_Occurred()
check it performs has nothing to do with any of its actions,
rather than our guessing work done before.

Therefore, clear the error after we've guessed the type.

Signed-off-by: Michal Privoznik &lt;mprivozn@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Drop support for python 2</title>
<updated>2019-12-04T12:14:51+00:00</updated>
<author>
<name>Daniel P. Berrangé</name>
<email>berrange@redhat.com</email>
</author>
<published>2019-12-04T10:27:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=b22e4f2441078aec048b9503fde2b45e78710ce1'/>
<id>b22e4f2441078aec048b9503fde2b45e78710ce1</id>
<content type='text'>
python2 will be end of life by the time of the next
libvirt release. All our supported build targets, including
CentOS7, have a python3 build available.

Reviewed-by: Michal Privoznik &lt;mprivozn@redhat.com&gt;
Signed-off-by: Daniel P. Berrangé &lt;berrange@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
python2 will be end of life by the time of the next
libvirt release. All our supported build targets, including
CentOS7, have a python3 build available.

Reviewed-by: Michal Privoznik &lt;mprivozn@redhat.com&gt;
Signed-off-by: Daniel P. Berrangé &lt;berrange@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libvirt_charPtrUnwrap: remove unnecessary check of returned string</title>
<updated>2018-06-12T08:27:38+00:00</updated>
<author>
<name>Pavel Hrdina</name>
<email>phrdina@redhat.com</email>
</author>
<published>2018-06-12T05:12:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=a950b083177934aebab8c1902699e5ae77033b4d'/>
<id>a950b083177934aebab8c1902699e5ae77033b4d</id>
<content type='text'>
Function libvirt_charPtrUnwrap() either fails or always sets the
unwrapped string so there is no need to check it explicitly.

Reviewed-by: Ján Tomko &lt;jtomko@redhat.com&gt;
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Function libvirt_charPtrUnwrap() either fails or always sets the
unwrapped string so there is no need to check it explicitly.

Reviewed-by: Ján Tomko &lt;jtomko@redhat.com&gt;
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libvirt-utils: remove unused py_str function</title>
<updated>2018-06-12T08:27:14+00:00</updated>
<author>
<name>Pavel Hrdina</name>
<email>phrdina@redhat.com</email>
</author>
<published>2018-06-01T09:12:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=fb70ad159992c2290ae73a243682982e778dd796'/>
<id>fb70ad159992c2290ae73a243682982e778dd796</id>
<content type='text'>
Commit &lt;57a160b5248ba47d4e1c9d22d95847dad8e0524f&gt; removed last usage
but did not remove the function itself.

Reviewed-by: Ján Tomko &lt;jtomko@redhat.com&gt;
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit &lt;57a160b5248ba47d4e1c9d22d95847dad8e0524f&gt; removed last usage
but did not remove the function itself.

Reviewed-by: Ján Tomko &lt;jtomko@redhat.com&gt;
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid implicit treatment of an arithmetic result as a boolean</title>
<updated>2017-09-26T10:14:03+00:00</updated>
<author>
<name>Daniel P. Berrange</name>
<email>berrange@redhat.com</email>
</author>
<published>2017-09-26T10:14:03+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=ac8faf417ed4fbea0e3a579ffd365bbcc09d913f'/>
<id>ac8faf417ed4fbea0e3a579ffd365bbcc09d913f</id>
<content type='text'>
Latest GCC versions are unhappy with us treating an integer
arithmetic result as a boolean:

libvirt-utils.c: In function ‘virReallocN’:
libvirt-utils.c:111:23: warning: ‘*’ in boolean context, suggest ‘&amp;&amp;’ instead [-Wint-in-bool-context]
     if (!tmp &amp;&amp; (size * count)) {
                 ~~~~~~^~~~~~~~

Add an explicit comparison '!= 0' to keep it happy, since its
suggestion to use '&amp;&amp;' is nonsense.

Signed-off-by: Daniel P. Berrange &lt;berrange@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Latest GCC versions are unhappy with us treating an integer
arithmetic result as a boolean:

libvirt-utils.c: In function ‘virReallocN’:
libvirt-utils.c:111:23: warning: ‘*’ in boolean context, suggest ‘&amp;&amp;’ instead [-Wint-in-bool-context]
     if (!tmp &amp;&amp; (size * count)) {
                 ~~~~~~^~~~~~~~

Add an explicit comparison '!= 0' to keep it happy, since its
suggestion to use '&amp;&amp;' is nonsense.

Signed-off-by: Daniel P. Berrange &lt;berrange@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix comparisons between signed &amp; unsigned integers</title>
<updated>2017-09-26T10:12:18+00:00</updated>
<author>
<name>Daniel P. Berrange</name>
<email>berrange@redhat.com</email>
</author>
<published>2017-09-26T10:12:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=75ec2acb6163b4f71921e6efbaca088fa8ed16a9'/>
<id>75ec2acb6163b4f71921e6efbaca088fa8ed16a9</id>
<content type='text'>
When python3 builds C modules, it adds the -Wsign-compare flag to GCC.
This creates lots of warnings where we compare a 'size_t' value against
an 'int' value due to signed/unsigned difference.  Change all the size_t
types to ssize_t to address this.

Signed-off-by: Daniel P. Berrange &lt;berrange@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When python3 builds C modules, it adds the -Wsign-compare flag to GCC.
This creates lots of warnings where we compare a 'size_t' value against
an 'int' value due to signed/unsigned difference.  Change all the size_t
types to ssize_t to address this.

Signed-off-by: Daniel P. Berrange &lt;berrange@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>don't overrun buffer when converting cpumap</title>
<updated>2016-11-11T13:02:24+00:00</updated>
<author>
<name>Konstantin Neumoin</name>
<email>kneumoin@virtuozzo.com</email>
</author>
<published>2016-11-03T17:05:52+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=4a77ad764bd0a5cfdbffd55b993c1825cb72f9ea'/>
<id>4a77ad764bd0a5cfdbffd55b993c1825cb72f9ea</id>
<content type='text'>
If we pass large(more than cpunum) cpu mask to any libvirt_virDomainPin*
function, it could leads to crash. So we have to check tuple size in
virPyCpumapConvert and ignore extra tuple members.

Since we allocate a zeroed buffer, we don't need to bother with setting
the bits to zero.

Signed-off-by: Konstantin Neumoin &lt;kneumoin@virtuozzo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we pass large(more than cpunum) cpu mask to any libvirt_virDomainPin*
function, it could leads to crash. So we have to check tuple size in
virPyCpumapConvert and ignore extra tuple members.

Since we allocate a zeroed buffer, we don't need to bother with setting
the bits to zero.

Signed-off-by: Konstantin Neumoin &lt;kneumoin@virtuozzo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>move cpumap conversion code to a common helper</title>
<updated>2016-11-11T12:44:44+00:00</updated>
<author>
<name>Konstantin Neumoin</name>
<email>kneumoin@virtuozzo.com</email>
</author>
<published>2016-11-03T17:05:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=a03d782b3e19cb9b4681783ec1f6c88615128627'/>
<id>a03d782b3e19cb9b4681783ec1f6c88615128627</id>
<content type='text'>
All libvirt_virDomainPin* functions do the same thing for convert
pycpumap to cpumap, so this patch moves all common logic to new
helper - virPyCpumapConvert.

Signed-off-by: Konstantin Neumoin &lt;kneumoin@virtuozzo.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
All libvirt_virDomainPin* functions do the same thing for convert
pycpumap to cpumap, so this patch moves all common logic to new
helper - virPyCpumapConvert.

Signed-off-by: Konstantin Neumoin &lt;kneumoin@virtuozzo.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>use VIR_PY_DICT_SET_GOTO</title>
<updated>2015-10-05T07:42:44+00:00</updated>
<author>
<name>Pavel Hrdina</name>
<email>phrdina@redhat.com</email>
</author>
<published>2015-09-22T14:10:04+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=0a9385286a7265a9f1fd2321e037681d7247270b'/>
<id>0a9385286a7265a9f1fd2321e037681d7247270b</id>
<content type='text'>
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>indent labels by one space</title>
<updated>2015-10-05T06:35:30+00:00</updated>
<author>
<name>Pavel Hrdina</name>
<email>phrdina@redhat.com</email>
</author>
<published>2015-09-21T14:36:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libvirt-python.git/commit/?id=c982604ef855ef3093c03209a958295cc965957a'/>
<id>c982604ef855ef3093c03209a958295cc965957a</id>
<content type='text'>
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Pavel Hrdina &lt;phrdina@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
