[libvirt] [libvirt-python 00/18] Remaining bits for libvirt-python split

As a follow up to Daniel Berrange's libvirt-python creation patchset [1], I've added the following to allow the repo to build against multiple versions of libvirt. I've successfully built it against libvirt 0.10.2.8 from Fedora 18 but will test further against some other distros as well. If you just want something clone-able you can get the full repo from: git clone https://github.com/cardoe/libvirt-python.git And since its github you can see the web page at: https://github.com/cardoe/libvirt-python The patchset is still a work in progress for the following: * commit message clean up * tests against additional versions I'm really curious to see how far back people want to support things. [1] http://www.redhat.com/archives/libvir-list/2013-November/msg00416.html Doug Goldstein (18): Bump version number to current 1.1.5 Add missing URL attribute to setup.py Add maintainer/maintainer_email to the libvirt list Add libvirt version check macro from libvirt upstream Break generator.py to be called per module Create array of modules to be built Don't build LXC module when building less than 1.0.2 virTypedParams* API appeared in 1.0.2 virNodeGetCPUMap API not added until 1.0.0 virDomainMigrate3 and virDomainMigrateToURI3 not added until 1.1.0 Wrap new domain create APIs added in 1.1.1 virConnectGetCPUModelNames() did not appear until 1.1.3 virDomainGetJobStats() was added in 1.0.3 virDomainMigrateGetCompressionCache() was added in 1.0.3 VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK added in 1.0.0 VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED was added in 1.1.1 Add missing break to switch-case block Bring some virTypedParams* API from libvirt generator.py | 24 ++++++++++++------------ libvirt-override.c | 40 ++++++++++++++++++++++++++++++++++++++-- libvirt-utils.c | 43 +++++++++++++++++++++++++++++++++++++++++++ libvirt-utils.h | 16 ++++++++++++++++ setup.py | 53 +++++++++++++++++++++++++++++++++++++++++------------ 5 files changed, 150 insertions(+), 26 deletions(-) -- 1.8.3.2

--- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a790754..2cb1a38 100644 --- a/setup.py +++ b/setup.py @@ -246,7 +246,7 @@ class my_clean(clean): remove_tree("build") setup(name = 'libvirt-python', - version = '1.1.2', + version = '1.1.5', description = 'The libvirt virtualization API', ext_modules = [module, modulelxc, moduleqemu], py_modules = ["libvirt", "libvirt_qemu", "libvirt_lxc"], -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py index a790754..2cb1a38 100644 --- a/setup.py +++ b/setup.py @@ -246,7 +246,7 @@ class my_clean(clean): remove_tree("build")
setup(name = 'libvirt-python', - version = '1.1.2', + version = '1.1.5',
I mentioned other instances of 1.1.2 in Dan's tree; probably worth squashing all such patches into one and recreating the new libvirt-python repo with a slightly cleaner history. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, Nov 19, 2013 at 07:58:20AM -0700, Eric Blake wrote:
On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.py b/setup.py index a790754..2cb1a38 100644 --- a/setup.py +++ b/setup.py @@ -246,7 +246,7 @@ class my_clean(clean): remove_tree("build")
setup(name = 'libvirt-python', - version = '1.1.2', + version = '1.1.5',
I mentioned other instances of 1.1.2 in Dan's tree; probably worth squashing all such patches into one and recreating the new libvirt-python repo with a slightly cleaner history.
Yes, we'll squash some of Doug's patches into mine to clear up history where appropriate. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

--- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 2cb1a38..0868528 100644 --- a/setup.py +++ b/setup.py @@ -247,6 +247,7 @@ class my_clean(clean): setup(name = 'libvirt-python', version = '1.1.5', + url = 'http://www.libvirt.org', description = 'The libvirt virtualization API', ext_modules = [module, modulelxc, moduleqemu], py_modules = ["libvirt", "libvirt_qemu", "libvirt_lxc"], -- 1.8.3.2

Add the libvirt mailing list as the maintainer of the libvirt-python component. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 0868528..14cf94e 100644 --- a/setup.py +++ b/setup.py @@ -248,6 +248,8 @@ class my_clean(clean): setup(name = 'libvirt-python', version = '1.1.5', url = 'http://www.libvirt.org', + maintainer = 'Libvirt Maintainers', + maintainer_email = 'libvir-list@redhat.com', description = 'The libvirt virtualization API', ext_modules = [module, modulelxc, moduleqemu], py_modules = ["libvirt", "libvirt_qemu", "libvirt_lxc"], -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
Add the libvirt mailing list as the maintainer of the libvirt-python component. --- setup.py | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/setup.py b/setup.py index 0868528..14cf94e 100644 --- a/setup.py +++ b/setup.py @@ -248,6 +248,8 @@ class my_clean(clean): setup(name = 'libvirt-python', version = '1.1.5', url = 'http://www.libvirt.org', + maintainer = 'Libvirt Maintainers', + maintainer_email = 'libvir-list@redhat.com',
Probably worth squashing with 2/18. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Add LIBVIRT_CHECK_VERSION from libvirt upstream so that we can check the version of the library we are compiling against and support a range of libvirt versions. The macro was added to libvirt in 1.1.5 so we must provide it if its not defined. --- libvirt-utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libvirt-utils.h b/libvirt-utils.h index 1b26413..6f920c6 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -22,6 +22,16 @@ #ifndef __LIBVIRT_UTILS_H__ # define __LIBVIRT_UTILS_H__ +/** + * libvirt.h provides this as of version 1.1.5, but we want to be able + * to support older versions of libvirt so copy and paste the macro from + * libvirt.h + */ +#ifndef LIBVIR_CHECK_VERSION +# define LIBVIR_CHECK_VERSION(major, minor, micro) \ + ((major) * 1000000 + (minor) * 1000 + (micro) <= LIBVIR_VERSION_NUMBER) +#endif + #define STREQ(a,b) (strcmp(a,b) == 0) #ifndef MIN -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
Add LIBVIRT_CHECK_VERSION from libvirt upstream so that we can check the
s/LIBVIRT_/LIBVIR_/
version of the library we are compiling against and support a range of libvirt versions. The macro was added to libvirt in 1.1.5 so we must provide it if its not defined. --- libvirt-utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Since we don't always want to build all the modules and there might be more modules added in the future but we want to retain backwards compatibility with older libvirts, change generator.py to be called once per module instead of with all modules at once. --- generator.py | 24 ++++++++++++------------ setup.py | 4 +++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/generator.py b/generator.py index 83efe32..1661fbf 100755 --- a/generator.py +++ b/generator.py @@ -17,11 +17,6 @@ import re quiet=True -coreapifile = sys.argv[1] -lxcapifile = sys.argv[2] -qemuapifile = sys.argv[3] - - ####################################################################### # # That part if purely the API acquisition phase from the @@ -1945,13 +1940,18 @@ def lxcBuildWrappers(module): quiet = 0 if not os.path.exists("build"): os.mkdir("build") -if buildStubs("libvirt", coreapifile) < 0: - sys.exit(1) -if buildStubs("libvirt-lxc", lxcapifile) < 0: + +if buildStubs(sys.argv[1], sys.argv[2]) < 0: sys.exit(1) -if buildStubs("libvirt-qemu", qemuapifile) < 0: + +if sys.argv[1] == "libvirt": + buildWrappers(sys.argv[1]) +elif sys.argv[1] == "libvirt-lxc": + lxcBuildWrappers(sys.argv[1]) +elif sys.argv[1] == "libvirt-qemu": + qemuBuildWrappers(sys.argv[1]) +else: + print "ERROR: unknown module %s" % sys.argv[1] sys.exit(1) -buildWrappers("libvirt") -lxcBuildWrappers("libvirt-lxc") -qemuBuildWrappers("libvirt-qemu") + sys.exit(0) diff --git a/setup.py b/setup.py index 14cf94e..bab7f03 100644 --- a/setup.py +++ b/setup.py @@ -95,7 +95,9 @@ class my_build(build): def run(self): apis = self.get_api_xml_files() - self.spawn(["./generator.py", apis[0], apis[1], apis[2]]) + self.spawn(["./generator.py", "libvirt", apis[0]]) + self.spawn(["./generator.py", "libvirt-qemu", apis[1]]) + self.spawn(["./generator.py", "libvirt-lxc", apis[2]]) build.run(self) -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
Since we don't always want to build all the modules and there might be
s/modules/modules,/
more modules added in the future but we want to retain backwards compatibility with older libvirts, change generator.py to be called once per module instead of with all modules at once. --- generator.py | 24 ++++++++++++------------ setup.py | 4 +++- 2 files changed, 15 insertions(+), 13 deletions(-)
My python is relatively weak, but I was able to follow this patch based on your commit message. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Create an array of modules to be built to allow for flexibility to enable or disable some modules in the future and allow for additional modules to be added easily --- setup.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index bab7f03..4d61f59 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,9 @@ def get_pkgconfig_data(args, mod, required=True): ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False) cflags = get_pkgconfig_data(["--cflags"], "libvirt", False) +c_modules = [] +py_modules = [] + module = Extension('libvirtmod', sources = ['libvirt-override.c', 'build/libvirt.c', 'typewrappers.c'], libraries = [ "virt" ], @@ -56,6 +59,8 @@ if cflags != "": if ldflags != "": module.extra_link_args.append(ldflags) +c_modules.append(module) +py_modules.append("libvirt") moduleqemu = Extension('libvirtmod_qemu', sources = ['libvirt-qemu-override.c', 'build/libvirt-qemu.c', 'typewrappers.c'], @@ -66,6 +71,9 @@ if cflags != "": if ldflags != "": moduleqemu.extra_link_args.append(ldflags) +c_modules.append(moduleqemu) +py_modules.append("libvirt_qemu") + modulelxc = Extension('libvirtmod_lxc', sources = ['libvirt-lxc-override.c', 'build/libvirt-lxc.c', 'typewrappers.c'], libraries = [ "virt-lxc" ], @@ -75,6 +83,10 @@ if cflags != "": if ldflags != "": modulelxc.extra_link_args.append(ldflags) +c_modules.append(modulelxc) +py_modules.append("libvirt_lxc") + + class my_build(build): def get_api_xml_files(self): @@ -253,8 +265,8 @@ setup(name = 'libvirt-python', maintainer = 'Libvirt Maintainers', maintainer_email = 'libvir-list@redhat.com', description = 'The libvirt virtualization API', - ext_modules = [module, modulelxc, moduleqemu], - py_modules = ["libvirt", "libvirt_qemu", "libvirt_lxc"], + ext_modules = c_modules, + py_modules = py_modules, package_dir = { '': 'build' }, -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
Create an array of modules to be built to allow for flexibility to enable or disable some modules in the future and allow for additional modules to be added easily --- setup.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
Again, weak review, but makes sense. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

The functions that the LXC module wraps did not appear until 1.0.2 so we can't build the module unless we're building against 1.0.2 or newer. --- setup.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 4d61f59..f8e74ba 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ from distutils.command.sdist import sdist from distutils.dir_util import remove_tree from distutils.util import get_platform from distutils.spawn import spawn +from distutils.errors import DistutilsExecError import distutils import sys @@ -17,6 +18,7 @@ import re import time MIN_LIBVIRT = "0.10.2" +MIN_LIBVIRT_LXC = "1.0.2" pkgcfg = distutils.spawn.find_executable("pkg-config") @@ -28,6 +30,14 @@ spawn([pkgcfg, "--atleast-version=%s" % MIN_LIBVIRT, "libvirt"]) +have_libvirt_lxc=True +try: + spawn([pkgcfg, + "--atleast-version=%s" % MIN_LIBVIRT_LXC, + "libvirt"]) +except DistutilsExecError,e: + have_libvirt_lxc=False + def get_pkgconfig_data(args, mod, required=True): """Run pkg-config to and return content associated with it""" f = os.popen("%s %s %s" % (pkgcfg, " ".join(args), mod)) @@ -74,17 +84,18 @@ if ldflags != "": c_modules.append(moduleqemu) py_modules.append("libvirt_qemu") -modulelxc = Extension('libvirtmod_lxc', - sources = ['libvirt-lxc-override.c', 'build/libvirt-lxc.c', 'typewrappers.c'], - libraries = [ "virt-lxc" ], - include_dirs = [ "." ]) -if cflags != "": - modulelxc.extra_compile_args.append(cflags) -if ldflags != "": - modulelxc.extra_link_args.append(ldflags) +if have_libvirt_lxc: + modulelxc = Extension('libvirtmod_lxc', + sources = ['libvirt-lxc-override.c', 'build/libvirt-lxc.c', 'typewrappers.c'], + libraries = [ "virt-lxc" ], + include_dirs = [ "." ]) + if cflags != "": + modulelxc.extra_compile_args.append(cflags) + if ldflags != "": + modulelxc.extra_link_args.append(ldflags) -c_modules.append(modulelxc) -py_modules.append("libvirt_lxc") + c_modules.append(modulelxc) + py_modules.append("libvirt_lxc") class my_build(build): @@ -109,7 +120,8 @@ class my_build(build): self.spawn(["./generator.py", "libvirt", apis[0]]) self.spawn(["./generator.py", "libvirt-qemu", apis[1]]) - self.spawn(["./generator.py", "libvirt-lxc", apis[2]]) + if have_libvirt_lxc: + self.spawn(["./generator.py", "libvirt-lxc", apis[2]]) build.run(self) -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
The functions that the LXC module wraps did not appear until 1.0.2 so we can't build the module unless we're building against 1.0.2 or newer.
Aha - now the previous two make more sense :)
--- setup.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)
Again, my python is weak, but this matched the commit message. ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

--- libvirt-override.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libvirt-override.c b/libvirt-override.c index 816ef01..f7c37a2 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -254,7 +254,7 @@ cleanup: return NULL; } - +#if LIBVIR_CHECK_VERSION(1,0,2) typedef struct { const char *name; int type; @@ -406,6 +406,7 @@ cleanup: virTypedParamsFree(params, n); return ret; } +#endif /* LIBVIR_CHECK_VERSION(1,0,2) */ /* -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

--- libvirt-override.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libvirt-override.c b/libvirt-override.c index f7c37a2..6964ee4 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -420,12 +420,14 @@ cleanup: */ static int getPyNodeCPUCount(virConnectPtr conn) { - int i_retval; + int i_retval = -1; virNodeInfo nodeinfo; +#if LIBVIR_CHECK_VERSION(1,0,0) LIBVIRT_BEGIN_ALLOW_THREADS; i_retval = virNodeGetCPUMap(conn, NULL, NULL, 0); LIBVIRT_END_ALLOW_THREADS; +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */ if (i_retval < 0) { /* fallback: use nodeinfo */ @@ -7054,6 +7056,7 @@ cleanup: return ret; } +#if LIBVIR_CHECK_VERSION(1,0,0) static PyObject * libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -7122,6 +7125,7 @@ error: ret = NULL; goto cleanup; } +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */ static PyObject * -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
ACK.
+#if LIBVIR_CHECK_VERSION(1,0,0)
Style-wise, I would have written LIBVIR_CHECK_VERSION(1, 0, 0), but I'm not sure the whitespace difference matters.
LIBVIRT_BEGIN_ALLOW_THREADS; i_retval = virNodeGetCPUMap(conn, NULL, NULL, 0); LIBVIRT_END_ALLOW_THREADS; +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */
if (i_retval < 0) { /* fallback: use nodeinfo */
Works because of the fallback code (we have to call at least one libvirt function before returning error so that the libvirt error api has something to report). -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, Nov 19, 2013 at 9:19 AM, Eric Blake <eblake@redhat.com> wrote:
On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
ACK.
+#if LIBVIR_CHECK_VERSION(1,0,0)
Style-wise, I would have written LIBVIR_CHECK_VERSION(1, 0, 0), but I'm not sure the whitespace difference matters.
I'll make that change for the whole series.
LIBVIRT_BEGIN_ALLOW_THREADS; i_retval = virNodeGetCPUMap(conn, NULL, NULL, 0); LIBVIRT_END_ALLOW_THREADS; +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */
if (i_retval < 0) { /* fallback: use nodeinfo */
Works because of the fallback code (we have to call at least one libvirt function before returning error so that the libvirt error api has something to report).
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
-- Doug Goldstein

The functions virDomainMigrate3 and virDomainMigrateToURI3 were not added to libvirt until v1.1.0. --- libvirt-override.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 6964ee4..b20af57 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6799,6 +6799,7 @@ libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *a return py_retval; } +#if LIBVIR_CHECK_VERSION(1,1,0) static PyObject * libvirt_virDomainMigrate3(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -6860,6 +6861,7 @@ libvirt_virDomainMigrateToURI3(PyObject *self ATTRIBUTE_UNUSED, virTypedParamsFree(params, nparams); return libvirt_intWrap(ret); } +#endif /* LIBVIR_CHECK_VERSION(1,1,0) */ static PyObject * libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED, @@ -7337,14 +7339,18 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL}, {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache, METH_VARARGS, NULL}, {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,1,0) {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3, METH_VARARGS, NULL}, {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,1,0) */ {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL}, {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL}, {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL}, {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL}, {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,0,0) {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */ {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles, METH_VARARGS, NULL}, {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
The functions virDomainMigrate3 and virDomainMigrateToURI3 were not added to libvirt until v1.1.0.
Is there a method to how you picked which functions to work around? It would be nicer to rearrange this series from newest to oldest (1.1.3 [virConnectGetCPUModelNames], 1.1.1 [virDomainCreateWithFiles, virDomainCreateXMLWithFiles, virDomainSetMemoryStatsPeriod], 1.1.0 ...) rather than ad hoc. As to this patch:
+#if LIBVIR_CHECK_VERSION(1,1,0)
Still the style question.
@@ -7337,14 +7339,18 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL}, {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache, METH_VARARGS, NULL}, {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,1,0) {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3, METH_VARARGS, NULL}, {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,1,0) */
Looks reasonable.
{(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL}, {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL}, {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL}, {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL}, {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,0,0) {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */
Oops, looks like this hunk belongs in 9/18. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Tue, Nov 19, 2013 at 9:35 AM, Eric Blake <eblake@redhat.com> wrote:
On 11/18/2013 03:44 PM, Doug Goldstein wrote:
The functions virDomainMigrate3 and virDomainMigrateToURI3 were not added to libvirt until v1.1.0.
Is there a method to how you picked which functions to work around? It would be nicer to rearrange this series from newest to oldest (1.1.3 [virConnectGetCPUModelNames], 1.1.1 [virDomainCreateWithFiles, virDomainCreateXMLWithFiles, virDomainSetMemoryStatsPeriod], 1.1.0 ...) rather than ad hoc.
There was no method to my madness. It was actually APIs that I remembered off the top of my head and how to quickly find when they went in until I started using git describe --contains for later commits. You're right though, I'll reorder the whole series.
As to this patch:
+#if LIBVIR_CHECK_VERSION(1,1,0)
Still the style question.
@@ -7337,14 +7339,18 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL}, {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache, METH_VARARGS, NULL}, {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,1,0) {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3, METH_VARARGS, NULL}, {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,1,0) */
Looks reasonable.
{(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL}, {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL}, {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL}, {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL}, {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,0,0) {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */
Oops, looks like this hunk belongs in 9/18.
Whoops. Thanks. -- Doug Goldstein

On Tue, Nov 19, 2013 at 09:48:57AM -0600, Doug Goldstein wrote:
On Tue, Nov 19, 2013 at 9:35 AM, Eric Blake <eblake@redhat.com> wrote:
On 11/18/2013 03:44 PM, Doug Goldstein wrote:
The functions virDomainMigrate3 and virDomainMigrateToURI3 were not added to libvirt until v1.1.0.
Is there a method to how you picked which functions to work around? It would be nicer to rearrange this series from newest to oldest (1.1.3 [virConnectGetCPUModelNames], 1.1.1 [virDomainCreateWithFiles, virDomainCreateXMLWithFiles, virDomainSetMemoryStatsPeriod], 1.1.0 ...) rather than ad hoc.
There was no method to my madness. It was actually APIs that I remembered off the top of my head and how to quickly find when they went in until I started using git describe --contains for later commits. You're right though, I'll reorder the whole series.
Easiest way is to actually just look at src/libvirt_public.syms where explicit versions are all recorded. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

virDomainCreateXMLWithFiles() and virDomainCreateWithFiles() were not added to libvirt until 1.1.1 --- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index b20af57..fa8b94c 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -7130,6 +7130,7 @@ error: #endif /* LIBVIR_CHECK_VERSION(1,0,0) */ +#if LIBVIR_CHECK_VERSION(1,1,1) static PyObject * libvirt_virDomainCreateWithFiles(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { PyObject *py_retval = NULL; @@ -7219,6 +7220,7 @@ cleanup: VIR_FREE(files); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(1,1,1) */ /************************************************************************ @@ -7351,8 +7353,10 @@ static PyMethodDef libvirtMethods[] = { #if LIBVIR_CHECK_VERSION(1,0,0) {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap, METH_VARARGS, NULL}, #endif /* LIBVIR_CHECK_VERSION(1,0,0) */ +#if LIBVIR_CHECK_VERSION(1,1,1) {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles, METH_VARARGS, NULL}, {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,1,1) */ {NULL, NULL, 0, NULL} }; -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
virDomainCreateXMLWithFiles() and virDomainCreateWithFiles() were not added to libvirt until 1.1.1 --- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index fa8b94c..55c6089 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2275,6 +2275,7 @@ libvirt_virConnectGetVersion(PyObject *self ATTRIBUTE_UNUSED, return PyInt_FromLong(hvVersion); } +#if LIBVIR_CHECK_VERSION(1,1,3) PyObject * libvirt_virConnectGetCPUModelNames(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -2326,6 +2327,7 @@ error: rv = VIR_PY_INT_FAIL; goto done; } +#endif /* LIBVIR_CHECK_VERSION(1,1,3) */ static PyObject * libvirt_virConnectGetLibVersion(PyObject *self ATTRIBUTE_UNUSED, @@ -7232,7 +7234,9 @@ static PyMethodDef libvirtMethods[] = { #include "build/libvirt-export.c" {(char *) "virGetVersion", libvirt_virGetVersion, METH_VARARGS, NULL}, {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,1,3) {(char *) "virConnectGetCPUModelNames", libvirt_virConnectGetCPUModelNames, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,1,3) */ {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion, METH_VARARGS, NULL}, {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth, METH_VARARGS, NULL}, {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL}, -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 55c6089..b3de8fc 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -4536,6 +4536,7 @@ libvirt_virDomainGetJobInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { return py_retval; } +#if LIBVIR_CHECK_VERSION(1,0,3) static PyObject * libvirt_virDomainGetJobStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { @@ -4576,6 +4577,7 @@ cleanup: else return VIR_PY_NONE; } +#endif /* LIBVIR_CHECK_VERSION(1,0,3) */ static PyObject * libvirt_virDomainGetBlockJobInfo(PyObject *self ATTRIBUTE_UNUSED, @@ -7333,7 +7335,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces, METH_VARARGS, NULL}, {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU, METH_VARARGS, NULL}, {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,0,3) {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,0,3) */ {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL}, {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots, METH_VARARGS, NULL}, {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames, METH_VARARGS, NULL}, -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index b3de8fc..e7df899 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6751,6 +6751,7 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +#if LIBVIR_CHECK_VERSION(1,0,3) static PyObject * libvirt_virDomainMigrateGetCompressionCache(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -6777,6 +6778,7 @@ libvirt_virDomainMigrateGetCompressionCache(PyObject *self ATTRIBUTE_UNUSED, return libvirt_ulonglongWrap(cacheSize); } +#endif /* LIBVIR_CHECK_VERSION(1,0,3) */ static PyObject * libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { @@ -7347,7 +7349,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune, METH_VARARGS, NULL}, {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune, METH_VARARGS, NULL}, {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(1,0,3) {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(1,0,3) */ {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL}, #if LIBVIR_CHECK_VERSION(1,1,0) {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3, METH_VARARGS, NULL}, -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index e7df899..3125d27 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6233,6 +6233,7 @@ libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_ return ret; } +#if LIBVIR_CHECK_VERSION(1,0,0) static int libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom, @@ -6279,6 +6280,7 @@ libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_ LIBVIRT_RELEASE_THREAD_STATE; return ret; } +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */ static int libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED, @@ -6397,9 +6399,11 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback); break; +#if LIBVIR_CHECK_VERSION(1,0,0) case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback); break; +#endif /* LIBVIR_CHECK_VERSION(1,0,0) */ case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback); -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 3125d27..c3ff1e0 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6282,6 +6282,7 @@ libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_ } #endif /* LIBVIR_CHECK_VERSION(1,0,0) */ +#if LIBVIR_CHECK_VERSION(1,1,1) static int libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom, @@ -6326,6 +6327,7 @@ libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_ LIBVIRT_RELEASE_THREAD_STATE; return ret; } +#endif /* LIBVIR_CHECK_VERSION(1,1,1) */ static PyObject * libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, @@ -6404,8 +6406,10 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback); break; #endif /* LIBVIR_CHECK_VERSION(1,0,0) */ +#if LIBVIR_CHECK_VERSION(1,1,1) case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback); +#endif /* LIBVIR_CHECK_VERSION(1,1,1) */ case VIR_DOMAIN_EVENT_ID_LAST: break; -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
--- libvirt-override.c | 4 ++++ 1 file changed, 4 insertions(+)
ACK.
@@ -6404,8 +6406,10 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback); break; #endif /* LIBVIR_CHECK_VERSION(1,0,0) */ +#if LIBVIR_CHECK_VERSION(1,1,1) case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback); +#endif /* LIBVIR_CHECK_VERSION(1,1,1) */
case VIR_DOMAIN_EVENT_ID_LAST:
Hmm. VIR_DOMAIN_EVENT_ID_LAST has a floating value - the value that it has in the libvirt.h we compile against may not match the value that it has in the remote libvirtd we are connecting to. More specifically, if we are compiled against 1.0.0 but talking to a 1.1.1 server, the server can return an event id that we think is VIR_DOMAIN_EVENT_ID_LAST; what's more, an 0.10.2 client talking to a 1.1.1 server will see an id that is larger than VIR_DOMAIN_EVENT_ID_LAST, at which point it just skips the entire switch statement. But in the context you didn't show, we correctly treat all unknown callback ids (whether we think it is VIR_DOMIAN_EVENT_ID_LAST or even something larger), so this looks correct to me. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

The case label for VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED did not have its own break statement but relied on falling through which we probably don't want. --- libvirt-override.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libvirt-override.c b/libvirt-override.c index c3ff1e0..03f6253 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6409,6 +6409,7 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, #if LIBVIR_CHECK_VERSION(1,1,1) case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback); + break; #endif /* LIBVIR_CHECK_VERSION(1,1,1) */ case VIR_DOMAIN_EVENT_ID_LAST: -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
The case label for VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED did not have its own break statement but relied on falling through which we probably don't want. --- libvirt-override.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/libvirt-override.c b/libvirt-override.c index c3ff1e0..03f6253 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6409,6 +6409,7 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, #if LIBVIR_CHECK_VERSION(1,1,1) case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback); + break; #endif /* LIBVIR_CHECK_VERSION(1,1,1) */
ACK; we may want to push this one upstream first as trivial before doing the libvirt-python split. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

virTypedParamsClear() and virTypedParamsFree() were introduced in libvirt 1.0.2. In an effort to keep the code clean bring these two functions to libvirt-python if we're building against a version of libvirt that's older than 1.0.2 --- libvirt-utils.c | 43 +++++++++++++++++++++++++++++++++++++++++++ libvirt-utils.h | 6 ++++++ 2 files changed, 49 insertions(+) diff --git a/libvirt-utils.c b/libvirt-utils.c index 6866bf1..90d4719 100644 --- a/libvirt-utils.c +++ b/libvirt-utils.c @@ -134,3 +134,46 @@ int virFileClose(int *fdptr) return rc; } + +/** + * virTypedParamsClear: + * @params: the array of the typed parameters + * @nparams: number of parameters in the @params array + * + * Frees all memory used by string parameters. The memory occupied by @params + * is not free; use virTypedParamsFree if you want it to be freed too. + * + * Returns nothing. + */ +void +virTypedParamsClear(virTypedParameterPtr params, + int nparams) +{ + size_t i; + + if (!params) + return; + + for (i = 0; i < nparams; i++) { + if (params[i].type == VIR_TYPED_PARAM_STRING) + VIR_FREE(params[i].value.s); + } +} + +/** + * virTypedParamsFree: + * @params: the array of the typed parameters + * @nparams: number of parameters in the @params array + * + * Frees all memory used by string parameters and the memory occuiped by + * @params. + * + * Returns nothing. + */ +void +virTypedParamsFree(virTypedParameterPtr params, + int nparams) +{ + virTypedParamsClear(params, nparams); + VIR_FREE(params); +} diff --git a/libvirt-utils.h b/libvirt-utils.h index 6f920c6..70f6690 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -200,4 +200,10 @@ int virFileClose(int *fdptr) # define VIR_FORCE_CLOSE(FD) \ ignore_value(virFileClose(&(FD))) +# if ! LIBVIR_CHECK_VERSION(1,0,2) +void virTypedParamsClear(virTypedParameterPtr params, int nparams); + +void virTypedParamsFree(virTypedParameterPtr params, int nparams); +# endif /* ! LIBVIR_CHECK_VERSION(1,0,2) */ + #endif /* __LIBVIRT_UTILS_H__ */ -- 1.8.3.2

On 11/18/2013 03:44 PM, Doug Goldstein wrote:
virTypedParamsClear() and virTypedParamsFree() were introduced in libvirt 1.0.2. In an effort to keep the code clean bring these two functions to libvirt-python if we're building against a version of libvirt that's older than 1.0.2 --- libvirt-utils.c | 43 +++++++++++++++++++++++++++++++++++++++++++ libvirt-utils.h | 6 ++++++ 2 files changed, 49 insertions(+)
+ * Returns nothing. + */ +void +virTypedParamsClear(virTypedParameterPtr params, + int nparams)
Umm, where's the LIBVIR_CHECK_VERSION() to ensure that we don't compile this when using a new enough libvirt.so?
+ * + * Frees all memory used by string parameters and the memory occuiped by
s/occuiped/occupied/ (upstream was correct, so not sure how you made that mistake)
+# if ! LIBVIR_CHECK_VERSION(1,0,2) +void virTypedParamsClear(virTypedParameterPtr params, int nparams); + +void virTypedParamsFree(virTypedParameterPtr params, int nparams); +# endif /* ! LIBVIR_CHECK_VERSION(1,0,2) */
This part is okay, but the .c side also needs guards. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Doug Goldstein
-
Eric Blake