On Wed, Dec 04, 2013 at 05:06:19PM +0000, Daniel P. Berrange wrote:
On Tue, Dec 03, 2013 at 09:36:28AM -0700, Eric Blake wrote:
> On 12/03/2013 09:01 AM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange(a)redhat.com>
> >
> > The event handler code currently invokes PyImport_ImportModule
> > which is very heavyweight. This is not in fact required, since
> > we know the libvirt module has already been imported. We can
> > thus use PyImport_ImportModuleNoBlock and do away with the
> > global variables caching the imported module reference.
> >
> > Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
> > ---
> > libvirt-override.c | 35 +++++++++++------------------------
> > 1 file changed, 11 insertions(+), 24 deletions(-)
> >
>
> > - /* Bogus (char *) cast for RHEL-5 python API brokenness */
> > - libvirt_module = PyImport_ImportModule((char *)"libvirt");
> > - if (!libvirt_module) {
> > - DEBUG("%s Error importing libvirt module\n", __FUNCTION__);
> > +getLibvirtDictObject(void) {
> > + PyObject *libvirt_mod;
> > + PyObject *libvirt_dict;
> > +
> > + libvirt_mod = PyImport_ImportModuleNoBlock("libvirt");
>
> Do we still need the bogus cast? (I guess I should try building
> libvirt-python on my RHEL-5 VM...)
I just tested the build with RHEL-5.10 and it was fine - I verified
the header declares the parameter const, so presumably the flaw was
fixed at some point.
Damn, I screwed up and logged into the wrong VM when testing this.
It does not in fact work in RHEL-5, python 2.4, so I've reverted
this commit entirely. The PyImport_ImportModuleNoBlock function
does not exist.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|