
Daniel P. Berrange wrote:
On Tue, May 18, 2010 at 12:32:13PM +0200, Jim Meyering wrote:
I've just fixed code in a test that ignored virInitialize failure. Looking at all uses, I saw one other: in python/libvirt-override.c, where the initialization function ignores virInitialize failure:
void #ifndef __CYGWIN__ initlibvirtmod #else initcygvirtmod #endif (void) { static int initialized = 0;
if (initialized != 0) return;
virInitialize();
/* initialize the python extension module */ Py_InitModule((char *) #ifndef __CYGWIN__ "libvirtmod" #else "cygvirtmod" #endif , libvirtMethods);
initialized = 1; }
Unfortunately, this function is public, so we can't change its signature.
More specifically, the signature is defined by Python's loadable module interface so we're not at liberty to redeclare that.
Any suggestions?
abort()
Here you go. Do you think it's worth a diagnostic first? If so, using what function?
From 9225353b89c6ee4ff550d0fee18e759a2d949686 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Tue, 18 May 2010 13:46:27 +0200 Subject: [PATCH] python: don't ignore virInitialize failure in module initialization
* python/libvirt-override.c (initlibvirtmod): Abort upon virInitialize failure. --- python/libvirt-override.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index b97445b..b754f5e 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -3543,7 +3543,8 @@ initcygvirtmod if (initialized != 0) return; - virInitialize(); + if (virInitialize() < 0) + abort(); /* initialize the python extension module */ Py_InitModule((char *) -- 1.7.1.250.g7d1e8