diff --git a/.gitignore b/.gitignore index 04001dc..459752f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/libvirt-python-1.2.17.tar.gz +SOURCES/libvirt-python-2.0.0.tar.gz diff --git a/.libvirt-python.metadata b/.libvirt-python.metadata index 378d077..c44c67d 100644 --- a/.libvirt-python.metadata +++ b/.libvirt-python.metadata @@ -1 +1 @@ -c1f066dc710e172099d8401ec205d1e59eff950c SOURCES/libvirt-python-1.2.17.tar.gz +dde6d4cdd5fbf02c4d468654c90c043a7c29c5a5 SOURCES/libvirt-python-2.0.0.tar.gz diff --git a/SOURCES/libvirt-python-Check-return-value-of-PyList_Append.patch b/SOURCES/libvirt-python-Check-return-value-of-PyList_Append.patch deleted file mode 100644 index 8f4a3bc..0000000 --- a/SOURCES/libvirt-python-Check-return-value-of-PyList_Append.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 13ba25fa006ae1af1b3a7507cefc9fb433859803 Mon Sep 17 00:00:00 2001 -Message-Id: <13ba25fa006ae1af1b3a7507cefc9fb433859803@dist-git> -From: Jiri Denemark -Date: Mon, 3 Aug 2015 10:26:26 +0200 -Subject: [PATCH] Check return value of PyList_Append - -libvirt_virDomainGetSecurityLabelList called PyList_Append without -checking its return value. While looking at it I noticed the function -did not properly check several other return values either so I fixed -them all. - -https://bugzilla.redhat.com/show_bug.cgi?id=1249511 - -Signed-off-by: Jiri Denemark -(cherry picked from commit 5a6b2c98390a2344c9c3cc10a1c346a4838f0d58) -Signed-off-by: Jiri Denemark ---- - libvirt-override.c | 46 ++++++++++++++++++++++++++++++++++++++-------- - 1 file changed, 38 insertions(+), 8 deletions(-) - -diff --git a/libvirt-override.c b/libvirt-override.c -index 2398228..4dfe332 100644 ---- a/libvirt-override.c -+++ b/libvirt-override.c -@@ -3144,32 +3144,62 @@ libvirt_virDomainGetSecurityLabel(PyObject *self ATTRIBUTE_UNUSED, PyObject *arg - - #if LIBVIR_CHECK_VERSION(0, 10, 0) - static PyObject * --libvirt_virDomainGetSecurityLabelList(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { -+libvirt_virDomainGetSecurityLabelList(PyObject *self ATTRIBUTE_UNUSED, -+ PyObject *args) -+{ - PyObject *py_retval; - int c_retval; - virDomainPtr dom; - PyObject *pyobj_dom; -- virSecurityLabel *labels; -+ virSecurityLabel *labels = NULL; - size_t i; - - if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityLabel", &pyobj_dom)) - return NULL; -+ - dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom); - - LIBVIRT_BEGIN_ALLOW_THREADS; - c_retval = virDomainGetSecurityLabelList(dom, &labels); - LIBVIRT_END_ALLOW_THREADS; -+ - if (c_retval < 0) - return VIR_PY_NONE; -- py_retval = PyList_New(0); -+ -+ if (!(py_retval = PyList_New(0))) -+ goto error; -+ - for (i = 0 ; i < c_retval ; i++) { -- PyObject *entry = PyList_New(2); -- PyList_SetItem(entry, 0, libvirt_constcharPtrWrap(&labels[i].label[0])); -- PyList_SetItem(entry, 1, libvirt_boolWrap(labels[i].enforcing)); -- PyList_Append(py_retval, entry); -+ PyObject *entry; -+ PyObject *value; -+ -+ if (!(entry = PyList_New(2)) || -+ PyList_Append(py_retval, entry) < 0) { -+ Py_XDECREF(entry); -+ goto error; -+ } -+ -+ if (!(value = libvirt_constcharPtrWrap(&labels[i].label[0])) || -+ PyList_SetItem(entry, 0, value) < 0) { -+ Py_XDECREF(value); -+ goto error; -+ } -+ -+ if (!(value = libvirt_boolWrap(labels[i].enforcing)) || -+ PyList_SetItem(entry, 1, value) < 0) { -+ Py_XDECREF(value); -+ goto error; -+ } - } -- free(labels); -+ -+ cleanup: -+ VIR_FREE(labels); - return py_retval; -+ -+ error: -+ Py_XDECREF(py_retval); -+ py_retval = NULL; -+ goto cleanup; - } - #endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */ - --- -2.5.0 - diff --git a/SOURCES/libvirt-python-Fix-crash-in-storage-pool-refresh-callback.patch b/SOURCES/libvirt-python-Fix-crash-in-storage-pool-refresh-callback.patch new file mode 100644 index 0000000..be1ab61 --- /dev/null +++ b/SOURCES/libvirt-python-Fix-crash-in-storage-pool-refresh-callback.patch @@ -0,0 +1,47 @@ +From c3e600b430787105f135e148aaca9b0b481dbfa3 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Pavel Hrdina +Date: Mon, 25 Jul 2016 10:27:18 +0200 +Subject: [PATCH] Fix crash in storage pool refresh callback + +Fixes copy-paste typo introduced by commit cb84e36c. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1354271 + +Signed-off-by: Pavel Hrdina +(cherry picked from commit a3a4425338017ecefd31b969f62a1b5803f92a5c) +Signed-off-by: Pavel Hrdina +--- + examples/event-test.py | 2 +- + libvirt-override.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/examples/event-test.py b/examples/event-test.py +index f0341b5..1bcea07 100755 +--- a/examples/event-test.py ++++ b/examples/event-test.py +@@ -580,7 +580,7 @@ def myStoragePoolEventLifecycleCallback(conn, pool, event, detail, opaque): + storageEventToString(event), + detail)) + +-def myStoragePoolEventRefreshCallback(conn, pool, event, detail, opaque): ++def myStoragePoolEventRefreshCallback(conn, pool, opaque): + print("myStoragePoolEventRefreshCallback: Storage pool %s" % pool.name()) + + ########################################################################## +diff --git a/libvirt-override.c b/libvirt-override.c +index 8f21cfd..72b4b6b 100644 +--- a/libvirt-override.c ++++ b/libvirt-override.c +@@ -8862,7 +8862,7 @@ libvirt_virConnectStoragePoolEventGenericCallback(virConnectPtr conn ATTRIBUTE_U + /* Call the Callback Dispatcher */ + pyobj_ret = PyObject_CallMethod(pyobj_conn, + (char*)"_dispatchStoragePoolEventGenericCallback", +- (char*)"OiiO", ++ (char*)"OO", + pyobj_pool, + pyobj_cbData); + +-- +2.9.2 + diff --git a/SOURCES/libvirt-python-examples-Introduce-nodestats-example.patch b/SOURCES/libvirt-python-examples-Introduce-nodestats-example.patch deleted file mode 100644 index d761f52..0000000 --- a/SOURCES/libvirt-python-examples-Introduce-nodestats-example.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 3d040733d21991fb8141b6a32dca2eca29652ace Mon Sep 17 00:00:00 2001 -Message-Id: <3d040733d21991fb8141b6a32dca2eca29652ace@dist-git> -From: Michal Privoznik -Date: Fri, 17 Jul 2015 11:45:33 +0200 -Subject: [PATCH] examples: Introduce nodestats example - -https://bugzilla.redhat.com/show_bug.cgi?id=1051494 - -So, this is an exercise to show libvirt capabilities. Firstly, for -each host NUMA nodes some statistics are printed out, i.e. total -memory and free memory. Then, for each running domain, that has memory -strictly bound to certain host nodes, a small statistics of how much -memory it takes is printed out too. For instance: - - # ./examples/nodestats.py - NUMA stats - NUMA nodes: 0 1 2 3 - MemTotal: 3950 3967 3937 3943 - MemFree: 66 56 42 41 - Domain 'fedora': - Overall memory: 1536 MiB - Domain 'fedora22': - Overall memory: 2048 MiB - Domain 'fedora21': - Overall memory: 1024 MiB nodes 0-1 - Node 0: 1024 MiB nodes 0-1 - Domain 'gentoo': - Overall memory: 4096 MiB nodes 0-3 - Node 0: 1024 MiB nodes 0 - Node 1: 1024 MiB nodes 1 - Node 2: 1024 MiB nodes 2 - Node 3: 1024 MiB nodes 3 - -We can see 4 host NUMA nodes, all of them having roughly 4GB of RAM. -Yeah, all of them has nearly all the memory consumed. Then, there are -four domains running. For instance, domain 'fedora' has 1.5GB memory -which is not pinned onto any specific host NUMA node. Domain 'gentoo' on -the other hand has 4GB memory and has 4 NUMA nodes which are pinned 1:1 -to host nodes. - -Signed-off-by: Michal Privoznik -(cherry picked from commit fa21f3d927b29991741e2d7a8ebc2a920778ecba) -Signed-off-by: Michal Privoznik -Signed-off-by: Jiri Denemark ---- - examples/nodestats.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 87 insertions(+) - create mode 100755 examples/nodestats.py - -diff --git a/examples/nodestats.py b/examples/nodestats.py -new file mode 100755 -index 0000000..c01dead ---- /dev/null -+++ b/examples/nodestats.py -@@ -0,0 +1,87 @@ -+#!/usr/bin/env python -+# Print some host NUMA node statistics -+# -+# Authors: -+# Michal Privoznik -+ -+import libvirt -+import sys -+from xml.dom import minidom -+import libxml2 -+ -+def xpath_eval(ctxt, path): -+ res = ctxt.xpathEval(path) -+ if res is None or len(res) == 0: -+ value = None -+ else: -+ value = res[0].content -+ return value -+ -+try: -+ conn = libvirt.openReadOnly(None) -+except libvirt.libvirtError: -+ print("Failed to connect to the hypervisor") -+ sys.exit(1) -+ -+try: -+ capsXML = conn.getCapabilities() -+except libvirt.libvirtError: -+ print("Failed to request capabilities") -+ sys.exit(1) -+ -+caps = minidom.parseString(capsXML) -+cells = caps.getElementsByTagName("cells")[0] -+ -+nodesIDs = [ int(proc.getAttribute("id")) -+ for proc in cells.getElementsByTagName("cell") ] -+ -+nodesMem = [ conn.getMemoryStats(int(proc)) -+ for proc in nodesIDs] -+ -+doms = conn.listAllDomains(libvirt.VIR_CONNECT_LIST_DOMAINS_ACTIVE) -+ -+domsStrict = [ proc -+ for proc in doms -+ if proc.numaParameters()["numa_mode"] == libvirt.VIR_DOMAIN_NUMATUNE_MEM_STRICT ] -+ -+domsStrictCfg = {} -+for dom in domsStrict: -+ xmlStr = dom.XMLDesc() -+ doc = libxml2.parseDoc(xmlStr) -+ ctxt = doc.xpathNewContext() -+ -+ domsStrictCfg[dom] = {} -+ -+ pin = ctxt.xpathEval("string(/domain/numatune/memory/@nodeset)") -+ memsize = ctxt.xpathEval("string(/domain/memory)") -+ domsStrictCfg[dom]["memory"] = {"size": int(memsize), "pin": pin} -+ -+ for memnode in ctxt.xpathEval("/domain/numatune/memnode"): -+ ctxt.setContextNode(memnode) -+ cellid = xpath_eval(ctxt, "@cellid") -+ nodeset = xpath_eval(ctxt, "@nodeset") -+ -+ nodesize = xpath_eval(ctxt, "/domain/cpu/numa/cell[@id='%s']/@memory" % cellid) -+ domsStrictCfg[dom][cellid] = {"size": int(nodesize), "pin": nodeset} -+ -+ -+print("NUMA stats") -+print("NUMA nodes:\t" + "\t".join(str(node) for node in nodesIDs)) -+print("MemTotal:\t" + "\t".join(str(i.get("total") // 1024) for i in nodesMem)) -+print("MemFree:\t" + "\t".join(str(i.get("free") // 1024) for i in nodesMem)) -+ -+for dom, v in domsStrictCfg.items(): -+ print("Domain '%s':\t" % dom.name()) -+ -+ toPrint = "\tOverall memory: %d MiB" % (v["memory"]["size"] // 1024) -+ if v["memory"]["pin"] is not None and v["memory"]["pin"] is not "": -+ toPrint = toPrint + " nodes %s" % v["memory"]["pin"] -+ print(toPrint) -+ -+ for k, node in sorted(v.items()): -+ if k is "memory": -+ continue -+ toPrint = "\tNode %s:\t%d MiB" % (k, node["size"] // 1024) -+ if node["pin"] is not None and node["pin"] is not "": -+ toPrint = toPrint + " nodes %s" % node["pin"] -+ print(toPrint) --- -2.5.0 - diff --git a/SOURCES/libvirt-python-iothread-Fix-crash-if-virDomainGetIOThreadInfo-returns-error.patch b/SOURCES/libvirt-python-iothread-Fix-crash-if-virDomainGetIOThreadInfo-returns-error.patch deleted file mode 100644 index d9a68d0..0000000 --- a/SOURCES/libvirt-python-iothread-Fix-crash-if-virDomainGetIOThreadInfo-returns-error.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 6971993051ba16c374d7385e7ab65fa7f3b57e0c Mon Sep 17 00:00:00 2001 -Message-Id: <6971993051ba16c374d7385e7ab65fa7f3b57e0c@dist-git> -From: Peter Krempa -Date: Thu, 30 Jul 2015 10:04:02 +0200 -Subject: [PATCH] iothread: Fix crash if virDomainGetIOThreadInfo returns error - -The cleanup portion of libvirt_virDomainGetIOThreadInfo would try to -clean the returned structures but the count of iothreads was set to -1. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248295 -(cherry picked from commit 0a59630a341f73f716e635a8635c053861695cf1) - -Signed-off-by: Jiri Denemark ---- - libvirt-override.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/libvirt-override.c b/libvirt-override.c -index 45c8afc..2398228 100644 ---- a/libvirt-override.c -+++ b/libvirt-override.c -@@ -2104,8 +2104,10 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self ATTRIBUTE_UNUSED, - py_iothrinfo = NULL; - - cleanup: -- for (i = 0; i < niothreads; i++) -- virDomainIOThreadInfoFree(iothrinfo[i]); -+ if (niothreads > 0) { -+ for (i = 0; i < niothreads; i++) -+ virDomainIOThreadInfoFree(iothrinfo[i]); -+ } - VIR_FREE(iothrinfo); - Py_XDECREF(py_iothrinfo); - return py_retval; --- -2.5.0 - diff --git a/SPECS/libvirt-python.spec b/SPECS/libvirt-python.spec index bbe7b44..c30f7d7 100644 --- a/SPECS/libvirt-python.spec +++ b/SPECS/libvirt-python.spec @@ -6,19 +6,17 @@ Summary: The libvirt virtualization API python2 binding Name: libvirt-python -Version: 1.2.17 +Version: 2.0.0 Release: 2%{?dist}%{?extra_release} Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz -Patch1: libvirt-python-examples-Introduce-nodestats-example.patch -Patch2: libvirt-python-iothread-Fix-crash-if-virDomainGetIOThreadInfo-returns-error.patch -Patch3: libvirt-python-Check-return-value-of-PyList_Append.patch +Patch1: libvirt-python-Fix-crash-in-storage-pool-refresh-callback.patch Url: http://libvirt.org License: LGPLv2+ Group: Development/Libraries BuildRequires: git -BuildRequires: libvirt-devel >= 1.2.17-3%{?dist} +BuildRequires: libvirt-devel >= 2.0.0-3%{?dist} BuildRequires: python-devel BuildRequires: python-nose BuildRequires: python-lxml @@ -55,6 +53,11 @@ of recent versions of Linux (and other OSes). %prep %setup -q +# Unset execute bit for example scripts; it can introduce spurious +# RPM dependencies, like /usr/bin/python which can pull in python2 +# for the -python3 package +find examples -type f -exec chmod 0644 \{\} \; + # Patches have to be stored in a temporary file because RPM has # a limit on the length of the result of any macro expansion; # if the string is longer, it's silently cropped @@ -132,6 +135,30 @@ rm -f %{buildroot}%{_libdir}/python*/site-packages/*egg-info %endif %changelog +* Mon Aug 1 2016 Jiri Denemark - 2.0.0-2 +- Fix crash in storage pool refresh callback (rhbz#1354271) + +* Fri Jul 1 2016 Jiri Denemark - 2.0.0-1 +- Rebased to libvirt-python-2.0.0 (rhbz#1286680) + +* Wed Jun 8 2016 Jiri Denemark - 1.3.5-1 +- Rebased to libvirt-python-1.3.5 (rhbz#1286680) + +* Tue May 3 2016 Jiri Denemark - 1.3.4-1 +- Rebased to libvirt-python-1.3.4 (rhbz#1286680) +- The rebase also fixes the following bugs: + rhbz#1286680, rhbz#1326839 + +* Wed Apr 6 2016 Jiri Denemark - 1.3.3-1 +- Rebased to libvirt-python-1.3.3 (rhbz#1286680) +- The rebase also fixes the following bugs: + rhbz# + +* Wed Mar 2 2016 Jiri Denemark - 1.3.2-1 +- Rebased to libvirt-python-1.3.2 (rhbz#1286680) +- The rebase also fixes the following bugs: + rhbz#1311058 + * Tue Aug 4 2015 Jiri Denemark - 1.2.17-2 - examples: Introduce nodestats example (rhbz#1051494) - iothread: Fix crash if virDomainGetIOThreadInfo returns error (rhbz#1248295)