Re: [libvirt] [PATCH] libxl: libxl_domain_create_restore has an extra argument
On 4/5/16 9:20 AM, Wei Liu wrote: > In the latest libxenlight code, libxl_domain_create_restore accepts a > new argument. Update libvirt's libxl driver for that. Use the macro > provided by libxenlight to detect which version should be used. > > The new parameter (send_back_fd) is set to -1 because libvirt provides > no such fd. > > Signed-off-by: Wei Liu <wei.l...@citrix.com> > --- > Build test with Xen 4.6.1 (old API) and Xen unstable (new API). > --- > src/libxl/libxl_domain.c | 7 ++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c > index 04962a0..aed904b 100644 > --- a/src/libxl/libxl_domain.c > +++ b/src/libxl/libxl_domain.c > @@ -1070,7 +1070,12 @@ libxlDomainStart(libxlDriverPrivatePtr driver, > virDomainObjPtr vm, > ret = libxl_domain_create_new(cfg->ctx, _config, >, NULL, _console_how); > } else { > -#ifdef LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS > +#if defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_SEND_BACK_FD) > +params.checkpointed_stream = 0; > +ret = libxl_domain_create_restore(cfg->ctx, _config, , > + restore_fd, -1, , NULL, > + _console_how); > +#elif defined(LIBXL_HAVE_DOMAIN_CREATE_RESTORE_PARAMS) > params.checkpointed_stream = 0; > ret = libxl_domain_create_restore(cfg->ctx, _config, , >restore_fd, , NULL, > ACK This fixes integration testing that Xen Project does with libvirt and Xen so it would be nice to get in for 1.3.3. -- Doug Goldstein signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Fwd: libvirt-php: 0.4.8 tag is missing
Hi Michal, I sent the below message to the libvirt mailing list back on June 11th 2013 but never received a response from anyone. I just checked and the tag is still missing. Can you possibly push this tag as it looks like you are maintaining this project now. Thank you. -- Doug Goldstein -- Forwarded message -- From: Doug Goldstein car...@gentoo.org Date: Tue, Jun 11, 2013 at 8:31 PM Subject: libvirt-php: 0.4.8 tag is missing To: libvir-list libvir-list@redhat.com The libvirt-php 0.4.8 tar is missing from the git repo [1]. Hopefully someone who created the tarball can create the tag as well and push it. [1] http://libvirt.org/git/?p=libvirt-php.git Thanks. -- Doug Goldstein -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Drop dependency on pm-is-supported
On Mar 28, 2014, at 11:32 AM, Cédric Bosdonnat cbosdon...@suse.com wrote: From: Cédric Bosdonnat cedric.bosdon...@free.fr pm-is-supported is the only thing needed in pm-utils, better get rid of it since systemd is heavily used for libvirt. --- src/util/virnodesuspend.c | 34 -- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c index 8088931..9839de2 100644 --- a/src/util/virnodesuspend.c +++ b/src/util/virnodesuspend.c @@ -29,6 +29,8 @@ #include viralloc.h #include virlog.h #include virerror.h +#include virfile.h +#include virstring.h #define VIR_FROM_THIS VIR_FROM_NONE @@ -263,41 +265,45 @@ int nodeSuspendForDuration(unsigned int target, static int virNodeSuspendSupportsTarget(unsigned int target, bool *supported) { -virCommandPtr cmd; -int status; int ret = -1; +char *buf = NULL; +char **states = NULL; +bool canSuspend = false; +bool canHibernate = false; if (virNodeSuspendInitialize() 0) return -1; *supported = false; +if (virFileReadAll(/sys/power/state, 1024, buf) 0) +goto cleanup; + +states = virStringSplit(buf, , 0); + +canSuspend = (virStringArrayHasString(states, mem) || + virStringArrayHasString(states, standby)); +canHibernate = virStringArrayHasString(states, disk); + switch (target) { case VIR_NODE_SUSPEND_TARGET_MEM: -cmd = virCommandNewArgList(pm-is-supported, --suspend, NULL); +*supported = canSuspend; break; case VIR_NODE_SUSPEND_TARGET_DISK: -cmd = virCommandNewArgList(pm-is-supported, --hibernate, NULL); +*supported = canHibernate; break; case VIR_NODE_SUSPEND_TARGET_HYBRID: -cmd = virCommandNewArgList(pm-is-supported, --suspend-hybrid, NULL); +*supported = canSuspend canHibernate; break; default: return ret; } -if (virCommandRun(cmd, status) 0) -goto cleanup; - - /* -* Check return code of command == 0 for success -* (i.e., the PM capability is supported) -*/ -*supported = (status == 0); ret = 0; cleanup: -virCommandFree(cmd); +VIR_FREE(buf); +virStringFreeList(states); return ret; } -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list While systemd is used for a number of things there are other platforms than Linux and there are Linux platforms that don't use systemd. Can't we just wrap this in if not systemd? -- Doug -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] spice: expose the QEMU disable file transfer option
On Jan 15, 2014, at 10:33 AM, Francesco Romani from...@redhat.com wrote: spice-server offers an API to disable file transfer messages on the agent channel between the client and the guest. This is supported in qemu through the disable-agent-file-xfer option. This patch exposes this option to libvirt. Adds a new element 'filetransfer', with one property, 'filetransfer', which accepts a boolean setting. Default is enabled. Haven't reviewed the code but the commit message is wrong. The property is 'enable' from the schema change. Depends on the capability exported in the first patch of the series. Signed-off-by: Francesco Romani from...@redhat.com --- docs/formatdomain.html.in | 8 + docs/schemas/domaincommon.rng | 11 ++ src/conf/domain_conf.c | 31 - src/conf/domain_conf.h | 10 ++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_command.c| 9 + ...emuxml2argv-graphics-spice-agent-file-xfer.args | 9 + ...qemuxml2argv-graphics-spice-agent-file-xfer.xml | 40 ++ .../qemuxml2argv-graphics-spice.args | 5 +-- .../qemuxml2argv-graphics-spice.xml| 1 + tests/qemuxml2argvtest.c | 9 - 11 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 68860ef..c11a7d3 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4042,6 +4042,7 @@ qemu-kvm -net nic,model=? /dev/null lt;streaming mode='filter'/gt; lt;clipboard copypaste='no'/gt; lt;mouse mode='client'/gt; +lt;filetransfer enable='no'/gt; lt;/graphicsgt;/pre p Spice supports variable compression settings for audio, @@ -4081,6 +4082,13 @@ qemu-kvm -net nic,model=? /dev/null span class=sincesince 0.9.11/span. If no mode is specified, the qemu default will be used (client mode). /p +p + File transfer functionality (via Spice agent) is set using the + codefiletransfer/code element. + It is enabled by default, and can be disabled by setting the + codeenable/code property to codeno/code , + since span class=sincesince 1.2.2/span. +/p /dd dtcoderdp/code/dt dd diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index a69f6b6..9ddb772 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2474,6 +2474,17 @@ empty/ /element /optional +optional + element name=filetransfer +attribute name=enable + choice +valueyes/value +valueno/value + /choice +/attribute +empty/ + /element +/optional /interleave /group group diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c1dd598..7d6c9ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -604,6 +604,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpiceClipboardCopypaste, yes, no); +VIR_ENUM_IMPL(virDomainGraphicsSpiceAgentFileTransfer, + VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_LAST, + default, + yes, + no); + VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST, subsystem, capabilities) @@ -8519,6 +8525,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, VIR_FREE(copypaste); def-data.spice.copypaste = copypasteVal; +} else if (xmlStrEqual(cur-name, BAD_CAST filetransfer)) { +char *enable = virXMLPropString(cur, enable); +int enableVal; + +if (!enable) { +virReportError(VIR_ERR_XML_ERROR, %s, + _(spice filetransfer missing enable)); +goto error; +} + +if ((enableVal = + virDomainGraphicsSpiceAgentFileTransferTypeFromString(enable)) = 0) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(unknown enable value '%s'), enable); +VIR_FREE(enable); +goto error; +} +
Re: [libvirt] [PATCH v2] Add helper program to create custom leases
On Jan 14, 2014, at 2:09 PM, Nehal J Wani nehaljw.k...@gmail.com wrote: Introduce helper program to catch events from dnsmasq and maintain a custom lease file per network. It supports DHCPv4 and DHCPv6. The file is saved as interface-name.status. The format of each lease is: expiry-time (epoch time) mac iaid ip-address hostname clientid I feel like I'm bikesheding but is it the best idea to have a custom file format? I know our string handling code makes this really easy to do but it just has a slight code smell to make our own format. We link to stuff like yajl and libxml for JSON/XML support and its really simple to do so we could easily write out a JSON/XML file and read it in. Definitely don't rework the patch based on my comments because we'll 99.9% go with this way, I'm just asking a question I felt should be asked. Example of custom leases file content: 1385245780 52:54:00:2f:ba:76 * 192.168.150.153 * * 1385245781 52:54:00:2f:ba:76 3127926 2001:db8:ca2:2:1::6c * 00:04:76:00:cf:ae:b3:0b:fc:cd:0e:22:2e:97:76:65:74:ec 1385245964 52:54:00:44:7c:d7 * 192.168.150.219 iiit-ad885e4aa1 01:52:54:00:44:7c:d7 1385245964 52:54:00:44:7c:d7 * 192.168.150.219 * 01:52:54:00:44:7c:d7 1385246016 52:54:00:5d:99:92 * 192.168.150.212 iiit-ad885e4aa1 01:52:54:00:5d:99:92 1385246041 52:54:00:3b:16:e0 * 192.168.150.207 * * 1385246081 52:54:00:db:dd:98 * 192.168.150.234 * * 1385246088 52:54:00:db:dd:98 14409112 2001:db8:ca2:2:1::6d * 00:04:76:00:cf:ae:b3:0b:fc:cd:0e:22:2e:97:76:65:74:ec --- As danpb suggested, I have split the previous patch into helper program API Refer: https://www.redhat.com/archives/libvir-list/2013-December/msg00694.html Once this get ACKed, I'll send in the patches for the Leases API v6 src/Makefile.am | 20 src/network/bridge_driver.c | 4 + src/util/leaseshelper.c | 225 3 files changed, 249 insertions(+) create mode 100644 src/util/leaseshelper.c diff --git a/src/Makefile.am b/src/Makefile.am index 57e163f..6e5b03c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -838,6 +838,9 @@ STORAGE_HELPER_DISK_SOURCES =\ UTIL_IO_HELPER_SOURCES =\ util/iohelper.c +UTIL_LEASES_HELPER_SOURCES =\ +util/leaseshelper.c + # Network filters NWFILTER_DRIVER_SOURCES =\ nwfilter/nwfilter_driver.h nwfilter/nwfilter_driver.c\ @@ -2408,6 +2411,23 @@ libvirt_iohelper_CFLAGS = \ $(NULL) endif WITH_LIBVIRTD +if WITH_LIBVIRTD +libexec_PROGRAMS += libvirt_leaseshelper +libvirt_leaseshelper_SOURCES = $(UTIL_LEASES_HELPER_SOURCES) +libvirt_leaseshelper_LDFLAGS = \ + $(NULL) +libvirt_leaseshelper_LDADD = \ + libvirt_util.la \ + ../gnulib/lib/libgnu.la +if WITH_DTRACE_PROBES +libvirt_leaseshelper_LDADD += libvirt_probes.lo +endif WITH_DTRACE_PROBES + +libvirt_leaseshelper_CFLAGS = \ + $(PIE_CFLAGS) \ + $(NULL) +endif WITH_LIBVIRTD + if WITH_STORAGE_DISK if WITH_LIBVIRTD libexec_PROGRAMS += libvirt_parthelper diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 95e4b65..2278dba 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1063,6 +1063,10 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps)); virCommandAddArgFormat(cmd, --conf-file=%s, configfile); + +/* This helper is used to create cutom leases file for libvirt */ +virCommandAddArgFormat(cmd, --dhcp-script=%s, LIBEXECDIR /libvirt_leaseshelper); + *cmdout = cmd; ret = 0; cleanup: diff --git a/src/util/leaseshelper.c b/src/util/leaseshelper.c new file mode 100644 index 000..486ebe3 --- /dev/null +++ b/src/util/leaseshelper.c @@ -0,0 +1,225 @@ +/* + * leasehelper.c: Helper program to create custom leases file + * + * Copyright (C) 2013 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * http://www.gnu.org/licenses/. + * + * Author: Nehal J Wani nehaljw.k...@gmail.com + * + */ + +#include config.h + +#include stdio.h +#include stdlib.h + +#include virutil.h +#include virthread.h +#include virfile.h +#include
[libvirt] [PATCH python] virStream.sendAll() fix raising an undeclared var
The exception is raised from the variable 'e', which was undeclared in this context. Used code that is compatible with old and new Python versions. --- libvirt-override-virStream.py | 1 + 1 file changed, 1 insertion(+) diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py index 189d062..cd44314 100644 --- a/libvirt-override-virStream.py +++ b/libvirt-override-virStream.py @@ -76,6 +76,7 @@ try: got = handler(self, 1024*64, opaque) except: +e = sys.exc_info()[1] try: self.abort() except: -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] vmware: os x support is broken
On Fri, Jan 3, 2014 at 12:14 PM, Eric Blake ebl...@redhat.com wrote: On 01/03/2014 10:57 AM, Denis Kondratenko wrote: Incorrect usage of virAsprintf and vmware-vmx reports to stderr. --- https://bugzilla.redhat.com/show_bug.cgi?id=1036248 Oh my - the triple --- leadin confused 'git am': Applying: vmware: os x support is broken fatal: patch fragment without header at line 42: @@ -271,17 +271,17 @@ vmwareExtractVersion(struct vmware_driver *driver)/divdiv /divdiv switch (driver-gt;type) {/divdiv case VMWARE_DRIVER_PLAYER:/divdiv- if (virAsprintf(amp;bin, quot;%s/%squot;, vmwarePath, quot;vmplayerquot;))/div Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0001 vmware: os x support is broken so I had to apply it by hand. case VMWARE_DRIVER_PLAYER: -if (virAsprintf(bin, %s/%s, vmwarePath, vmplayer)) +if (virAsprintf(bin, %s/%s, vmwarePath, vmplayer) 0) Definitely correct! cmd = virCommandNewArgList(bin, -v, NULL); virCommandSetOutputBuffer(cmd, outbuf); + +// OS X 10.9.1 and some earlier ver: vmware-vmx reports ver to stderr We prefer to avoid C99 comments, and the code is self-explanatory enough that it was easier to just drop the comment (and put it in the commit message instead). Sadly the comment actually doesn't make any sense. vmware-vmx is a program shipped by VMware and doesn't select stdout or stderr based on OS X version. It selects it based on whether the arguments supplied are valid or not for the command. If they aren't valid then its stderr (like most UNIX utilities) and if they're valid it goes via stdout. I believe we had to use a bad command (and thus stderr) on OS X always to get the version info as nothing that supplied the version returned a successful. Denis, I don't own a copy of VMware Fusion (or any VMware product) so I can't personally test. I have a number of branches which have some potential fixes (I believe 1 series has been posted RFC without a response) but don't at the moment have anyone to test them. So if you're interested in testing them I can provide you with an alternate brew install command and we can maybe land some other fixes. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] define __GNUC_PREREQ macro before using it
On Tue, Dec 31, 2013 at 8:26 AM, Eric Blake ebl...@redhat.com wrote: On 12/29/2013 03:52 PM, Doug Goldstein wrote: We brought over use of the __GNUC_PREREQ macro from libvirt but didn't bring over the definition of it. This brings over the macro from libvirt sources. --- libvirt-utils.h | 9 + 1 file changed, 9 insertions(+) ACK (with #endif fixed). diff --git a/libvirt-utils.h b/libvirt-utils.h index f55be7b..add7553 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -65,6 +65,15 @@ # endif # ifdef __GNUC__ + +# ifndef __GNUC_PREREQ +# if defined __GNUC__ defined __GNUC_MINOR__ +#define __GNUC_PREREQ(maj, min)\ +((__GNUC__ 16) + __GNUC_MINOR__ = ((maj) 16) + (min)) +# else +#define __GNUC_PREREQ(maj,min) 0 Copy and paste and all, but you could add a space after that comma for consistency. +# endif + /** * ATTRIBUTE_UNUSED: * -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org Pushed with the fixes. Thanks all. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] rbd: Use rbd_create3 to create RBD format 2 images by default
On Thu, Jan 2, 2014 at 10:01 AM, Wido den Hollander w...@widodh.nl wrote: On 12/11/2013 03:47 PM, Wido den Hollander wrote: This new RBD format supports snapshotting and cloning. By having libvirt create images in format 2 end-users of the created images can benefit of the new RBD format. Older versions of libvirt can work with this new RBD format as long as librbd supports format 2, something that all recent versions of librbd do. Did somebody get a look at this patch yet? It's a fairly simple one, but would be great for the Ceph project! So I'm thinking we might want to do something similar with the compat attribute added for qcow2 for the versioning that way things are explicitly stated rather than implicitly switching versions on us. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] can't build python bindings on FreeBSD
On Sun, Dec 29, 2013 at 12:42 PM, Jason Helfman j...@freebsd.org wrote: Any ideas? I just posted a patch with the subject of [PATCH python] define __GNUC_PREREQ macro before using it [1]. Give it a shot and let me know if that fixes the issue. Additionally, if you can potentially provide a FreeBSD machine that we can use as a BuildBot [2] for libvirt-python, that would likely prevent problems in the future. You can see the BB here [3]. [1] https://www.redhat.com/archives/libvir-list/2013-December/msg01317.html [2] http://buildbot.net [3] http://bb.cardoe.com/libvirt-python/ Clang: FreeBSD clang version 3.1 creating build/temp.freebsd-9.1-RELEASE-p4-i386-2.7 creating build/temp.freebsd-9.1-RELEASE-p4-i386-2.7/build clang -DNDEBUG -O2 -pipe -fno-strict-aliasing -O2 -pipe -fno-strict-aliasing -fPIC -I. -I/usr/local/include/python2.7 -c libvirt-override.c -o build/temp.freebsd-9.1-RELEASE-p4-i386-2.7/libvirt-override.o -I/usr/local/include In file included from libvirt-override.c:26: ./libvirt-utils.h:87:22: error: token is not a valid binary operator in a preprocessor subexpression # if __GNUC_PREREQ (3, 3) ~ ^ ./libvirt-utils.h:99:22: error: token is not a valid binary operator in a preprocessor subexpression # if __GNUC_PREREQ (3, 4) ~ ^ 2 errors generated. error: command 'clang' failed with exit status 1 *** [do-build] Error code 1 Stop in /usr/home/jgh/workspace/ports/devel/py-libvirt. Gcc: gcc (GCC) 4.2.1 20070831 gcc -DNDEBUG -O2 -pipe -fno-strict-aliasing -O2 -pipe -fno-strict-aliasing -fPIC -I. -I/usr/local/include/python2.7 -c libvirt-override.c -o build/temp.freebsd-9.1-RELEASE-p4-i386-2.7/libvirt-override.o -I/usr/local/include In file included from libvirt-override.c:26: libvirt-utils.h:87:22: error: missing binary operator before token ( libvirt-utils.h:99:22: error: missing binary operator before token ( error: command 'gcc' failed with exit status 1 *** [do-build] Error code 1 Thanks! -jgh -- Jason Helfman | FreeBSD Committer j...@freebsd.org | http://people.freebsd.org/~jgh | The Power to Serve -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python] define __GNUC_PREREQ macro before using it
We brought over use of the __GNUC_PREREQ macro from libvirt but didn't bring over the definition of it. This brings over the macro from libvirt sources. --- libvirt-utils.h | 9 + 1 file changed, 9 insertions(+) diff --git a/libvirt-utils.h b/libvirt-utils.h index f55be7b..add7553 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -65,6 +65,15 @@ # endif # ifdef __GNUC__ + +# ifndef __GNUC_PREREQ +# if defined __GNUC__ defined __GNUC_MINOR__ +#define __GNUC_PREREQ(maj, min)\ +((__GNUC__ 16) + __GNUC_MINOR__ = ((maj) 16) + (min)) +# else +#define __GNUC_PREREQ(maj,min) 0 +# endif + /** * ATTRIBUTE_UNUSED: * -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC/PATCH python] expose the bindings version to Python
On Thu, Dec 12, 2013 at 4:29 PM, Eric Blake ebl...@redhat.com wrote: On 12/11/2013 08:43 PM, Doug Goldstein wrote: The method getVersion() retrieves the version of the libvirt library that the binaries are linked against but there is no way to retrieve the version of the bindings you are using. In the future if we support new APIs in Python that don't rely on features in the library there needs to be a way for programmers to detect the version. --- I would expect there's a cleaner way to implement this than I've done but I opted for what I saw as the smallest implementation. If anyone has a suggestion for a better way to do this I'm ok with redoing this patch. The idea sounds sane to me. --- libvirt-override.py | 3 +++ setup.py| 16 2 files changed, 19 insertions(+) Alas, my python is too weak to give either a meaningful review to the code, or to suggest an alternative. :( -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org Ping for some more feedback from others. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] libxl: avoid crashing if calling `virsh numatune' on inactive domain
On Tue, Dec 24, 2013 at 12:02 AM, Eric Blake ebl...@redhat.com wrote: On 12/20/2013 11:36 AM, Jim Fehlig wrote: Dario Faggioli wrote: by, in libxlDomainGetNumaParameters(), calling libxl_bitmap_init() as soon as possible, which avoids getting to 'cleanup:', where libxl_bitmap_dispose() happens, without having initialized the nodemap, and hence crashing after some invalid free()-s: Yikes! ACK to the fix. I've pushed it. This has been assigned CVE-6457; we'll get it tagged in libvirt.git and make sure it is backported to relevant branches once I've got more time (may be in 2014). I'll help you out and get started on this. Family is in town around the holidays so no promises I'll get them all done if its not too trivial. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] libxl: avoid crashing if calling `virsh numatune' on inactive domain
On Sat, Dec 28, 2013 at 3:18 PM, Doug Goldstein car...@gentoo.org wrote: On Tue, Dec 24, 2013 at 12:02 AM, Eric Blake ebl...@redhat.com wrote: On 12/20/2013 11:36 AM, Jim Fehlig wrote: Dario Faggioli wrote: by, in libxlDomainGetNumaParameters(), calling libxl_bitmap_init() as soon as possible, which avoids getting to 'cleanup:', where libxl_bitmap_dispose() happens, without having initialized the nodemap, and hence crashing after some invalid free()-s: Yikes! ACK to the fix. I've pushed it. This has been assigned CVE-6457; we'll get it tagged in libvirt.git and make sure it is backported to relevant branches once I've got more time (may be in 2014). I'll help you out and get started on this. Family is in town around the holidays so no promises I'll get them all done if its not too trivial. -- Doug Goldstein The fix has been back ported to: v1.1.1-maint v1.1.2-maint v1.1.3-maint v1.1.4-maint v1.2.0-maint This should cover all affected versions per Jim's analysis. Let me know if anything further needs to be done. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] python setMetadata issue
On Dec 24, 2013, at 2:13 AM, Umar Draz unix...@gmail.com wrote: Hi I am trying to set Metada of running virtual machine, but its giving me an error. Thanks for taking the time to report a potential issue. When you report potential issues please make sure to include the version of libvirt you are using. Here is my code import libvirt conn = libvirt.open('qemu+tcp://10.0.128.12/system') dom = conn.lookupByName('virtspace') type = 'VIR_DOMAIN_METADATA_DESCRIPTION' The type value is not a string, it should be libvirt.VIR_DOMAIN_METADATA_DESCRIPTION key = '' uri = '' The above values must be set to None for when setting the description per the documentation. dom.setMetadata(conn, type, 'myDescription', key, uri) and here is the error. Traceback (most recent call last): File setMeta.py, line 11, in module dom.setMetadata(conn, type, 'meta_test', key, uri) File /usr/lib64/python2.6/site-packages/libvirt.py, line 1460, in setMetadata ret = libvirtmod.virDomainSetMetadata(self._o, type, metadata, key, uri, flags) AttributeError: virConnect instance has no attribute '__trunc__' Definitely curious what version you used since we should not error like this despite the argument mix up. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] storage: show compile options in virsh --version=long
On Wed, Dec 11, 2013 at 9:10 PM, Eric Blake ebl...@redhat.com wrote: Adding output to 'virsh --version=long' makes it easier to tell if a distro built with particular libraries (it doesn't tell you what a remote libvirtd is built with, but is still better than nothing). * tools/virsh.c (vshShowVersion): Add gluster witness. Signed-off-by: Eric Blake ebl...@redhat.com --- tools/virsh.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/virsh.c b/tools/virsh.c index 5559d71..9d07d3e 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -3069,6 +3069,9 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED) #ifdef WITH_STORAGE_SHEEPDOG vshPrint(ctl, Sheepdog); #endif +#ifdef WITH_STORAGE_GLUSTER +vshPrint(ctl, Gluster); +#endif vshPrint(ctl, \n); vshPrint(ctl, %s, _( Miscellaneous:)); -- 1.8.4.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From a code stand point this is fine. But the commit subject and message are ambiguous and don't really explain what you're doing. It seems like you're adding all storage compile options into the output when really they were there already and just Gluster was missing. Wouldn't be better to say storage: show gluster option in virsh --version=long? I realize I'm nitpicking the commit message/subject, the code is fine so ACK from that stand point. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [RFC/PATCH python] expose the bindings version to Python
The method getVersion() retrieves the version of the libvirt library that the binaries are linked against but there is no way to retrieve the version of the bindings you are using. In the future if we support new APIs in Python that don't rely on features in the library there needs to be a way for programmers to detect the version. --- I would expect there's a cleaner way to implement this than I've done but I opted for what I saw as the smallest implementation. If anyone has a suggestion for a better way to do this I'm ok with redoing this patch. --- libvirt-override.py | 3 +++ setup.py| 16 2 files changed, 19 insertions(+) diff --git a/libvirt-override.py b/libvirt-override.py index 63f8ecb..ed8f73a 100644 --- a/libvirt-override.py +++ b/libvirt-override.py @@ -2,6 +2,9 @@ # Manually written part of python bindings for libvirt # +__version__ = '@VERSION@' +version = @VER_TUPLE@ + # On cygwin, the DLL is called cygvirtmod.dll import sys diff --git a/setup.py b/setup.py index 24d4cf2..ad4f406 100755 --- a/setup.py +++ b/setup.py @@ -119,6 +119,21 @@ if have_libvirt_lxc: class my_build(build): +def gen_version(self, filename): +os.rename(filename, filename + '.tmp') + +version = self.distribution.get_version() +ver_tuple = tuple(int(x) for x in version.split('.')) + +f1 = open(filename + '.tmp', 'r') +f2 = open(filename, 'w') +for line in f1: +f2.write(line +.replace('@VER_TUPLE@', str(ver_tuple)) +.replace('@VERSION@', version)) +f1.close() +f2.close() + def run(self): apis = get_api_xml_files() @@ -127,6 +142,7 @@ class my_build(build): if have_libvirt_lxc: self.spawn([sys.executable, generator.py, libvirt-lxc, apis[2]]) +self.gen_version('build/libvirt.py') build.run(self) class my_sdist(sdist): -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 01/14] examples: Invoke print(...) instead of print ...
like option -a not recognized usage() sys.exit(2) for o, a in opts: if o in (-h, --help): -usage(sys.stdout) +usage() sys.exit() if o in (-d, --debug): global do_debug @@ -541,7 +541,7 @@ def main(): else: uri = qemu:///system -print Using uri: + uri +print(Using uri: + uri) # Run a background thread with the event loop if use_pure_python_event_loop: @@ -554,7 +554,7 @@ def main(): # Close connection on exit (to test cleanup paths) old_exitfunc = getattr(sys, 'exitfunc', None) def exit(): -print Closing + str(vc) +print(Closing + vc.getURI()) vc.close() if (old_exitfunc): old_exitfunc() sys.exitfunc = exit diff --git a/examples/topology.py b/examples/topology.py index 62effe3..191669c 100755 --- a/examples/topology.py +++ b/examples/topology.py @@ -13,13 +13,13 @@ from xml.dom import minidom try: conn = libvirt.openReadOnly(None) except libvirt.libvirtError: -print 'Failed to connect to the hypervisor' +print('Failed to connect to the hypervisor') sys.exit(1) try: capsXML = conn.getCapabilities() except libvirt.libvirtError: -print 'Failed to request capabilities' +print('Failed to request capabilities') sys.exit(1) caps = minidom.parseString(capsXML) @@ -38,8 +38,8 @@ siblingsIds = [ proc.getAttribute('siblings') for proc in cells.getElementsByTagName('cpu') if proc.getAttribute('siblings') not in siblingsIds ] -print Host topology -print NUMA nodes:, cells.getAttribute('num') -printSockets:, len(set(socketIds)) -print Cores:, len(set(siblingsIds)) -printThreads:, total_cpus +print(Host topology) +print(NUMA nodes:, cells.getAttribute('num')) +print( Sockets:, len(set(socketIds))) +print( Cores:, len(set(siblingsIds))) +print( Threads:, total_cpus) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 02/14] examples: Ensure we write bytes to the self-pipe
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Strings in python3 default to unicode, so when writing to the self-pipe we must be sure to use bytes by calling the encode() method. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- examples/event-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/event-test.py b/examples/event-test.py index cf1a8b8..1402c04 100644 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -236,7 +236,7 @@ class virEventLoopPure: def interrupt(self): if self.runningPoll and not self.pendingWakeup: self.pendingWakeup = True -os.write(self.pipetrick[1], 'c') +os.write(self.pipetrick[1], 'c'.encode(UTF-8)) # Registers a new file handle 'fd', monitoring for 'events' (libvirt -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 03/14] override: Fix native module registration to work with Python3
*PyInit_libvirtmod_qemu(void); +# else +extern PyObject *PyInit_cygvirtmod_qemu(void); +# endif #else +# ifndef __CYGWIN__ +extern void initlibvirtmod_qemu(void); +# else extern void initcygvirtmod_qemu(void); +# endif #endif #if 0 @@ -128,30 +136,59 @@ static PyMethodDef libvirtQemuMethods[] = { {NULL, NULL, 0, NULL} }; +#if PY_MAJOR_VERSION 2 +static struct PyModuleDef moduledef = { +PyModuleDef_HEAD_INIT, +# ifndef __CYGWIN__ +libvirtmod_qemu, +# else +cygvirtmod_qemu, +# endif +NULL, +-1, +libvirtQemuMethods, +NULL, +NULL, +NULL, +NULL +}; + +PyObject * +# ifndef __CYGWIN__ +PyInit_libvirtmod_qemu +# else +PyInit_cygvirtmod_qemu +# endif + (void) +{ +PyObject *module; + +if (virInitialize() 0) +return NULL; + +module = PyModule_Create(moduledef); + +return module; +} +#else /* ! PY_MAJOR_VERSION 2 */ void -#ifndef __CYGWIN__ +# ifndef __CYGWIN__ initlibvirtmod_qemu -#else +# else initcygvirtmod_qemu -#endif +# endif (void) { -static int initialized = 0; - -if (initialized != 0) -return; - if (virInitialize() 0) return; /* initialize the python extension module */ Py_InitModule((char *) -#ifndef __CYGWIN__ - libvirtmod_qemu -#else - cygvirtmod_qemu -#endif - , libvirtQemuMethods); - -initialized = 1; +# ifndef __CYGWIN__ + libvirtmod_qemu, +# else + cygvirtmod_qemu, +# endif + libvirtQemuMethods); } +#endif /* ! PY_MAJOR_VERSION 2 */ -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 04/14] sanitytest: Fix libvirtError class handling for Python 2.4
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The Exception class hiearchy in Python 2.4 reports different data types than in later Python versions. As a result the type(libvirt.libvirtError) does not return 'type'. We just special case handling of this class. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sanitytest.py b/sanitytest.py index bd93fe6..eb4caee 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -39,9 +39,11 @@ for name in dir(libvirt): if name[0] == '_': continue thing = getattr(libvirt, name) +# Special-case libvirtError to deal with python 2.4 difference +# in Exception class type reporting. if type(thing) == int: gotenums.append(name) -elif type(thing) == type: +elif type(thing) == type or name == libvirtError: gottypes.append(name) gotfunctions[name] = [] elif callable(thing): -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Don't have a setup to test, but in principle the code makes sense. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 05/14] override: Replace PyString_FromString with libvirt_constcharPtrWrap
@@ libvirt_virNWFilterGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -4280,7 +4280,7 @@ libvirt_virNWFilterGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -4601,7 +4601,7 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED, if (base_cpu == NULL) return VIR_PY_NONE; -pybase_cpu = PyString_FromString(base_cpu); +pybase_cpu = libvirt_constcharPtrWrap(base_cpu); VIR_FREE(base_cpu); if (pybase_cpu == NULL) @@ -6969,7 +6969,7 @@ libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED, goto cleanup; } -py_retval = PyString_FromStringAndSize(buf, size); +py_retval = libvirt_charPtrSizeWrap(buf, size); cleanup: VIR_FREE(buf); @@ -7006,7 +7006,7 @@ libvirt_virDomainMemoryPeek(PyObject *self ATTRIBUTE_UNUSED, goto cleanup; } -py_retval = PyString_FromStringAndSize(buf, size); +py_retval = libvirt_charPtrSizeWrap(buf, size); cleanup: VIR_FREE(buf); diff --git a/libvirt-qemu-override.c b/libvirt-qemu-override.c index 72257ac..480a7d3 100644 --- a/libvirt-qemu-override.c +++ b/libvirt-qemu-override.c @@ -85,7 +85,7 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString(result); +py_retval = libvirt_constcharPtrWrap(result); VIR_FREE(result); return py_retval; } @@ -116,7 +116,7 @@ libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, PyObject if (!result) return VIR_PY_NONE; -py_retval = PyString_FromString(result); +py_retval = libvirt_constcharPtrWrap(result); VIR_FREE(result); return py_retval; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 06/14] override: Replace PyString_AsString with libvirt_charPtrUnwrap
char *removeHandleName = NULL; -static PyObject *addTimeoutObj= NULL; -static char *addTimeoutName = NULL; -static PyObject *updateTimeoutObj = NULL; -static char *updateTimeoutName= NULL; -static PyObject *removeTimeoutObj = NULL; -static char *removeTimeoutName= NULL; +static PyObject *addHandleObj; +static char *addHandleName; +static PyObject *updateHandleObj; +static char *updateHandleName; +static PyObject *removeHandleObj; +static char *removeHandleName; +static PyObject *addTimeoutObj; +static char *addTimeoutName; +static PyObject *updateTimeoutObj; +static char *updateTimeoutName; +static PyObject *removeTimeoutObj; +static char *removeTimeoutName; Not sure the advantage of this change. #define NAME(fn) ( fn ## Name ? fn ## Name : # fn ) @@ -5381,6 +5393,12 @@ libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject * self, Py_XDECREF(addTimeoutObj); Py_XDECREF(updateTimeoutObj); Py_XDECREF(removeTimeoutObj); +free(addHandleName); +free(updateHandleName); +free(removeHandleName); +free(addTimeoutName); +free(updateTimeoutName); +free(removeTimeoutName); More free() vs VIR_FREE(). /* Parse and check arguments */ if (!PyArg_ParseTuple(args, (char *) OO:virEventRegisterImpl, @@ -7084,7 +7102,7 @@ libvirt_virNodeSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED, cleanup: virTypedParamsFree(params, nparams); -VIR_FREE(new_params); +virTypedParamsFree(new_params, nparams); return ret; } diff --git a/typewrappers.c b/typewrappers.c index 1622986..1e99554 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -317,6 +317,24 @@ libvirt_boolUnwrap(PyObject *obj, bool *val) return 0; } +int +libvirt_charPtrUnwrap(PyObject *obj, char **str) +{ +const char *ret; +*str = NULL; +if (!obj) { +PyErr_SetString(PyExc_TypeError, unexpected type); +return -1; +} + +ret = PyString_AsString(obj); +if (ret +!(*str = strdup(ret))) +return -1; + +return 0; +} + PyObject * libvirt_virDomainPtrWrap(virDomainPtr node) { diff --git a/typewrappers.h b/typewrappers.h index 04e364f..7068426 100644 --- a/typewrappers.h +++ b/typewrappers.h @@ -173,6 +173,7 @@ int libvirt_longlongUnwrap(PyObject *obj, long long *val); int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val); int libvirt_doubleUnwrap(PyObject *obj, double *val); int libvirt_boolUnwrap(PyObject *obj, bool *val); +int libvirt_charPtrUnwrap(PyObject *obj, char **str); PyObject * libvirt_virConnectPtrWrap(virConnectPtr node); PyObject * libvirt_virDomainPtrWrap(virDomainPtr node); PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Some minor nits but overall looks ok. I'll double check it for any leaks with more context after I review the rest of the series. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 07/14] override: Replace Py{Int, Long}_FromLong with helpers
); PyObject * libvirt_ulongWrap(unsigned long val); PyObject * libvirt_longlongWrap(long long val); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 08/14] override: Replace PyInt_AsLong with helper
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Replace use of the PyInt_AsLong libvirt_intUnwrap helper. This isolates the need for Python3 specific code in one place Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 3334c3f..9a013ca 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -5177,10 +5177,8 @@ libvirt_virEventAddHandleFunc (int fd, if (!result) { PyErr_Print(); PyErr_Clear(); -} else if (!PyInt_Check(result)) { -DEBUG(%s: %s should return an int\n, __FUNCTION__, NAME(addHandle)); } else { -retval = (int)PyInt_AsLong(result); +libvirt_intUnwrap(result, retval); } Py_XDECREF(result); @@ -5304,10 +5302,8 @@ libvirt_virEventAddTimeoutFunc(int timeout, if (!result) { PyErr_Print(); PyErr_Clear(); -} else if (!PyInt_Check(result)) { -DEBUG(%s: %s should return an int\n, __FUNCTION__, NAME(addTimeout)); } else { -retval = (int)PyInt_AsLong(result); +libvirt_intUnwrap(result, retval); } Py_XDECREF(result); @@ -6825,7 +6821,7 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED, } for (i = 0; i nkeycodes; i++) { -keycodes[i] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list, i)); +libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), (keycodes[i])); } LIBVIRT_BEGIN_ALLOW_THREADS; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 09/14] typewrappers: Replace use of PyString class
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Replace use of PyString with either PyBytes or PyUnicode. The former is used for buffers with explicit sizes, which are used by APIs processing raw bytes. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- typewrappers.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/typewrappers.c b/typewrappers.c index c230e0f..532fe13 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -92,7 +92,11 @@ libvirt_charPtrSizeWrap(char *str, Py_ssize_t size) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyBytes_FromStringAndSize(str, size); +#else ret = PyString_FromStringAndSize(str, size); +#endif VIR_FREE(str); return ret; } @@ -106,7 +110,11 @@ libvirt_charPtrWrap(char *str) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyUnicode_FromString(str); +#else ret = PyString_FromString(str); +#endif VIR_FREE(str); return ret; } @@ -120,7 +128,11 @@ libvirt_constcharPtrWrap(const char *str) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyUnicode_FromString(str); +#else ret = PyString_FromString(str); +#endif return ret; } @@ -328,17 +340,24 @@ libvirt_boolUnwrap(PyObject *obj, bool *val) int libvirt_charPtrUnwrap(PyObject *obj, char **str) { +#if PY_MAJOR_VERSION 3 const char *ret; +#endif *str = NULL; if (!obj) { PyErr_SetString(PyExc_TypeError, unexpected type); return -1; } +#if PY_MAJOR_VERSION 2 +if (!(*str = PyUnicode_AsUTF8(obj))) +return -1; +#else ret = PyString_AsString(obj); if (ret !(*str = strdup(ret))) return -1; +#endif return 0; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 10/14] typewrappers: PyInt/PyLong merge for Python3
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com In Python3 the PyInt / PyLong types have merged into a single PyLong type. Conditionalize the use of PyInt to Python 2 only Signed-off-by: Daniel P. Berrange berra...@redhat.com --- typewrappers.c | 33 - 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/typewrappers.c b/typewrappers.c index 532fe13..7331cbd 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -39,7 +39,11 @@ PyObject * libvirt_intWrap(int val) { PyObject *ret; +#if PY_MAJOR_VERSION 2 +ret = PyLong_FromLong((long) val); +#else ret = PyInt_FromLong((long) val); +#endif return ret; } @@ -47,7 +51,11 @@ PyObject * libvirt_uintWrap(uint val) { PyObject *ret; +#if PY_MAJOR_VERSION 2 +ret = PyLong_FromLong((long) val); +#else ret = PyInt_FromLong((long) val); +#endif return ret; } @@ -55,7 +63,7 @@ PyObject * libvirt_longWrap(long val) { PyObject *ret; -ret = PyInt_FromLong(val); +ret = PyLong_FromLong(val); return ret; } @@ -159,7 +167,11 @@ libvirt_intUnwrap(PyObject *obj, int *val) * to C long type directly. If it is of PyLong_Type, PyInt_AsLong * will call PyLong_AsLong() to deal with it automatically. */ +#if PY_MAJOR_VERSION 2 +long_val = PyLong_AsLong(obj); +#else long_val = PyInt_AsLong(obj); +#endif if ((long_val == -1) PyErr_Occurred()) return -1; @@ -187,7 +199,11 @@ libvirt_uintUnwrap(PyObject *obj, unsigned int *val) return -1; } +#if PY_MAJOR_VERSION 2 +long_val = PyLong_AsLong(obj); +#else long_val = PyInt_AsLong(obj); +#endif if ((long_val == -1) PyErr_Occurred()) return -1; @@ -211,7 +227,7 @@ libvirt_longUnwrap(PyObject *obj, long *val) return -1; } -long_val = PyInt_AsLong(obj); +long_val = PyLong_AsLong(obj); if ((long_val == -1) PyErr_Occurred()) return -1; @@ -229,7 +245,7 @@ libvirt_ulongUnwrap(PyObject *obj, unsigned long *val) return -1; } -long_val = PyInt_AsLong(obj); +long_val = PyLong_AsLong(obj); if ((long_val == -1) PyErr_Occurred()) return -1; @@ -253,10 +269,14 @@ libvirt_longlongUnwrap(PyObject *obj, long long *val) return -1; } +#if PY_MAJOR_VERSION == 2 /* If obj is of PyInt_Type, PyLong_AsLongLong * will call PyInt_AsLong() to handle it automatically. */ if (PyInt_Check(obj) || PyLong_Check(obj)) +#else +if (PyLong_Check(obj)) +#endif llong_val = PyLong_AsLongLong(obj); else PyErr_SetString(PyExc_TypeError, an integer is required); @@ -272,24 +292,27 @@ int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val) { unsigned long long ullong_val = -1; -long long llong_val; if (!obj) { PyErr_SetString(PyExc_TypeError, unexpected type); return -1; } +#if PY_MAJOR_VERSION == 2 /* The PyLong_AsUnsignedLongLong doesn't check the type of * obj, only accept argument of PyLong_Type, so we check it instead. */ if (PyInt_Check(obj)) { -llong_val = PyInt_AsLong(obj); +long long llong_val = PyInt_AsLong(obj); if (llong_val 0) PyErr_SetString(PyExc_OverflowError, negative Python int cannot be converted to C unsigned long long); else ullong_val = llong_val; } else if (PyLong_Check(obj)) { +#else +if (PyLong_Check(obj)) { +#endif ullong_val = PyLong_AsUnsignedLongLong(obj); } else { PyErr_SetString(PyExc_TypeError, an integer is required); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 11/14] override: Conditionalize use of PyString_Check and PyInt_Check
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The PyString and PyInt classes are gone in Python 3, so we must conditionalize their use to be Python 2 only. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 9a013ca..77c0af2 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -322,7 +322,11 @@ virPyDictToTypedParams(PyObject *dict, } if (type == -1) { +#if PY_MAJOR_VERSION 2 +if (PyUnicode_Check(value)) { +#else if (PyString_Check(value)) { +#endif type = VIR_TYPED_PARAM_STRING; } else if (PyBool_Check(value)) { type = VIR_TYPED_PARAM_BOOLEAN; @@ -332,11 +336,13 @@ virPyDictToTypedParams(PyObject *dict, type = VIR_TYPED_PARAM_LLONG; else type = VIR_TYPED_PARAM_ULLONG; +#if PY_MAJOR_VERSION == 2 Every where else in your other patches you did PY_MAJOR_VERSION 3, but its not like we're going to support Python 1 but just a note on inconsistency. } else if (PyInt_Check(value)) { if (PyInt_AS_LONG(value) 0) type = VIR_TYPED_PARAM_LLONG; else type = VIR_TYPED_PARAM_ULLONG; +#endif } else if (PyFloat_Check(value)) { type = VIR_TYPED_PARAM_DOUBLE; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 13/14] sanitytest: Fix broken comparison between int and string
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Python2 was forgiving of a comparison between an int and string but Python3 gets very upset. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanitytest.py b/sanitytest.py index eb4caee..50e4069 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -103,7 +103,7 @@ for cname in wantfunctions: found = True if name not in basicklassmap: basicklassmap[name] = [klassname, name[klen:], cname] -elif len(basicklassmap[name]) klassname: +elif len(basicklassmap[name]) klen: basicklassmap[name] = [klassname, name[klen:], cname] # Anything which can't map to a class goes into the -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 14/14] sanitytest: remove use of string.lower()
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Call lower() directly on the string object instance, not the class Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sanitytest.py b/sanitytest.py index 50e4069..363507b 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -201,8 +201,8 @@ for name in sorted(basicklassmap): klass = virDomain func = snapshot + func -# Names should stsart with lowercase letter... -func = string.lower(func[0:1]) + func[1:] +# Names should start with lowercase letter... +func = func[0:1].lower() + func[1:] if func[0:8] == nWFilter: func = nwfilter + func[8:] -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 12/14] override: Switch virStreamSend wrapper to use libvirt_charPtrSizeUnwrap
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Instead of using a 'z#i' format string to receive byte array, use 'O' and then libvirt_charPtrSizeUnwrap. This lets us hide the Python 3 vs 2 differences in typewrappers.c Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 11 ++- typewrappers.c | 19 +++ typewrappers.h | 1 + 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 77c0af2..7e54cf6 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6770,21 +6770,22 @@ libvirt_virStreamSend(PyObject *self ATTRIBUTE_UNUSED, { PyObject *py_retval; PyObject *pyobj_stream; +PyObject *pyobj_data; virStreamPtr stream; char *data; -int datalen; +Py_ssize_t datalen; int ret; -int nbytes; -if (!PyArg_ParseTuple(args, (char *) Oz#i:virStreamRecv, - pyobj_stream, data, datalen, nbytes)) { +if (!PyArg_ParseTuple(args, (char *) OO:virStreamRecv, + pyobj_stream, pyobj_data)) { DEBUG(%s failed to parse tuple\n, __FUNCTION__); return VIR_PY_INT_FAIL; } stream = PyvirStream_Get(pyobj_stream); +libvirt_charPtrSizeUnwrap(pyobj_data, data, datalen); LIBVIRT_BEGIN_ALLOW_THREADS; -ret = virStreamSend(stream, data, nbytes); +ret = virStreamSend(stream, data, datalen); LIBVIRT_END_ALLOW_THREADS; DEBUG(StreamSend ret=%d\n, ret); diff --git a/typewrappers.c b/typewrappers.c index 7331cbd..a8cca30 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -385,6 +385,25 @@ libvirt_charPtrUnwrap(PyObject *obj, char **str) return 0; } +int libvirt_charPtrSizeUnwrap(PyObject *obj, char **str, Py_ssize_t *size) +{ +int ret; +*str = NULL; +*size = 0; +if (!obj) { +PyErr_SetString(PyExc_TypeError, unexpected type); +return -1; +} + +#if PY_MAJOR_VERSION 2 +ret = PyBytes_AsStringAndSize(obj, str, size); +#else +ret = PyString_AsStringAndSize(obj, str, size); +#endif + +return ret; +} + PyObject * libvirt_virDomainPtrWrap(virDomainPtr node) { diff --git a/typewrappers.h b/typewrappers.h index 6bb193c..ed1e4a3 100644 --- a/typewrappers.h +++ b/typewrappers.h @@ -175,6 +175,7 @@ int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val); int libvirt_doubleUnwrap(PyObject *obj, double *val); int libvirt_boolUnwrap(PyObject *obj, bool *val); int libvirt_charPtrUnwrap(PyObject *obj, char **str); +int libvirt_charPtrSizeUnwrap(PyObject *obj, char **str, Py_ssize_t *size); PyObject * libvirt_virConnectPtrWrap(virConnectPtr node); PyObject * libvirt_virDomainPtrWrap(virDomainPtr node); PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list I don't really know the format specifier but it seems reasonably correct that O is object and then you're unwrapping it which makes sense so ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python 1/2] override: Fix exception handling syntax
Python 3 no longer accepts 'except Exception, e:' as valid while Python 2.4 does not accept the new syntax 'except Exception as e:' so this uses a fall back method that is compatible with both. --- libvirt-override-virStream.py | 3 ++- libvirt-override.py | 8 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libvirt-override-virStream.py b/libvirt-override-virStream.py index 53000da..189d062 100644 --- a/libvirt-override-virStream.py +++ b/libvirt-override-virStream.py @@ -50,7 +50,8 @@ ret = handler(self, got, opaque) if type(ret) is int and ret 0: raise RuntimeError(recvAll handler returned %d % ret) -except Exception, e: +except Exception: +e = sys.exc_info()[1] try: self.abort() except: diff --git a/libvirt-override.py b/libvirt-override.py index 87996f8..63f8ecb 100644 --- a/libvirt-override.py +++ b/libvirt-override.py @@ -3,12 +3,16 @@ # # On cygwin, the DLL is called cygvirtmod.dll +import sys + try: import libvirtmod -except ImportError, lib_e: +except ImportError: +lib_e = sys.exc_info()[1] try: import cygvirtmod as libvirtmod -except ImportError, cyg_e: +except ImportError: +cyg_e = sys.exc_info()[1] if str(cyg_e).count(No module named): raise lib_e -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python 2/2] test: Invoke print(...) instead of print ...
The 'print' statement no longer exists in Python 3 and now must be called as a function. This is compatible down to Python 2.4 as we are not using any special syntax of the function. --- sanitytest.py | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sanitytest.py b/sanitytest.py index 7346d7b..bd93fe6 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -232,9 +232,9 @@ for name in sorted(finalklassmap): if func in gotfunctions[klass]: usedfunctions[%s.%s % (klass, func)] = 1 if verbose: -print PASS %s - %s.%s % (name, klass, func) +print(PASS %s - %s.%s % (name, klass, func)) else: -print FAIL %s - %s.%s (C API not mapped to python) % (name, klass, func) +print(FAIL %s - %s.%s (C API not mapped to python) % (name, klass, func)) fail = True @@ -249,11 +249,11 @@ for klass in gotfunctions: key = %s.%s % (klass, func) if not key in usedfunctions: -print FAIL %s.%s (Python API not mapped to C) % (klass, func) +print(FAIL %s.%s (Python API not mapped to C) % (klass, func)) fail = True else: if verbose: -print PASS %s.%s % (klass, func) +print(PASS %s.%s % (klass, func)) # Phase 7: Validate that all the low level C APIs have binding for name in sorted(finalklassmap): @@ -273,7 +273,7 @@ for name in sorted(finalklassmap): try: thing = getattr(libvirt.libvirtmod, pyname) except AttributeError: -print FAIL libvirt.libvirtmod.%s (C binding does not exist) % pyname +print(FAIL libvirt.libvirtmod.%s (C binding does not exist) % pyname) fail = True if fail: -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RFC] spec: move hypvisor-specific files to hypervisor driver subpackages
On Thu, Dec 5, 2013 at 9:03 AM, Jim Fehlig jfeh...@suse.com wrote: Jim Fehlig wrote: The libvirt-daemon package contains several hypervisor-specific files, directories, and script, which can be problematic when building the package with multiple hypervisor support, e.g. both QEMU and Xen. E.g. installing a QEMU+Xen enabled libvirt-daemon on a Xen-only system will result in the creation of qemu and kvm groups and a qemu user. Move the hypervisor-specific files, directories, and script to the respective hypervisor driver subpackages. Any thoughts on moving these hypervisor-specific items to their sub packages? Not related to the code or the work at all but there is a typo in the commit subject that probably should be fixed before pushing. -- Doug -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python v2] generator: Remove use of 'has_key' function
): # return the class # classes.write(return __tmp\n) -elif converter_type.has_key(ret[0]): +elif ret[0] in converter_type: # # Raise an exception # -if functions_noexcept.has_key(name): +if name in functions_noexcept: classes.write( if ret is None:return None) # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) @@ -1627,8 +1627,8 @@ def buildWrappers(module): # are several things that we can do, depending on # the contents of functions_int_*: elif is_integral_type (ret[0]): -if not functions_noexcept.has_key (name): -if functions_int_exception_test.has_key (name): +if name not in functions_noexcept: +if name in functions_int_exception_test: test = functions_int_exception_test[name] else: test = functions_int_default_test @@ -1662,15 +1662,15 @@ def buildWrappers(module): (ret, name)) # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) classes.write (return ret\n) elif is_python_noninteger_type (ret[0]): -if not functions_noexcept.has_key (name): -if functions_list_exception_test.has_key (name): +if name not in functions_noexcept: +if name in functions_list_exception_test: test = functions_list_exception_test[name] else: test = functions_list_default_test @@ -1704,7 +1704,7 @@ def buildWrappers(module): (ret, name)) # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) @@ -1712,7 +1712,7 @@ def buildWrappers(module): else: # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python 0/3] Python 3 support mixed with Dan's patches
Turns out Dan and I both started working on Python 3 support and we talked about some changes to his patchset and these are the result of that conversation. This really belongs in the middle of his patchset but he's pushed the first part already so this is on top of master. Doug Goldstein (3): setup: Drop unused exception variable generator: Support exceptions in Python 2 and 3 Update exception catching in generated code generator.py | 18 -- setup.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python 3/3] Update exception catching in generated code
Use a syntax for exception handling that works in both Python 2 and Python 3. The new syntax is 'except Exception as e:' but this does not work in older Pythons so we use the most compatible way by just catching the exception and getting the type and the exception value after the fact. --- generator.py | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/generator.py b/generator.py index 009d3e1..214abed 100755 --- a/generator.py +++ b/generator.py @@ -1822,10 +1822,12 @@ def qemuBuildWrappers(module): fd.write(try:\n) fd.write(import libvirtmod_qemu\n) -fd.write(except ImportError, lib_e:\n) +fd.write(except ImportError:\n) +fd.write(lib_e = sys.exc_info()[1]\n) fd.write(try:\n) fd.write(import cygvirtmod_qemu as libvirtmod_qemu\n) -fd.write(except ImportError, cyg_e:\n) +fd.write(except ImportError:\n) +fd.write(cyg_e = sys.exc_info()[1]\n) fd.write(if str(cyg_e).count(\No module named\):\n) fd.write(raise lib_e\n\n) @@ -1933,10 +1935,12 @@ def lxcBuildWrappers(module): fd.write(try:\n) fd.write(import libvirtmod_lxc\n) -fd.write(except ImportError, lib_e:\n) +fd.write(except ImportError:\n) +fd.write(lib_e = sys.exc_info()[1]\n) fd.write(try:\n) fd.write(import cygvirtmod_lxc as libvirtmod_lxc\n) -fd.write(except ImportError, cyg_e:\n) +fd.write(except ImportError:\n) +fd.write(cyg_e = sys.exc_info()[1]\n) fd.write(if str(cyg_e).count(\No module named\):\n) fd.write(raise lib_e\n\n) -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python 2/3] generator: Support exceptions in Python 2 and 3
Use a syntax for exception handling that works in both Python 2 and Python 3 --- generator.py | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/generator.py b/generator.py index 0717624..009d3e1 100755 --- a/generator.py +++ b/generator.py @@ -818,7 +818,8 @@ def buildStubs(module, api_xml): (parser, target) = getparser() parser.feed(data) parser.close() -except IOError, msg: +except IOError: +msg = sys.exc_info()[1] print(file, :, msg) sys.exit(1) @@ -837,7 +838,8 @@ def buildStubs(module, api_xml): (parser, target) = getparser() parser.feed(data) parser.close() -except IOError, msg: +except IOError: +msg = sys.exc_info()[1] print(file, :, msg) if not quiet: -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python 1/3] setup: Drop unused exception variable
Drop the unused exception variable in setup.py. This has the benefit of dropping syntax that is not valid with Python 3. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 561157c..24d4cf2 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ try: spawn([pkgcfg, --atleast-version=%s % MIN_LIBVIRT_LXC, libvirt]) -except DistutilsExecError,e: +except DistutilsExecError: have_libvirt_lxc=False def get_pkgconfig_data(args, mod, required=True): -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 02/15] generator: Remove string.lower(XXX) with XXX.lower()
:9] == virDomain: func = name[9:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:13] == virNetworkGet: func = name[13:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:10] == virNetwork: func = name[10:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:15] == virInterfaceGet: func = name[15:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:12] == virInterface: func = name[12:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:12] == 'virSecretGet': func = name[12:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:9] == 'virSecret': func = name[9:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:14] == 'virNWFilterGet': func = name[14:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:11] == 'virNWFilter': func = name[11:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:12] == 'virStreamNew': func = newStream elif name[0:9] == 'virStream': func = name[9:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:17] == virStoragePoolGet: func = name[17:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:14] == virStoragePool: func = name[14:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:16] == virStorageVolGet: func = name[16:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:13] == virStorageVol: func = name[13:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:13] == virNodeDevice: if name[13:16] == Get: -func = string.lower(name[16]) + name[17:] +func = name[16].lower() + name[17:] elif name[13:19] == Lookup or name[13:19] == Create: -func = string.lower(name[3]) + name[4:] +func = name[3].lower() + name[4:] else: -func = string.lower(name[13]) + name[14:] +func = name[13].lower() + name[14:] elif name[0:7] == virNode: func = name[7:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:10] == virConnect: func = name[10:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] elif name[0:3] == xml: func = name[3:] -func = string.lower(func[0:1]) + func[1:] +func = func[0:1].lower() + func[1:] else: func = name if func == iD: -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 01/15] generator: Don't use 'list' as a variable name
On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com In python3 if we use 'list' as a variable name it causes it to hide the corresponding 'list()' function from the entire function that holds the variable. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- generator.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generator.py b/generator.py index a9f98ab..a40ed11 100755 --- a/generator.py +++ b/generator.py @@ -1434,8 +1434,8 @@ def buildWrappers(module): else: classes.write(def __init__(self, _obj=None):\n) if reference_keepers.has_key(classname): -list = reference_keepers[classname] -for ref in list: +rlist = reference_keepers[classname] +for ref in rlist: classes.write(self.%s = None\n % ref[1]) if classname in [ virDomain, virNetwork, virInterface, virNodeDevice, virSecret, virStream, @@ -1589,8 +1589,8 @@ def buildWrappers(module): # tclass = classes_type[ret[0]][2] if reference_keepers.has_key(tclass): -list = reference_keepers[tclass] -for pref in list: +rlist = reference_keepers[tclass] +for pref in rlist: if pref[0] == classname: classes.write(__tmp.%s = self\n % pref[1]) -- 1.8.3.1 ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 04/15] generator: Cast iterators to a list() explicitly
in list(lxc_functions.keys()): func = nameFixup(name, 'None', None, None) (desc, ret, args, file, mod, cond) = lxc_functions[name] fd.write(def %s( % func) @@ -1993,10 +1993,10 @@ def lxcBuildWrappers(module): # # Generate enum constants # -for type,enum in lxc_enums.items(): +for type,enum in list(lxc_enums.items()): fd.write(# %s\n % type) -items = enum.items() -items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1]))) +items = list(enum.items()) +items.sort(lambda i1,i2: cmp(int(i1[1]),int(i2[1]))) for name,value in items: fd.write(%s = %s\n % (name,value)) fd.write(\n) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 05/15] generator: Remove use of 'has_key' function
( if ret is None:return None) # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) @@ -1625,8 +1625,8 @@ def buildWrappers(module): # are several things that we can do, depending on # the contents of functions_int_*: elif is_integral_type (ret[0]): -if not functions_noexcept.has_key (name): -if functions_int_exception_test.has_key (name): +if name not in functions_noexcept: +if name in functions_int_exception_test: test = functions_int_exception_test[name] else: test = functions_int_default_test @@ -1660,15 +1660,15 @@ def buildWrappers(module): (ret, name)) # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) classes.write (return ret\n) elif is_python_noninteger_type (ret[0]): -if not functions_noexcept.has_key (name): -if functions_list_exception_test.has_key (name): +if name not in functions_noexcept: +if name in functions_list_exception_test: test = functions_list_exception_test[name] else: test = functions_list_default_test @@ -1702,7 +1702,7 @@ def buildWrappers(module): (ret, name)) # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) @@ -1710,7 +1710,7 @@ def buildWrappers(module): else: # Post-processing - just before we return. -if function_post.has_key(name): +if name in function_post: classes.write(%s\n % (function_post[name])) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 09/15] setup: Fix exception catching syntax
On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com In Python3 you cannot use 'except Foo, e' you must use 'except Foo as e' instead, or just 'except Foo' if the variable isn't required. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bf222f8..ecbce1f 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ try: spawn([pkgcfg, --atleast-version=%s % MIN_LIBVIRT_LXC, libvirt]) -except DistutilsExecError,e: +except DistutilsExecError: have_libvirt_lxc=False def get_pkgconfig_data(args, mod, required=True): -- 1.8.3.1 ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 10/15] examples: Invoke print(...) instead of print ...
like option -a not recognized usage() sys.exit(2) for o, a in opts: if o in (-h, --help): -usage(sys.stdout) +usage() sys.exit() if o in (-d, --debug): global do_debug @@ -541,7 +541,7 @@ def main(): else: uri = qemu:///system -print Using uri: + uri +print(Using uri: + uri) # Run a background thread with the event loop if use_pure_python_event_loop: @@ -554,7 +554,7 @@ def main(): # Close connection on exit (to test cleanup paths) old_exitfunc = getattr(sys, 'exitfunc', None) def exit(): -print Closing + str(vc) +print(Closing + vc.getURI()) vc.close() if (old_exitfunc): old_exitfunc() sys.exitfunc = exit diff --git a/examples/topology.py b/examples/topology.py index 62effe3..191669c 100755 --- a/examples/topology.py +++ b/examples/topology.py @@ -13,13 +13,13 @@ from xml.dom import minidom try: conn = libvirt.openReadOnly(None) except libvirt.libvirtError: -print 'Failed to connect to the hypervisor' +print('Failed to connect to the hypervisor') sys.exit(1) try: capsXML = conn.getCapabilities() except libvirt.libvirtError: -print 'Failed to request capabilities' +print('Failed to request capabilities') sys.exit(1) caps = minidom.parseString(capsXML) @@ -38,8 +38,8 @@ siblingsIds = [ proc.getAttribute('siblings') for proc in cells.getElementsByTagName('cpu') if proc.getAttribute('siblings') not in siblingsIds ] -print Host topology -print NUMA nodes:, cells.getAttribute('num') -printSockets:, len(set(socketIds)) -print Cores:, len(set(siblingsIds)) -printThreads:, total_cpus +print(Host topology) +print(NUMA nodes:, cells.getAttribute('num')) +print( Sockets:, len(set(socketIds))) +print( Cores:, len(set(siblingsIds))) +print( Threads:, total_cpus) -- 1.8.3.1 I stuck a from __future__ import print_function at the top of all the examples, which you may want to do as well. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 03/15] generator: Invoke print(...) instead of print ...
extra_file = %s-override.py % module @@ -2018,7 +2018,7 @@ elif sys.argv[1] == libvirt-lxc: elif sys.argv[1] == libvirt-qemu: qemuBuildWrappers(sys.argv[1]) else: -print ERROR: unknown module %s % sys.argv[1] +print(ERROR: unknown module %s % sys.argv[1]) sys.exit(1) sys.exit(0) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list My patch actually uses myprint and provides that function which just calls the built in function when possible but provides one when not possible. Would we want to go with that approach instead? -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 03/15] generator: Invoke print(...) instead of print ...
On Tue, Dec 3, 2013 at 10:53 AM, Daniel P. Berrange berra...@redhat.com wrote: On Tue, Dec 03, 2013 at 10:44:07AM -0600, Doug Goldstein wrote: On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The 'print' method must be called as a function in python3, ie with brackets. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- generator.py | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/generator.py b/generator.py index 0c31ab2..23bae9a 100755 --- a/generator.py +++ b/generator.py @@ -48,24 +48,24 @@ class docParser(xml.sax.handler.ContentHandler): def close(self): if debug: -print close +print(close) def getmethodname(self): return self._methodname def data(self, text): if debug: -print data %s % text +print(data %s % text) self._data.append(text) def cdata(self, text): if debug: -print data %s % text +print(data %s % text) self._data.append(text) def start(self, tag, attrs): if debug: -print start %s, %s % (tag, attrs) +print(start %s, %s % (tag, attrs)) if tag == 'function': self._data = [] self.in_function = 1 @@ -123,7 +123,7 @@ class docParser(xml.sax.handler.ContentHandler): def end(self, tag): if debug: -print end %s % tag +print(end %s % tag) if tag == 'function': # fuctions come from source files, hence 'virerror.c' if self.function is not None: @@ -600,7 +600,7 @@ def print_function_wrapper(module, name, output, export, include): if module == libvirt-qemu: (desc, ret, args, file, mod, cond) = qemu_functions[name] except: -print failed to get function %s infos % name +print(failed to get function %s infos % name) return if skipped_modules.has_key(module): @@ -794,7 +794,7 @@ def buildStubs(module, api_xml): global onlyOverrides if module not in [libvirt, libvirt-qemu, libvirt-lxc]: -print ERROR: Unknown module type: %s % module +print(ERROR: Unknown module type: %s % module) return None if module == libvirt: @@ -818,13 +818,13 @@ def buildStubs(module, api_xml): (parser, target) = getparser() parser.feed(data) parser.close() -except IOError, msg: -print file, :, msg +except IOError as msg: +print(file, :, msg) sys.exit(1) n = len(funcs.keys()) if not quiet: -print Found %d functions in %s % ((n), api_xml) +print(Found %d functions in %s % ((n), api_xml)) override_api_xml = %s-override-api.xml % module py_types['pythonObject'] = ('O', pythonObject, pythonObject, pythonObject) @@ -837,13 +837,13 @@ def buildStubs(module, api_xml): (parser, target) = getparser() parser.feed(data) parser.close() -except IOError, msg: -print file, :, msg +except IOError as msg: +print(file, :, msg) if not quiet: # XXX: This is not right, same function already in @functions # will be overwritten. -print Found %d functions in %s % ((len(funcs.keys()) - n), override_api_xml) +print(Found %d functions in %s % ((len(funcs.keys()) - n), override_api_xml)) nb_wrap = 0 failed = 0 skipped = 0 @@ -883,15 +883,15 @@ def buildStubs(module, api_xml): wrapper.close() if not quiet: -print Generated %d wrapper functions % nb_wrap +print(Generated %d wrapper functions % nb_wrap) if unknown_types: -print Missing type converters: +print(Missing type converters: ) for type in unknown_types.keys(): -print %s:%d % (type, len(unknown_types[type])), +print(%s:%d % (type, len(unknown_types[type]))) for f in funcs_failed: -print ERROR: failed %s % f +print(ERROR: failed %s % f) if failed 0: return -1 @@ -1229,7 +1229,7 @@ def buildWrappers(module): global functions_noexcept if not module == libvirt: -print ERROR: Unknown module type: %s % module +print(ERROR: Unknown module type: %s % module) return None for type in classes_type.keys(): @@ -1786,7 +1786,7 @@ def qemuBuildWrappers(module): global qemu_functions if not module == libvirt-qemu: -print ERROR: only libvirt-qemu is supported +print(ERROR: only libvirt-qemu is supported) return None
Re: [libvirt] [PATCH python 08/15] generator: Sort enums and functions when generating code
On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com To assist in diff comparisons between code generated with different versions of Python, do an explicit sort of all functions and enums. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- generator.py | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/generator.py b/generator.py index af05d7c..17f00d6 100755 --- a/generator.py +++ b/generator.py @@ -865,7 +865,10 @@ def buildStubs(module, api_xml): wrapper.write(#include \typewrappers.h\\n) wrapper.write(#include \build/ + module + .h\\n\n) -for function in list(funcs.keys()): +funcnames = list(funcs.keys()) +if funcnames is not None: +funcnames.sort() +for function in funcnames: # Skip the functions which are not for the module ret = print_function_wrapper(module, function, wrapper, export, include) if ret 0: @@ -1758,7 +1761,10 @@ def buildWrappers(module): # # Generate enum constants # -for type,enum in list(enums.items()): +enumvals = list(enums.items()) +if enumvals is not None: +enumvals.sort(key=lambda x: x[0]) +for type,enum in enumvals: classes.write(# %s\n % type) items = list(enum.items()) items.sort(key=lambda i: int(i[1])) -- 1.8.3.1 ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python] Use user requested python binary for setup.py
When setup.py is kicked off with a python interpreter other than the system 'python', (e.g. python2.7 setup.py build) the build process would switch to 'python' and not use python2.7 as requested by the user. We should always respect the user requested python interpreter and use it. --- setup.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index ecbce1f..24d4cf2 100755 --- a/setup.py +++ b/setup.py @@ -122,10 +122,10 @@ class my_build(build): def run(self): apis = get_api_xml_files() -self.spawn([python, generator.py, libvirt, apis[0]]) -self.spawn([python, generator.py, libvirt-qemu, apis[1]]) +self.spawn([sys.executable, generator.py, libvirt, apis[0]]) +self.spawn([sys.executable, generator.py, libvirt-qemu, apis[1]]) if have_libvirt_lxc: -self.spawn([python, generator.py, libvirt-lxc, apis[2]]) +self.spawn([sys.executable, generator.py, libvirt-lxc, apis[2]]) build.run(self) @@ -267,7 +267,7 @@ class my_test(Command): apis = get_api_xml_files() -self.spawn([python, sanitytest.py, self.build_platlib, apis[0]]) +self.spawn([sys.executable, sanitytest.py, self.build_platlib, apis[0]]) class my_clean(clean): -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 13/15] generator: Fix exception catching syntax in generated code
On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com In Python3 you cannot use 'except Foo, e' you must use 'except Foo as e' instead, or just 'except Foo' if the variable isn't required. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- generator.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generator.py b/generator.py index 17f00d6..6fe810f 100755 --- a/generator.py +++ b/generator.py @@ -1812,10 +1812,10 @@ def qemuBuildWrappers(module): fd.write(try:\n) fd.write(import libvirtmod_qemu\n) -fd.write(except ImportError, lib_e:\n) +fd.write(except ImportError as lib_e:\n) fd.write(try:\n) fd.write(import cygvirtmod_qemu as libvirtmod_qemu\n) -fd.write(except ImportError, cyg_e:\n) +fd.write(except ImportError as cyg_e:\n) fd.write(if str(cyg_e).count(\No module named\):\n) fd.write(raise lib_e\n\n) @@ -1923,10 +1923,10 @@ def lxcBuildWrappers(module): fd.write(try:\n) fd.write(import libvirtmod_lxc\n) -fd.write(except ImportError, lib_e:\n) +fd.write(except ImportError as lib_e:\n) fd.write(try:\n) fd.write(import cygvirtmod_lxc as libvirtmod_lxc\n) -fd.write(except ImportError, cyg_e:\n) +fd.write(except ImportError as cyg_e:\n) fd.write(if str(cyg_e).count(\No module named\):\n) fd.write(raise lib_e\n\n) -- 1.8.3.1 We'll want to use sys.exc_info() for the exceptions here so older Python compat. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 06/15] generator: Update to use sort() 'key' param
On Tue, Dec 3, 2013 at 10:36 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The sort() method previously took either a compartor function or a key function. Only the latter is supported in Python3. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- generator.py | 30 -- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/generator.py b/generator.py index 8cce800..9f4b76b 100755 --- a/generator.py +++ b/generator.py @@ -1172,23 +1172,9 @@ def nameFixup(name, classe, type, file): return func -def functionCompare(info1, info2): -(index1, func1, name1, ret1, args1, file1, mod1) = info1 -(index2, func2, name2, ret2, args2, file2, mod2) = info2 -if file1 == file2: -if func1 func2: -return -1 -if func1 func2: -return 1 -if file1 == python_accessor: -return -1 -if file2 == python_accessor: -return 1 -if file1 file2: -return -1 -if file1 file2: -return 1 -return 0 +def functionSortKey(info): +(index, func, name, ret, args, filename, mod) = info +return func, filename def writeDoc(module, name, args, indent, output): if module == libvirt: @@ -1319,7 +1305,7 @@ def buildWrappers(module): if None in function_classes: flist = function_classes[None] -flist.sort(functionCompare) +flist.sort(key=functionSortKey) oldfile = for info in flist: (index, func, name, ret, args, file, mod) = info @@ -1468,7 +1454,7 @@ def buildWrappers(module): classes.write(return self._dom\n\n) flist = function_classes[classname] -flist.sort(functionCompare) +flist.sort(key=functionSortKey) oldfile = for info in flist: (index, func, name, ret, args, file, mod) = info @@ -1775,7 +1761,7 @@ def buildWrappers(module): for type,enum in list(enums.items()): classes.write(# %s\n % type) items = list(enum.items()) -items.sort(lambda i1,i2: cmp(int(i1[1]),int(i2[1]))) +items.sort(key=lambda i: int(i[1])) for name,value in items: classes.write(%s = %s\n % (name,value)) classes.write(\n) @@ -1885,7 +1871,7 @@ def qemuBuildWrappers(module): for type,enum in list(qemu_enums.items()): fd.write(# %s\n % type) items = list(enum.items()) -items.sort(lambda i1,i2: cmp(int(i1[1]),int(i2[1]))) +items.sort(key=lambda i: int(i[1])) for name,value in items: fd.write(%s = %s\n % (name,value)) fd.write(\n) @@ -1996,7 +1982,7 @@ def lxcBuildWrappers(module): for type,enum in list(lxc_enums.items()): fd.write(# %s\n % type) items = list(enum.items()) -items.sort(lambda i1,i2: cmp(int(i1[1]),int(i2[1]))) +items.sort(key=lambda i: int(i[1])) for name,value in items: fd.write(%s = %s\n % (name,value)) fd.write(\n) -- 1.8.3.1 Visually makes sense. Have not run it locally but ACK from a visual stand point. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python] Use user requested python binary for setup.py
On Tue, Dec 3, 2013 at 11:23 AM, Eric Blake ebl...@redhat.com wrote: On 12/03/2013 10:11 AM, Doug Goldstein wrote: When setup.py is kicked off with a python interpreter other than the system 'python', (e.g. python2.7 setup.py build) the build process would switch to 'python' and not use python2.7 as requested by the user. We should always respect the user requested python interpreter and use it. --- setup.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) ACK -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org Thanks. Pushed and reworded the subject to: setup: Use user requested python binary To better match the style of our commits. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix VMware support for Fusion 6 / Workstation 10
On Mon, Dec 2, 2013 at 3:54 AM, Daniel P. Berrange berra...@redhat.com wrote: On Sat, Nov 30, 2013 at 07:51:10PM -0500, Brad Ackerman wrote: This patch gets VMware Fusion 6 working, but the support for ThinPrint needs work—I’m not sure what a good way would be to represent that in libvirt; none of the existing virDomainChrType values seem to be appropriate. Can you explain a bit what ThinPrint is ? BTW, it is preferrable to attach patches as text/plain rather than a binary mode, or have them inline. Best yet is to use git send-email to submit them since that trivally gets the formatted correct for you Regards, Daniel From everything I can tell they licensed a cloud printing tech that's print first and select a printer later. So basically it allows you to print from within your VM and queue it up on the host and then select the printer from the host side. The advantage here is that you don't have to pass through all the printers to the guest or have drivers within the guest. They are expressing it as a type of serial device within their configs. I believe VMware has an interface like virtio-serial that they can generically plumb things over to the guest. Right now I'm skipping expressing the device in libvirt until I come up with a better way to model it. Based on my description above do you have any suggestions? This patch also has a number of fixes that are independent tied together. We'll also need some tests added for at least one of these changes. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] Deal with old filenames for events/error functions
On Nov 27, 2013, at 6:14 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Older libvirt has files named 'events' and 'virterror' rather than 'virevent' and 'virerror'. This is visible in the API XML files. We must look for both names to ensure we don't loose generation of methods with older versions of libvirt. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- generator.py | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/generator.py b/generator.py index 273efbd..cd857b4 100755 --- a/generator.py +++ b/generator.py @@ -113,7 +113,8 @@ class docParser(xml.sax.handler.ContentHandler): elif tag == 'enum': # enums come from header files, hence virterror.h if (attrs['file'] == libvirt or -attrs['file'] == virterror): +attrs['file'] == virterror or +attrs['file'] == virerror): enum(attrs['type'],attrs['name'],attrs['value']) elif attrs['file'] == libvirt-lxc: lxc_enum(attrs['type'],attrs['name'],attrs['value']) @@ -127,8 +128,10 @@ class docParser(xml.sax.handler.ContentHandler): # fuctions come from source files, hence 'virerror.c' if self.function is not None: if (self.function_module == libvirt or +self.function_module == event or self.function_module == virevent or -self.function_module == virerror): +self.function_module == virerror or +self.function_module == virterror): function(self.function, self.function_descr, self.function_return, self.function_args, self.function_file, self.function_module, -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Aha. This solves the issue of the missing symbols on fedora 18 for me. ACK. -- Doug -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] Improve quality of sanitytest check
On Nov 27, 2013, at 6:19 AM, Daniel P. Berrange berra...@redhat.com wrote: On Tue, Nov 26, 2013 at 01:16:24PM -0600, Doug Goldstein wrote: On Tue, Nov 26, 2013 at 12:32 PM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Validate that every public API method is mapped into the python and that every python method has a sane C API. Looks like we had the same idea and even a similar approach as well. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 309 +++--- setup.py | 35 +++ 2 files changed, 294 insertions(+), 50 deletions(-) mode change 100755 = 100644 sanitytest.py diff --git a/sanitytest.py b/sanitytest.py old mode 100755 new mode 100644 index 517054b..9e4c261 --- a/sanitytest.py +++ b/sanitytest.py @@ -1,40 +1,283 @@ #!/usr/bin/python import sys +import lxml +import lxml.etree Can we drop the explicit lxml import since we are only using etree? Then we can try lxml.etree and xml.etree as fallbacks. Do we need lxml added to the spec file for building as well? +import string +# Munge import path to insert build location for libvirt mod sys.path.insert(0, sys.argv[1]) - import libvirt +import libvirtmod I wouldn't directly import libvirtmod due to Cygwin. I'd just use libvirt.libvirtmod which is what its available as. Ah, good point. +# Phase 1: Identify all functions and enums in public API +set = tree.xpath('/api/files/file/exports[@type=function]/@symbol') +for n in set: +wantfunctions.append(n) + +set = tree.xpath('/api/files/file/exports[@type=enum]/@symbol') +for n in set: +wantenums.append(n) + Maybe its a bit ugly but I actually grabbed the typedef's as well to check the various namespaces (e.g. virConnect, virDomain) but not sure if we want that. I used the method names themselves to detect this. Could perhaps do both to have double the sanity test, but this can wait for now. Works for me. This is a giant leap forward for the tests. + +# Phase 2: Identify all classes and methods in the 'libvirt' python module +gotenums = [] +gottypes = [] +gotfunctions = { libvirt: [] } + +for name in dir(libvirt): +if name[0] == '_': +continue +thing = getattr(libvirt, name) +if type(thing) == int: +gotenums.append(name) +elif type(thing) == type: +gottypes.append(name) +gotfunctions[name] = [] +elif callable(thing): +gotfunctions[libvirt].append(name) +else: + pass Could the body of this be made into a function reused below? Well the two loops are not really the same, so don't think it would save much code. + +for klassname in gottypes: +klassobj = getattr(libvirt, klassname) +for name in dir(klassobj): +if name[0] == '_': +continue +thing = getattr(klassobj, name) +if callable(thing): +gotfunctions[klassname].append(name) +else: +pass Just some visual comments until I get a chance to really play with this. I stopped at the fixup area, which in my code is equally painful as well. You're obviously a bit more knowledgable about Python than I am because your fixups are a bit cleaner. With all the fixes I've sent so far, I'm finally able to run this sanity test against builds of the python done against historical versions, which means we're getting alot better at compat. Overall ACK with the fix for Cygwin. It's a great improvement. The lxml import might be nice too. Sorry I don't have a specific example as I'm tapping this out on a phone in the car. -- Doug -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python] Call virGetLastError from mod rather than py wrapper
All other code always calls the methods from the mod rather than using the python wrapper so this matches the state of all other callers. --- libvirt-override.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-override.py b/libvirt-override.py index ccfec48..87996f8 100644 --- a/libvirt-override.py +++ b/libvirt-override.py @@ -20,7 +20,7 @@ class libvirtError(Exception): # Never call virConnGetLastError(). # virGetLastError() is now thread local -err = virGetLastError() +err = libvirtmod.virGetLastError() if err is None: msg = defmsg else: -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python] Improve quality of sanitytest check
+if pyname == virSetErrorFunc: +pyname = virRegisterErrorHandler +elif pyname == virConnectListDomains: +pyname = virConnectListDomainsID + +# These exist in C and exist in python, but we've got +# a pure-python impl so don't check them +if name in [virStreamRecvAll, virStreamSendAll]: +continue + +try: +thing = getattr(libvirtmod, pyname) +except AttributeError: +print FAIL libvirtmod.%s (C binding does not exist) % pyname +fail = True -globals = dir(libvirt) - -# Sanity test that the generator hasn't gone wrong - -# Look for core classes -for clsname in [virConnect, -virDomain, -virDomainSnapshot, -virInterface, -virNWFilter, -virNodeDevice, -virNetwork, -virSecret, -virStoragePool, -virStorageVol, -virStream, -]: -assert(clsname in globals) -assert(object in getattr(libvirt, clsname).__bases__) - -# Constants -assert(VIR_CONNECT_RO in globals) - -# Error related bits -assert(libvirtError in globals) -assert(VIR_ERR_AUTH_FAILED in globals) -assert(virGetLastError in globals) - -# Some misc methods -assert(virInitialize in globals) -assert(virEventAddHandle in globals) -assert(virEventRegisterDefaultImpl in globals) +if fail: +sys.exit(1) +else: +sys.exit(0) diff --git a/setup.py b/setup.py index 17b4722..bf222f8 100755 --- a/setup.py +++ b/setup.py @@ -59,6 +59,20 @@ def get_pkgconfig_data(args, mod, required=True): return line +def get_api_xml_files(): +Check with pkg-config that libvirt is present and extract +the API XML file paths we need from it + +libvirt_api = get_pkgconfig_data([--variable, libvirt_api], libvirt) + +offset = libvirt_api.index(-api.xml) +libvirt_qemu_api = libvirt_api[0:offset] + -qemu-api.xml + +offset = libvirt_api.index(-api.xml) +libvirt_lxc_api = libvirt_api[0:offset] + -lxc-api.xml + +return (libvirt_api, libvirt_qemu_api, libvirt_lxc_api) + ldflags = get_pkgconfig_data([--libs-only-L], libvirt, False) cflags = get_pkgconfig_data([--cflags], libvirt, False) @@ -105,23 +119,8 @@ if have_libvirt_lxc: class my_build(build): -def get_api_xml_files(self): -Check with pkg-config that libvirt is present and extract -the API XML file paths we need from it - -libvirt_api = get_pkgconfig_data([--variable, libvirt_api], libvirt) - -offset = libvirt_api.index(-api.xml) -libvirt_qemu_api = libvirt_api[0:offset] + -qemu-api.xml - -offset = libvirt_api.index(-api.xml) -libvirt_lxc_api = libvirt_api[0:offset] + -lxc-api.xml - -return (libvirt_api, libvirt_qemu_api, libvirt_lxc_api) - - def run(self): -apis = self.get_api_xml_files() +apis = get_api_xml_files() self.spawn([python, generator.py, libvirt, apis[0]]) self.spawn([python, generator.py, libvirt-qemu, apis[1]]) @@ -266,7 +265,9 @@ class my_test(Command): Run test suite -self.spawn([python, sanitytest.py, self.build_platlib]) +apis = get_api_xml_files() + +self.spawn([python, sanitytest.py, self.build_platlib, apis[0]]) class my_clean(clean): -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Just some visual comments until I get a chance to really play with this. I stopped at the fixup area, which in my code is equally painful as well. You're obviously a bit more knowledgable about Python than I am because your fixups are a bit cleaner. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Return right error code for baselineCPU
On Sat, Nov 23, 2013 at 3:15 PM, Don Dugger n0...@n0ano.com wrote: This Python interface code is returning a -1 on errors for the `baselineCPU' API. Since this API is supposed to return a pointer the error return value should really be VIR_PY_NONE. NB: I've checked all the other APIs in this file and this is the only pointer API that is returning -1. Signed-off-by: Don Dugger donald.d.dug...@intel.com --- python/libvirt-override.c |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index c60747d..b471605 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -4471,13 +4471,13 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED, ncpus = PyList_Size(list); if (VIR_ALLOC_N_QUIET(xmlcpus, ncpus) 0) -return VIR_PY_INT_FAIL; +return VIR_PY_NONE; for (i = 0; i ncpus; i++) { xmlcpus[i] = PyString_AsString(PyList_GetItem(list, i)); if (xmlcpus[i] == NULL) { VIR_FREE(xmlcpus); -return VIR_PY_INT_FAIL; +return VIR_PY_NONE; } } } @@ -4489,13 +4489,13 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED, VIR_FREE(xmlcpus); if (base_cpu == NULL) -return VIR_PY_INT_FAIL; +return VIR_PY_NONE; pybase_cpu = PyString_FromString(base_cpu); VIR_FREE(base_cpu); if (pybase_cpu == NULL) -return VIR_PY_INT_FAIL; +return VIR_PY_NONE; return pybase_cpu; } -- 1.7.10.4 ACK. This is correct. But it obviously changes our API so I'm not really sure how we should handle this, (e.g. document the API as is as note that its broken or fix it). -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python PATCHv2 43/44] virConnectGetCPUModelNames API appeared in 1.1.3
On Tue, Nov 19, 2013 at 1:36 PM, Doug Goldstein car...@cardoe.com wrote: --- libvirt-override.c | 4 1 file changed, 4 insertions(+) This change must be dropped with latest libvirt.git master. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python PATCHv2 43/44] virConnectGetCPUModelNames API appeared in 1.1.3
On Thu, Nov 21, 2013 at 8:14 AM, Doug Goldstein car...@cardoe.com wrote: On Tue, Nov 19, 2013 at 1:36 PM, Doug Goldstein car...@cardoe.com wrote: --- libvirt-override.c | 4 1 file changed, 4 insertions(+) This change must be dropped with latest libvirt.git master. Nvm. Ignore this statement. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] python: add virConnectGetCPUModelNames to skip_impl
On Tue, Nov 19, 2013 at 4:17 PM, Doug Goldstein car...@cardoe.com wrote: In commit de51dc9c9, we removed virConnectGetCPUModelNames from skip_impl but without this the module will always generate a symbol for libvirt_virConnectGetCPUModelNames which we don't always want. CC: Giuseppe Scrivano gscri...@redhat.com --- I don't really understand the generator enough to know why this was removed but without this change the module will always generate the symbol. Maybe someone more knowledgable with the code can explain? I've CC'd the original author as well. --- python/generator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/generator.py b/python/generator.py index 87ecf5a..99bf965 100755 --- a/python/generator.py +++ b/python/generator.py @@ -450,6 +450,7 @@ skip_impl = ( 'virNodeGetCPUMap', 'virDomainMigrate3', 'virDomainMigrateToURI3', +'virConnectGetCPUModelNames', ) lxc_skip_impl = ( -- 1.8.3.2 I'm going to personally NACK my own patch. It looks like another change will have to be made at the same time. The API is appearing as libvirt.getCPUModelNames() instead of libvirt.virConnect.getCPUModelNames() with this change due to some other code that's moving it. So I'll just fix both issues in 1 commit. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] python: Move examples to python/ for repo breakout
In anticipation of the python bindings moving to their own repo and in an effort to preserve history, move the examples within the python/ directory. --- Makefile.am| 3 +-- configure.ac | 2 +- {examples/python = python/examples}/Makefile.am | 1 + {examples/python = python/examples}/README| 0 {examples/python = python/examples}/consolecallback.py| 0 {examples/python = python/examples}/dominfo.py| 0 {examples/python = python/examples}/domrestore.py | 0 {examples/python = python/examples}/domsave.py| 0 {examples/python = python/examples}/domstart.py | 0 {examples/python = python/examples}/esxlist.py| 0 .../domain-events/events-python = python/examples}/event-test.py | 0 {examples/python = python/examples}/topology.py | 0 12 files changed, 3 insertions(+), 3 deletions(-) rename {examples/python = python/examples}/Makefile.am (97%) rename {examples/python = python/examples}/README (100%) rename {examples/python = python/examples}/consolecallback.py (100%) rename {examples/python = python/examples}/dominfo.py (100%) rename {examples/python = python/examples}/domrestore.py (100%) rename {examples/python = python/examples}/domsave.py (100%) rename {examples/python = python/examples}/domstart.py (100%) rename {examples/python = python/examples}/esxlist.py (100%) rename {examples/domain-events/events-python = python/examples}/event-test.py (100%) rename {examples/python = python/examples}/topology.py (100%) diff --git a/Makefile.am b/Makefile.am index 192a378..b84507d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ GENHTML = genhtml SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \ python tests po examples/domain-events/events-c examples/hellolibvirt \ - examples/dominfo examples/domsuspend examples/python examples/apparmor \ + examples/dominfo examples/domsuspend python/examples examples/apparmor \ examples/xml/nwfilter examples/openauth examples/systemtap ACLOCAL_AMFLAGS = -I m4 @@ -40,7 +40,6 @@ EXTRA_DIST = \ Makefile.nonreentrant \ autogen.sh \ cfg.mk \ - examples/domain-events/events-python \ run.in \ AUTHORS.in \ $(XML_EXAMPLES) diff --git a/configure.ac b/configure.ac index 6003871..05a0394 100644 --- a/configure.ac +++ b/configure.ac @@ -2614,6 +2614,7 @@ AC_CONFIG_FILES([\ po/Makefile.in \ include/libvirt/Makefile include/libvirt/libvirt.h \ python/Makefile \ +python/examples/Makefile \ daemon/Makefile \ tools/Makefile \ tests/Makefile \ @@ -2622,7 +2623,6 @@ AC_CONFIG_FILES([\ examples/domsuspend/Makefile \ examples/dominfo/Makefile \ examples/openauth/Makefile \ -examples/python/Makefile \ examples/hellolibvirt/Makefile \ examples/systemtap/Makefile \ examples/xml/nwfilter/Makefile]) diff --git a/examples/python/Makefile.am b/python/examples/Makefile.am similarity index 97% rename from examples/python/Makefile.am rename to python/examples/Makefile.am index 7823c20..0e197d0 100644 --- a/examples/python/Makefile.am +++ b/python/examples/Makefile.am @@ -18,4 +18,5 @@ EXTRA_DIST= \ README \ consolecallback.py \ topology.py \ + event-test.py \ dominfo.py domrestore.py domsave.py domstart.py esxlist.py diff --git a/examples/python/README b/python/examples/README similarity index 100% rename from examples/python/README rename to python/examples/README diff --git a/examples/python/consolecallback.py b/python/examples/consolecallback.py similarity index 100% rename from examples/python/consolecallback.py rename to python/examples/consolecallback.py diff --git a/examples/python/dominfo.py b/python/examples/dominfo.py similarity index 100% rename from examples/python/dominfo.py rename to python/examples/dominfo.py diff --git a/examples/python/domrestore.py b/python/examples/domrestore.py similarity index 100% rename from examples/python/domrestore.py rename to python/examples/domrestore.py diff --git a/examples/python/domsave.py b/python/examples/domsave.py similarity index 100% rename from examples/python/domsave.py rename to python/examples/domsave.py diff --git a/examples/python/domstart.py b/python/examples/domstart.py similarity index 100% rename from examples/python/domstart.py rename to python/examples/domstart.py diff --git a/examples/python/esxlist.py b/python/examples/esxlist.py similarity index 100% rename from examples/python/esxlist.py rename to
Re: [libvirt] [libvirt-python 09/18] virNodeGetCPUMap API not added until 1.0.0
On Tue, Nov 19, 2013 at 9:19 AM, Eric Blake ebl...@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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python 10/18] virDomainMigrate3 and virDomainMigrateToURI3 not added until 1.1.0
On Tue, Nov 19, 2013 at 9:35 AM, Eric Blake ebl...@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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Add missing break to switch-case block
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. --- python/libvirt-override.c | 1 + 1 file changed, 1 insertion(+) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 2e58bf9..747c877 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -6399,6 +6399,7 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, break; case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback); +break; case VIR_DOMAIN_EVENT_ID_LAST: break; -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Add missing break to switch-case block
On Tue, Nov 19, 2013 at 10:39 AM, Martin Kletzander mklet...@redhat.com wrote: On Tue, Nov 19, 2013 at 10:32:01AM -0600, 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. --- python/libvirt-override.c | 1 + 1 file changed, 1 insertion(+) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 2e58bf9..747c877 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -6399,6 +6399,7 @@ libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self, break; case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED: cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback); +break; case VIR_DOMAIN_EVENT_ID_LAST: break; -- 1.8.3.2 ACK, Martin Thanks. Pushed. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 05/44] Add decl of MIN macro
From: Daniel P. Berrange berra...@redhat.com Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-utils.h | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-utils.h b/libvirt-utils.h index bec7346..aed64e6 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -24,4 +24,8 @@ # define STREQ(a,b) (strcmp(a,b) == 0) +# ifndef MIN +# define MIN(a,b) (((a) (b)) ? (a) : (b)) +# endif + #endif /* __LIBVIRT_UTILS_H__ */ -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 13/44] Import some virTypedParams* APIs from libvirt
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 | 45 + libvirt-utils.h | 6 ++ 2 files changed, 51 insertions(+) diff --git a/libvirt-utils.c b/libvirt-utils.c index 6866bf1..3947596 100644 --- a/libvirt-utils.c +++ b/libvirt-utils.c @@ -134,3 +134,48 @@ int virFileClose(int *fdptr) return rc; } + +#if ! LIBVIR_CHECK_VERSION(1, 0, 2) +/** + * 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); +} +#endif /* ! LIBVIR_CHECK_VERSION(1, 0, 2) */ diff --git a/libvirt-utils.h b/libvirt-utils.h index 447e81f..0517f9c 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 08/44] Import code annotation macros from libvirt
From: Daniel P. Berrange berra...@redhat.com Import ATTRIBUTE_RETURN_CHECK, ATTRIBUTE_UNUSED ATTRIBUTE_NONNULL macros Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-utils.h | 52 1 file changed, 52 insertions(+) diff --git a/libvirt-utils.h b/libvirt-utils.h index 961cc20..f608eb4 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -54,4 +54,56 @@ # define ignore_value(x) ((void) (x)) # endif +# ifdef __GNUC__ +/** + * ATTRIBUTE_UNUSED: + * + * Macro to flag consciously unused parameters to functions + */ +# ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED __attribute__((__unused__)) +# endif + +/* gcc's handling of attribute nonnull is less than stellar - it does + * NOT improve diagnostics, and merely allows gcc to optimize away + * null code checks even when the caller manages to pass null in spite + * of the attribute, leading to weird crashes. Coverity, on the other + * hand, knows how to do better static analysis based on knowing + * whether a parameter is nonnull. Make this attribute conditional + * based on whether we are compiling for real or for analysis, while + * still requiring correct gcc syntax when it is turned off. See also + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308 */ +# ifndef ATTRIBUTE_NONNULL +# if __GNUC_PREREQ (3, 3) +#if STATIC_ANALYSIS +# define ATTRIBUTE_NONNULL(m) __attribute__((__nonnull__(m))) +#else +# define ATTRIBUTE_NONNULL(m) __attribute__(()) +#endif +# else +#define ATTRIBUTE_NONNULL(m) +# endif +# endif + +# ifndef ATTRIBUTE_RETURN_CHECK +# if __GNUC_PREREQ (3, 4) +#define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__)) +# else +#define ATTRIBUTE_RETURN_CHECK +# endif +# endif + +# else +# ifndef ATTRIBUTE_UNUSED +# define ATTRIBUTE_UNUSED +# endif +# ifndef ATTRIBUTE_NONNULL +# define ATTRIBUTE_NONNULL(m) +# endif +# ifndef ATTRIBUTE_RETURN_CHECK +# define ATTRIBUTE_RETURN_CHECK +# endif +# endif /* __GNUC__ */ + + #endif /* __LIBVIRT_UTILS_H__ */ -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 02/44] Update generator for new code layout
From: Daniel P. Berrange berra...@redhat.com Change the generator.py to - Take XML API file names on command line - Generate data in build/ directory instead of cwd --- generator.py | 69 ++-- 1 file changed, 25 insertions(+), 44 deletions(-) diff --git a/generator.py b/generator.py index 87ecf5a..83efe32 100755 --- a/generator.py +++ b/generator.py @@ -17,17 +17,10 @@ import re quiet=True -if __name__ == __main__: -# launched as a script -srcPref = os.path.dirname(sys.argv[0]) -if len(sys.argv) 1: -python = sys.argv[1] -else: -print Python binary not specified -sys.exit(1) -else: -# imported -srcPref = os.path.dirname(__file__) +coreapifile = sys.argv[1] +lxcapifile = sys.argv[2] +qemuapifile = sys.argv[3] + ### # @@ -777,7 +770,7 @@ def print_function_wrapper(module, name, output, export, include): return 0 return 1 -def buildStubs(module): +def buildStubs(module, api_xml): global py_types global py_return_types global unknown_types @@ -799,26 +792,16 @@ def buildStubs(module): funcs_failed = qemu_functions_failed funcs_skipped = qemu_functions_skipped -api_xml = %s-api.xml % module - try: -f = open(os.path.join(srcPref,api_xml)) +f = open(api_xml) data = f.read() f.close() (parser, target) = getparser() parser.feed(data) parser.close() except IOError, msg: -try: -f = open(os.path.join(srcPref,..,docs,api_xml)) -data = f.read() -f.close() -(parser, target) = getparser() -parser.feed(data) -parser.close() -except IOError, msg: -print file, :, msg -sys.exit(1) +print file, :, msg +sys.exit(1) n = len(funcs.keys()) if not quiet: @@ -828,7 +811,7 @@ def buildStubs(module): py_types['pythonObject'] = ('O', pythonObject, pythonObject, pythonObject) try: -f = open(os.path.join(srcPref, override_api_xml)) +f = open(override_api_xml) data = f.read() f.close() (parser, target) = getparser() @@ -845,9 +828,9 @@ def buildStubs(module): failed = 0 skipped = 0 -header_file = %s.h % module -export_file = %s-export.c % module -wrapper_file = %s.c % module +header_file = build/%s.h % module +export_file = build/%s-export.c % module +wrapper_file = build/%s.c % module include = open(header_file, w) include.write(/* Generated */\n\n) @@ -857,11 +840,10 @@ def buildStubs(module): wrapper = open(wrapper_file, w) wrapper.write(/* Generated by generator.py */\n\n) -wrapper.write(#include config.h\n) wrapper.write(#include Python.h\n) wrapper.write(#include libvirt/ + module + .h\n) wrapper.write(#include \typewrappers.h\\n) -wrapper.write(#include \ + module + .h\\n\n) +wrapper.write(#include \build/ + module + .h\\n\n) for function in funcs.keys(): # Skip the functions which are not for the module @@ -1283,15 +1265,14 @@ def buildWrappers(module): info = (0, func, name, ret, args, file, mod) function_classes['None'].append(info) -classes_file = %s.py % module -extra_file = os.path.join(srcPref, %s-override.py % module) +classes_file = build/%s.py % module +extra_file = %s-override.py % module extra = None classes = open(classes_file, w) if os.path.exists(extra_file): extra = open(extra_file, r) -classes.write(#! + python + -i\n) classes.write(#\n) classes.write(# WARNING WARNING WARNING WARNING\n) classes.write(#\n) @@ -1716,7 +1697,7 @@ def buildWrappers(module): classes.write(\n) # Append classname.py to class def, iff it exists try: -extra = open(os.path.join(srcPref,libvirt-override- + classname + .py), r) +extra = open(libvirt-override- + classname + .py, r) classes.write (#\n) classes.write (# %s methods from %s.py (hand coded)\n % (classname,classname)) classes.write (#\n) @@ -1746,14 +1727,13 @@ def qemuBuildWrappers(module): print ERROR: only libvirt-qemu is supported return None -extra_file = os.path.join(srcPref, %s-override.py % module) +extra_file = %s-override.py % module extra = None -fd = open(libvirt_qemu.py, w) +fd = open(build/libvirt_qemu.py, w) if os.path.exists(extra_file): extra = open(extra_file, r) -fd.write(#! + python + -i\n) fd.write(#\n) fd.write(# WARNING WARNING WARNING WARNING\n) fd.write(#\n) @@ -1858,14 +1838,13 @@ def lxcBuildWrappers(module): print ERROR: only libvirt-lxc
[libvirt] [libvirt-python PATCHv2 11/44] Import VIR_FORCE_CLOSE macro from libvirt
From: Daniel P. Berrange berra...@redhat.com Import the macro for safely closing file descriptors Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-utils.c | 19 +++ libvirt-utils.h | 7 +++ 2 files changed, 26 insertions(+) diff --git a/libvirt-utils.c b/libvirt-utils.c index 873552c..6866bf1 100644 --- a/libvirt-utils.c +++ b/libvirt-utils.c @@ -115,3 +115,22 @@ void virFree(void *ptrptr) *(void**)ptrptr = NULL; errno = save_errno; } + + +int virFileClose(int *fdptr) +{ +int saved_errno = 0; +int rc = 0; + +saved_errno = errno; + +if (*fdptr 0) +return 0; + +rc = close(*fdptr); +*fdptr = -1; + +errno = saved_errno; + +return rc; +} diff --git a/libvirt-utils.h b/libvirt-utils.h index 30380a3..795f678 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -183,4 +183,11 @@ void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1); # define VIR_FREE(ptr) virFree((void *) (ptr)) # endif +/* Don't call this directly - use the macro below */ +int virFileClose(int *fdptr) +ATTRIBUTE_RETURN_CHECK; + +# define VIR_FORCE_CLOSE(FD) \ +ignore_value(virFileClose((FD))) + #endif /* __LIBVIRT_UTILS_H__ */ -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 14/44] Add build/ to python module path for sanitytest.py
From: Daniel P. Berrange berra...@redhat.com The generated libvirt.py modules will be in the build/ directory, so santitytest.py must use that directory. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 4 1 file changed, 4 insertions(+) diff --git a/sanitytest.py b/sanitytest.py index ace6792..517054b 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -1,5 +1,9 @@ #!/usr/bin/python +import sys + +sys.path.insert(0, sys.argv[1]) + import libvirt globals = dir(libvirt) -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 09/44] Import VIR_ALLOC / VIR_ALLOC_N / VIR_REALLOC_N functions
From: Daniel P. Berrange berra...@redhat.com Import the libvirt memory allocation functions, stripping the OOM testing and error reporting pieces. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-lxc-override.c | 1 + libvirt-override.c | 106 +-- libvirt-qemu-override.c | 1 + libvirt-utils.c | 117 libvirt-utils.h | 77 +++ typewrappers.c | 1 + 6 files changed, 250 insertions(+), 53 deletions(-) create mode 100644 libvirt-utils.c diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c index 9b8cd4c..03b00b0 100644 --- a/libvirt-lxc-override.c +++ b/libvirt-lxc-override.c @@ -18,6 +18,7 @@ #include libvirt/libvirt-lxc.h #include libvirt/virterror.h #include typewrappers.h +#include libvirt-utils.h #include build/libvirt-lxc.h #ifndef __CYGWIN__ diff --git a/libvirt-override.c b/libvirt-override.c index 860d3ab..d8bbbab 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -166,7 +166,7 @@ setPyVirTypedParameter(PyObject *info, return NULL; } -if (VIR_ALLOC_N_QUIET(ret, size) 0) { +if (VIR_ALLOC_N(ret, size) 0) { PyErr_NoMemory(); return NULL; } @@ -506,7 +506,7 @@ libvirt_virDomainBlockStatsFlags(PyObject *self ATTRIBUTE_UNUSED, if (!nparams) return PyDict_New(); -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -573,7 +573,7 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) sumparams = nparams * MIN(ncpus, 128); -if (VIR_ALLOC_N_QUIET(params, sumparams) 0) { +if (VIR_ALLOC_N(params, sumparams) 0) { error = PyErr_NoMemory(); goto error; } @@ -625,7 +625,7 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) if (nparams) { sumparams = nparams; -if (VIR_ALLOC_N_QUIET(params, nparams) 0) { +if (VIR_ALLOC_N(params, nparams) 0) { error = PyErr_NoMemory(); goto error; } @@ -806,7 +806,7 @@ libvirt_virDomainGetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED, if (!nparams) return PyDict_New(); -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -854,7 +854,7 @@ libvirt_virDomainGetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED, if (!nparams) return PyDict_New(); -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -914,7 +914,7 @@ libvirt_virDomainSetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED, return NULL; } -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -990,7 +990,7 @@ libvirt_virDomainSetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED, return NULL; } -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -1064,7 +1064,7 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED, return NULL; } -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -1124,7 +1124,7 @@ libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED, if (!nparams) return PyDict_New(); -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -1184,7 +1184,7 @@ libvirt_virDomainSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED, return NULL; } -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -1244,7 +1244,7 @@ libvirt_virDomainGetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED, if (!nparams) return PyDict_New(); -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -1304,7 +1304,7 @@ libvirt_virDomainSetNumaParameters(PyObject *self ATTRIBUTE_UNUSED, return NULL; } -if (VIR_ALLOC_N_QUIET(params, nparams) 0) +if (VIR_ALLOC_N(params, nparams) 0) return PyErr_NoMemory(); LIBVIRT_BEGIN_ALLOW_THREADS; @@ -1364,7 +1364,7 @@
[libvirt] [libvirt-python PATCHv2 19/44] Create array of modules to be built
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 ffb8e1d..449894b 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 12/44] Import LIBVIR_CHECK_VERSION macro from libvirt
Add LIBVIR_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.2.0 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 795f678..447e81f 100644 --- a/libvirt-utils.h +++ b/libvirt-utils.h @@ -28,6 +28,16 @@ # define MIN(a,b) (((a) (b)) ? (a) : (b)) # endif +/** + * 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) * 100 + (minor) * 1000 + (micro) = LIBVIR_VERSION_NUMBER) +# endif + /* Return 1 if an array of N objects, each of size S, cannot exist due to size arithmetic overflow. S must be positive and N must be nonnegative. This is a macro, not a function, so that it -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 18/44] Break generator.py to be called per module
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 a28b052..ffb8e1d 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 03/44] Update header file includes
From: Daniel P. Berrange berra...@redhat.com We're no longer using automake, so config.h files are not required. Also remove of all libvirt internal util header files. Reference generated header files in build/ subdir. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-lxc-override.c | 8 ++-- libvirt-override.c | 11 ++- libvirt-qemu-override.c | 7 ++- typewrappers.c | 4 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c index f76ff4b..9b8cd4c 100644 --- a/libvirt-lxc-override.c +++ b/libvirt-lxc-override.c @@ -9,8 +9,6 @@ * Daniel Veillard veill...@redhat.com */ -#include config.h - /* Horrible kludge to work around even more horrible name-space pollution via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ @@ -20,9 +18,7 @@ #include libvirt/libvirt-lxc.h #include libvirt/virterror.h #include typewrappers.h -#include libvirt-lxc.h -#include viralloc.h -#include virfile.h +#include build/libvirt-lxc.h #ifndef __CYGWIN__ extern void initlibvirtmod_lxc(void); @@ -108,7 +104,7 @@ error: * * / static PyMethodDef libvirtLxcMethods[] = { -#include libvirt-lxc-export.c +#include build/libvirt-lxc-export.c {(char *) virDomainLxcOpenNamespace, libvirt_lxc_virDomainLxcOpenNamespace, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; diff --git a/libvirt-override.c b/libvirt-override.c index 2e58bf9..10e0daf 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -9,8 +9,6 @@ * Daniel Veillard veill...@redhat.com */ -#include config.h - /* Horrible kludge to work around even more horrible name-space pollution via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ @@ -23,12 +21,7 @@ #include libvirt/libvirt.h #include libvirt/virterror.h #include typewrappers.h -#include libvirt.h -#include viralloc.h -#include virtypedparam.h -#include ignore-value.h -#include virutil.h -#include virstring.h +#include build/libvirt.h #ifndef __CYGWIN__ extern void initlibvirtmod(void); @@ -7224,7 +7217,7 @@ cleanup: * * / static PyMethodDef libvirtMethods[] = { -#include libvirt-export.c +#include build/libvirt-export.c {(char *) virGetVersion, libvirt_virGetVersion, METH_VARARGS, NULL}, {(char *) virConnectGetVersion, libvirt_virConnectGetVersion, METH_VARARGS, NULL}, {(char *) virConnectGetCPUModelNames, libvirt_virConnectGetCPUModelNames, METH_VARARGS, NULL}, diff --git a/libvirt-qemu-override.c b/libvirt-qemu-override.c index 6249031..4008b10 100644 --- a/libvirt-qemu-override.c +++ b/libvirt-qemu-override.c @@ -9,8 +9,6 @@ * Daniel Veillard veill...@redhat.com */ -#include config.h - /* Horrible kludge to work around even more horrible name-space pollution via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ @@ -20,8 +18,7 @@ #include libvirt/libvirt-qemu.h #include libvirt/virterror.h #include typewrappers.h -#include libvirt-qemu.h -#include viralloc.h +#include build/libvirt-qemu.h #ifndef __CYGWIN__ extern void initlibvirtmod_qemu(void); @@ -119,7 +116,7 @@ libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, PyObject * * / static PyMethodDef libvirtQemuMethods[] = { -#include libvirt-qemu-export.c +#include build/libvirt-qemu-export.c {(char *) virDomainQemuMonitorCommand, libvirt_qemu_virDomainQemuMonitorCommand, METH_VARARGS, NULL}, {(char *) virDomainQemuAgentCommand, libvirt_qemu_virDomainQemuAgentCommand, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} diff --git a/typewrappers.c b/typewrappers.c index 9ba8790..ba02d6a 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -7,8 +7,6 @@ * Daniel Veillard veill...@redhat.com */ -#include config.h - /* Horrible kludge to work around even more horrible name-space pollution *via Python.h. That file includes /usr/include/python2.5/pyconfig*.h, * which has over 180 autoconf-style HAVE_* definitions. Shame on them. */ @@ -16,8 +14,6 @@ #include typewrappers.h -#include viralloc.h - #ifndef Py_CAPSULE_H typedef void(*PyCapsule_Destructor)(void *, void *); #endif -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 20/44] Don't build LXC module when building less than 1.0.2
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 449894b..059a772 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 15/44] Add execute permission for sanitytest.py
From: Daniel P. Berrange berra...@redhat.com Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 = 100755 sanitytest.py diff --git a/sanitytest.py b/sanitytest.py old mode 100644 new mode 100755 -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 32/44] virConnectListAll* APIs appeared in 0.10.2
--- libvirt-override.c | 24 1 file changed, 24 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 3cc6f22..3602cd9 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -3032,6 +3032,7 @@ libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +#if LIBVIR_CHECK_VERSION(0, 10, 2) static PyObject * libvirt_virConnectListAllNetworks(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -3078,6 +3079,7 @@ cleanup: VIR_FREE(nets); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ static PyObject * @@ -3473,6 +3475,7 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +#if LIBVIR_CHECK_VERSION(0, 10, 2) static PyObject * libvirt_virConnectListAllStoragePools(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -3519,6 +3522,7 @@ cleanup: VIR_FREE(pools); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ static PyObject * libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED, @@ -3827,6 +3831,7 @@ libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +#if LIBVIR_CHECK_VERSION(0, 10, 2) static PyObject * libvirt_virConnectListAllNodeDevices(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -3873,6 +3878,7 @@ cleanup: VIR_FREE(devices); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ static PyObject * libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED, @@ -4038,6 +4044,7 @@ libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +#if LIBVIR_CHECK_VERSION(0, 10, 2) static PyObject * libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -4084,6 +4091,7 @@ cleanup: VIR_FREE(secrets); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ static PyObject * libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED, @@ -4258,6 +4266,7 @@ libvirt_virConnectListNWFilters(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +#if LIBVIR_CHECK_VERSION(0, 10, 2) static PyObject * libvirt_virConnectListAllNWFilters(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -4304,6 +4313,7 @@ cleanup: VIR_FREE(filters); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ static PyObject * libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED, @@ -4414,6 +4424,7 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED, } +#if LIBVIR_CHECK_VERSION(0, 10, 2) static PyObject * libvirt_virConnectListAllInterfaces(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -4460,6 +4471,7 @@ cleanup: VIR_FREE(ifaces); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ static PyObject * libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED, @@ -7279,7 +7291,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) virConnGetLastError, libvirt_virConnGetLastError, METH_VARARGS, NULL}, {(char *) virConnectListNetworks, libvirt_virConnectListNetworks, METH_VARARGS, NULL}, {(char *) virConnectListDefinedNetworks, libvirt_virConnectListDefinedNetworks, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 10, 2) {(char *) virConnectListAllNetworks, libvirt_virConnectListAllNetworks, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ {(char *) virNetworkGetUUID, libvirt_virNetworkGetUUID, METH_VARARGS, NULL}, {(char *) virNetworkGetUUIDString, libvirt_virNetworkGetUUIDString, METH_VARARGS, NULL}, {(char *) virNetworkLookupByUUID, libvirt_virNetworkLookupByUUID, METH_VARARGS, NULL}, @@ -7320,7 +7334,9 @@ static PyMethodDef libvirtMethods[] = { #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ {(char *) virConnectListStoragePools, libvirt_virConnectListStoragePools, METH_VARARGS, NULL}, {(char *) virConnectListDefinedStoragePools, libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 10, 2) {(char *) virConnectListAllStoragePools, libvirt_virConnectListAllStoragePools, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ {(char *) virStoragePoolGetAutostart, libvirt_virStoragePoolGetAutostart, METH_VARARGS, NULL}, {(char *) virStoragePoolListVolumes, libvirt_virStoragePoolListVolumes, METH_VARARGS, NULL}, {(char *) virStoragePoolListAllVolumes, libvirt_virStoragePoolListAllVolumes, METH_VARARGS, NULL}, @@ -7335,23 +7351,31 @@ static PyMethodDef libvirtMethods[] = { {(char *) virEventInvokeHandleCallback, libvirt_virEventInvokeHandleCallback, METH_VARARGS, NULL}, {(char *)
[libvirt] [libvirt-python PATCHv2 41/44] virDomainCreateXMLWithFiles and virDomainCreateWithFiles APIs appeared in 1.1.1
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 6bd5138..32d1a4a 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -7176,6 +7176,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; @@ -7265,6 +7266,7 @@ cleanup: VIR_FREE(files); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(1, 1, 1) */ / @@ -7439,8 +7441,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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 40/44] virDomainMigrate3 and virDomainMigrateToURI3 appeared in 1.1.0
The functions virDomainMigrate3 and virDomainMigrateToURI3 were not added to libvirt until v1.1.0. --- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 6c5d55f..6bd5138 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6843,6 +6843,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) @@ -6904,6 +6905,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, @@ -7421,8 +7423,10 @@ static PyMethodDef libvirtMethods[] = { {(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}, {(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}, #if LIBVIR_CHECK_VERSION(0, 9, 10) -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 29/44] virDomainSnapshotListAllChildren API appeared in 0.9.13
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index dc1297e..90e6451 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2656,6 +2656,7 @@ cleanup: } #endif /* LIBVIR_CHECK_VERSION(0, 9, 7) */ +#if LIBVIR_CHECK_VERSION(0, 9, 13) static PyObject * libvirt_virDomainSnapshotListAllChildren(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -2701,6 +2702,7 @@ cleanup: VIR_FREE(snaps); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */ static PyObject * libvirt_virDomainRevertToSnapshot(PyObject *self ATTRIBUTE_UNUSED, @@ -7352,7 +7354,9 @@ static PyMethodDef libvirtMethods[] = { #if LIBVIR_CHECK_VERSION(0, 9, 7) {(char *) virDomainSnapshotListChildrenNames, libvirt_virDomainSnapshotListChildrenNames, METH_VARARGS, NULL}, #endif /* LIBVIR_CHECK_VERSION(0, 9, 7) */ +#if LIBVIR_CHECK_VERSION(0, 9, 13) {(char *) virDomainSnapshotListAllChildren, libvirt_virDomainSnapshotListAllChildren, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */ {(char *) virDomainRevertToSnapshot, libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL}, {(char *) virDomainGetBlockJobInfo, libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL}, #if LIBVIR_CHECK_VERSION(0, 9, 8) -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 26/44] virDomainGetDiskErrors API appeared in 0.9.10
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index dbf45cc..cccfac5 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -4766,6 +4766,7 @@ cleanup: } #endif /* LIBVIR_CHECK_VERSION(0, 9, 8) */ +#if LIBVIR_CHECK_VERSION(0, 9, 10) static PyObject * libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -4818,6 +4819,7 @@ cleanup: } return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 9, 10) */ /*** * Helper functions to avoid importing modules @@ -7356,7 +7358,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) virDomainMigrateToURI3, libvirt_virDomainMigrateToURI3, METH_VARARGS, NULL}, {(char *) virDomainBlockPeek, libvirt_virDomainBlockPeek, METH_VARARGS, NULL}, {(char *) virDomainMemoryPeek, libvirt_virDomainMemoryPeek, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 9, 10) {(char *) virDomainGetDiskErrors, libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 9, 10) */ {(char *) virNodeGetMemoryParameters, libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL}, {(char *) virNodeSetMemoryParameters, libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL}, {(char *) virNodeGetCPUMap, libvirt_virNodeGetCPUMap, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 36/44] virNodeGetCPUMap API appeared in 1.0.0
--- libvirt-override.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libvirt-override.c b/libvirt-override.c index 7e167ee..951ad29 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -419,12 +419,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 */ @@ -7095,6 +7097,7 @@ cleanup: } #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ +#if LIBVIR_CHECK_VERSION(1, 0, 0) static PyObject * libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -7163,6 +7166,7 @@ error: ret = NULL; goto cleanup; } +#endif /* LIBVIR_CHECK_VERSION(1, 0, 0) */ static PyObject * @@ -7419,7 +7423,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) virNodeGetMemoryParameters, libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL}, {(char *) virNodeSetMemoryParameters, libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL}, #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ +#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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 33/44] virNode{Get, Set}MemoryParameters API appeared in 0.10.2
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 3602cd9..4237cb7 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6967,6 +6967,7 @@ cleanup: return py_retval; } +#if LIBVIR_CHECK_VERSION(0, 10, 2) static PyObject * libvirt_virNodeSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -7086,6 +7087,7 @@ cleanup: virTypedParamsFree(params, nparams); return ret; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ static PyObject * libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED, @@ -7405,8 +7407,10 @@ static PyMethodDef libvirtMethods[] = { #if LIBVIR_CHECK_VERSION(0, 9, 10) {(char *) virDomainGetDiskErrors, libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL}, #endif /* LIBVIR_CHECK_VERSION(0, 9, 10) */ +#if LIBVIR_CHECK_VERSION(0, 10, 2) {(char *) virNodeGetMemoryParameters, libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL}, {(char *) virNodeSetMemoryParameters, libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ {(char *) virNodeGetCPUMap, libvirt_virNodeGetCPUMap, METH_VARARGS, NULL}, {(char *) virDomainCreateXMLWithFiles, libvirt_virDomainCreateXMLWithFiles, METH_VARARGS, NULL}, {(char *) virDomainCreateWithFiles, libvirt_virDomainCreateWithFiles, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 43/44] virConnectGetCPUModelNames API appeared in 1.1.3
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index bcc2499..0464f49 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2283,6 +2283,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) @@ -2334,6 +2335,7 @@ error: rv = VIR_PY_INT_FAIL; goto done; } +#endif /* LIBVIR_CHECK_VERSION(1, 1, 3) */ static PyObject * libvirt_virConnectGetLibVersion(PyObject *self ATTRIBUTE_UNUSED, @@ -7282,7 +7284,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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 39/44] virDomainMigrateGetCompressionCache API appeared in 1.0.3
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index ad1ff4a..6c5d55f 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6789,6 +6789,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) @@ -6815,6 +6816,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) { @@ -7415,7 +7417,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) virDomainGetBlockIoTune, libvirt_virDomainGetBlockIoTune, METH_VARARGS, NULL}, #endif /* LIBVIR_CHECK_VERSION(0, 9, 8) */ {(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}, {(char *) virDomainMigrate3, libvirt_virDomainMigrate3, METH_VARARGS, NULL}, {(char *) virDomainMigrateToURI3, libvirt_virDomainMigrateToURI3, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 25/44] virDomainGetCPUStats API appeared in 0.9.10
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 7ab9013..dbf45cc 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -526,6 +526,7 @@ cleanup: return ret; } +#if LIBVIR_CHECK_VERSION(0, 9, 10) static PyObject * libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { @@ -661,6 +662,7 @@ error: Py_DECREF(ret); return error; } +#endif /* LIBVIR_CHECK_VERSION(0, 9, 10) */ static PyObject * libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { @@ -7269,7 +7271,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) virNetworkGetAutostart, libvirt_virNetworkGetAutostart, METH_VARARGS, NULL}, {(char *) virDomainBlockStats, libvirt_virDomainBlockStats, METH_VARARGS, NULL}, {(char *) virDomainBlockStatsFlags, libvirt_virDomainBlockStatsFlags, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 9, 10) {(char *) virDomainGetCPUStats, libvirt_virDomainGetCPUStats, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 9, 10) */ {(char *) virDomainInterfaceStats, libvirt_virDomainInterfaceStats, METH_VARARGS, NULL}, {(char *) virDomainMemoryStats, libvirt_virDomainMemoryStats, METH_VARARGS, NULL}, {(char *) virNodeGetCellsFreeMemory, libvirt_virNodeGetCellsFreeMemory, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 44/44] Simplify out of memory error case
--- libvirt-override.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 0464f49..570918c 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -167,8 +167,7 @@ setPyVirTypedParameter(PyObject *info, } if (VIR_ALLOC_N(ret, size) 0) { -PyErr_NoMemory(); -return NULL; +return PyErr_NoMemory(); } temp = ret[0]; -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 00/44] Split Python bindings into its own repo
This patch series is a follow up to: https://www.redhat.com/archives/libvir-list/2013-November/msg00416.html https://www.redhat.com/archives/libvir-list/2013-November/msg00620.html It includes all of Dan's patches and builds on his work and incorporates all reviews from Eric. The goal is to split the Python bindings out into their own git repo. These patches do not apply to current libvirt.git. You must follow Dan's steps for creating the new repo and initialize it based on the history of the current python/ subdirectory. Assuming your current checkout of libvirt is in a directory 'libvirt', then $ git clone libvirt libvirt-python $ cd libvirt-python $ git filter-branch --subdirectory-filter python --tag-name-filter cat -- --all $ git for-each-ref --format=%(refname) refs/original/ | xargs -n 1 git update-ref -d $ git reflog expire --expire=now --all $ git gc --prune=now You should now have a repo that's a couple of MB in size, showing only the files from python/ dir, in the root. The tags have been re-written to show content from the python/ directory. All the GPG signatures from tags are removed, since they are invalid after rewriting history. This was previously agreed to be the right way to handle this. The build system uses python distutils instead of autoconf/automake. It still uses the code generator as before though, pulling the XML files from /usr/share/libvirt/api (or whever you installed libvirt, as indicated by pkg-config). created a simple autobuild.sh to do an end-to-end build, including the RPM generation. Or you can just do python setup.py build ('make' equiv) python setup.py test('make check' equiv) python setup.py rpm ('make rpm' equiv) python setup.py clean ('make clean' equiv) Historically libvirt python only worked with the exact matching libvirt binary. Before releasing this, I think we need to make it possible to compile libvirt-python against any recent-ish libvirt version. This shouldn't actually be too hard - the generator will take care of most of it. All we need do is fix up the -override.c files to make use of version checks to hide APIs not present in older libvirt. The RPM is designed to be drop in compatible/identical to/with the existing libvirt-python RPM, so users should notice no difference in any way when upgrading. If you don't want to try the filter-branch steps yourself, you can clone this complete series + repo from: git clone https://github.com/cardoe/libvirt-python.git Notice how the history is intact right back to the first commit of the python bindings. NOTE: We need to pull in the following directories and this does not do that. * examples/python * examples/domain-events/events-python Daniel P. Berrange (14): Remove obsolete Makefile.am Update generator for new code layout Update header file includes Import STREQ macro from libvirt Add decl of MIN macro Import gnulib's xalloc_oversized macro Import gnulib's ignore_value macro Import code annotation macros from libvirt Import VIR_ALLOC / VIR_ALLOC_N / VIR_REALLOC_N functions Remove use of virStrcpyStatic Import VIR_FORCE_CLOSE macro from libvirt Add build/ to python module path for sanitytest.py Add execute permission for sanitytest.py Setup distutils build system Doug Goldstein (30): Import LIBVIR_CHECK_VERSION macro from libvirt Import some virTypedParams* APIs from libvirt Add missing attributes to setup.py 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 virDomainSnapshotListChildrenNames API appeared in 0.9.7 virDomain{Get,Set}BlockIoTune APIs appeared in 0.9.8 virDomain{Get,Set}InterfaceParameters APIs appeared in 0.9.9 virDomain{Get,Set}NumaParameters APIs appeared in 0.9.9 virDomainGetCPUStats API appeared in 0.9.10 virDomainGetDiskErrors API appeared in 0.9.10 virDomainListAllSnapshots API appeared in 0.9.13 virConnectListAllDomains API appeared in 0.9.13 virDomainSnapshotListAllChildren API appeared in 0.9.13 virConnect{Unr,R}egisterCloseCallback API appeared in 0.10.0 virDomainPinEmulator and virDomainGetEmulatorPinInfo APIs appeared in 0.10.0 virConnectListAll* APIs appeared in 0.10.2 virNode{Get,Set}MemoryParameters API appeared in 0.10.2 virStoragePoolListAllVolumes API appeared in 0.10.2 VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK appeared in 1.0.0 virNodeGetCPUMap API appeared in 1.0.0 virTypedParams* API appeared in 1.0.2 virDomainGetJobStats API appeared in 1.0.3 virDomainMigrateGetCompressionCache API appeared in 1.0.3 virDomainMigrate3 and virDomainMigrateToURI3 appeared in 1.1.0 virDomainCreateXMLWithFiles and virDomainCreateWithFiles APIs appeared in 1.1.1 VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED appeared in 1.1.1 virConnectGetCPUModelNames API appeared in 1.1.3 Simplify out of memory error case .gitignore | 4 + AUTHORS.in | 12
[libvirt] [libvirt-python PATCHv2 24/44] virDomain{Get, Set}NumaParameters APIs appeared in 0.9.9
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 051b7cd..7ab9013 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -1264,6 +1264,7 @@ cleanup: return ret; } +#if LIBVIR_CHECK_VERSION(0, 9, 9) static PyObject * libvirt_virDomainSetNumaParameters(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -1383,6 +1384,7 @@ cleanup: virTypedParamsFree(params, nparams); return ret; } +#endif /* LIBVIR_CHECK_VERSION(0, 9, 9) */ #if LIBVIR_CHECK_VERSION(0, 9, 9) static PyObject * @@ -7280,8 +7282,10 @@ static PyMethodDef libvirtMethods[] = { {(char *) virDomainGetBlkioParameters, libvirt_virDomainGetBlkioParameters, METH_VARARGS, NULL}, {(char *) virDomainSetMemoryParameters, libvirt_virDomainSetMemoryParameters, METH_VARARGS, NULL}, {(char *) virDomainGetMemoryParameters, libvirt_virDomainGetMemoryParameters, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 9, 9) {(char *) virDomainSetNumaParameters, libvirt_virDomainSetNumaParameters, METH_VARARGS, NULL}, {(char *) virDomainGetNumaParameters, libvirt_virDomainGetNumaParameters, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 9, 9) */ #if LIBVIR_CHECK_VERSION(0, 9, 9) {(char *) virDomainSetInterfaceParameters, libvirt_virDomainSetInterfaceParameters, METH_VARARGS, NULL}, {(char *) virDomainGetInterfaceParameters, libvirt_virDomainGetInterfaceParameters, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 28/44] virConnectListAllDomains API appeared in 0.9.13
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 4bbb499..dc1297e 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2400,6 +2400,7 @@ libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED, return py_retval; } +#if LIBVIR_CHECK_VERSION(0, 9, 13) static PyObject * libvirt_virConnectListAllDomains(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -2446,6 +2447,7 @@ cleanup: VIR_FREE(doms); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */ static PyObject * libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED, @@ -7242,7 +7244,9 @@ static PyMethodDef libvirtMethods[] = { {(char *) virConnectOpenAuth, libvirt_virConnectOpenAuth, METH_VARARGS, NULL}, {(char *) virConnectListDomainsID, libvirt_virConnectListDomainsID, METH_VARARGS, NULL}, {(char *) virConnectListDefinedDomains, libvirt_virConnectListDefinedDomains, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 9, 13) {(char *) virConnectListAllDomains, libvirt_virConnectListAllDomains, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */ {(char *) virConnectDomainEventRegister, libvirt_virConnectDomainEventRegister, METH_VARARGS, NULL}, {(char *) virConnectDomainEventDeregister, libvirt_virConnectDomainEventDeregister, METH_VARARGS, NULL}, {(char *) virConnectDomainEventRegisterAny, libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 35/44] VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK appeared in 1.0.0
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index aff1131..7e167ee 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6260,6 +6260,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, @@ -6306,6 +6307,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, @@ -6424,9 +6426,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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 10/44] Remove use of virStrcpyStatic
From: Daniel P. Berrange berra...@redhat.com Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libvirt-override.c b/libvirt-override.c index d8bbbab..816ef01 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -189,7 +189,8 @@ setPyVirTypedParameter(PyObject *info, goto cleanup; } -ignore_value(virStrcpyStatic(temp-field, keystr)); +strncpy(temp-field, keystr, sizeof(*temp-field) - 1); +temp-field[sizeof(*temp-field) - 1] = '\0'; temp-type = params[i].type; switch (params[i].type) { -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 42/44] VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED appeared in 1.1.1
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 32d1a4a..bcc2499 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6314,6 +6314,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, @@ -6358,6 +6359,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, @@ -6436,8 +6438,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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 22/44] virDomain{Get, Set}BlockIoTune APIs appeared in 0.9.8
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 9740d1f..4aaef4e 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -4637,6 +4637,7 @@ error: return NULL; } +#if LIBVIR_CHECK_VERSION(0, 9, 8) static PyObject * libvirt_virDomainSetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) @@ -4757,6 +4758,7 @@ cleanup: virTypedParamsFree(params, nparams); return ret; } +#endif /* LIBVIR_CHECK_VERSION(0, 9, 8) */ static PyObject * libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED, @@ -7331,8 +7333,10 @@ static PyMethodDef libvirtMethods[] = { {(char *) virDomainSnapshotListAllChildren, libvirt_virDomainSnapshotListAllChildren, METH_VARARGS, NULL}, {(char *) virDomainRevertToSnapshot, libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL}, {(char *) virDomainGetBlockJobInfo, libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 9, 8) {(char *) virDomainSetBlockIoTune, libvirt_virDomainSetBlockIoTune, METH_VARARGS, NULL}, {(char *) virDomainGetBlockIoTune, libvirt_virDomainGetBlockIoTune, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 9, 8) */ {(char *) virDomainSendKey, libvirt_virDomainSendKey, METH_VARARGS, NULL}, {(char *) virDomainMigrateGetCompressionCache, libvirt_virDomainMigrateGetCompressionCache, METH_VARARGS, NULL}, {(char *) virDomainMigrateGetMaxSpeed, libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 38/44] virDomainGetJobStats API appeared in 1.0.3
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 06956f4..ad1ff4a 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -4564,6 +4564,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) { @@ -4604,6 +4605,7 @@ cleanup: else return VIR_PY_NONE; } +#endif /* LIBVIR_CHECK_VERSION(1, 0, 3) */ static PyObject * libvirt_virDomainGetBlockJobInfo(PyObject *self ATTRIBUTE_UNUSED, @@ -7393,7 +7395,9 @@ static PyMethodDef libvirtMethods[] = { #endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */ {(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}, #if LIBVIR_CHECK_VERSION(0, 9, 13) {(char *) virDomainListAllSnapshots, libvirt_virDomainListAllSnapshots, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 17/44] Add missing attributes to setup.py
setup.py needs a URL attribute that contains the project's website which is set to http://libvirt.org as well as information about a maintainer which is set to 'Libvirt Maintainers' and points to the libvirt mailing list. --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index b209bd6..a28b052 100644 --- a/setup.py +++ b/setup.py @@ -247,6 +247,9 @@ class my_clean(clean): setup(name = 'libvirt-python', version = '1.2.0', + 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-python PATCHv2 30/44] virConnect{Unr, R}egisterCloseCallback API appeared in 0.10.0
--- libvirt-override.c | 4 1 file changed, 4 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 90e6451..82bbd84 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6504,6 +6504,7 @@ libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED, LIBVIRT_RELEASE_THREAD_STATE; } +#if LIBVIR_CHECK_VERSION(0, 10, 0) static PyObject * libvirt_virConnectRegisterCloseCallback(ATTRIBUTE_UNUSED PyObject * self, PyObject * args) @@ -6570,6 +6571,7 @@ libvirt_virConnectUnregisterCloseCallback(ATTRIBUTE_UNUSED PyObject * self, py_retval = libvirt_intWrap(ret); return py_retval; } +#endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */ static void libvirt_virStreamEventFreeFunc(void *opaque) @@ -7253,8 +7255,10 @@ static PyMethodDef libvirtMethods[] = { {(char *) virConnectDomainEventDeregister, libvirt_virConnectDomainEventDeregister, METH_VARARGS, NULL}, {(char *) virConnectDomainEventRegisterAny, libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL}, {(char *) virConnectDomainEventDeregisterAny, libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL}, +#if LIBVIR_CHECK_VERSION(0, 10, 0) {(char *) virConnectRegisterCloseCallback, libvirt_virConnectRegisterCloseCallback, METH_VARARGS, NULL}, {(char *) virConnectUnregisterCloseCallback, libvirt_virConnectUnregisterCloseCallback, METH_VARARGS, NULL}, +#endif /* LIBVIR_CHECK_VERSION(0, 10, 0) */ {(char *) virStreamEventAddCallback, libvirt_virStreamEventAddCallback, METH_VARARGS, NULL}, {(char *) virStreamRecv, libvirt_virStreamRecv, METH_VARARGS, NULL}, {(char *) virStreamSend, libvirt_virStreamSend, METH_VARARGS, NULL}, -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list