]> xenbits.xensource.com Git - libvirt.git/commitdiff
* python/libvir.c: call the initialize entry point
authorDaniel Veillard <veillard@redhat.com>
Tue, 28 Mar 2006 14:41:04 +0000 (14:41 +0000)
committerDaniel Veillard <veillard@redhat.com>
Tue, 28 Mar 2006 14:41:04 +0000 (14:41 +0000)
* src/libvirt_sym.version: add initialize entry point
* src/libvirt.c: make sure we always initialize the lib
* python/tests/*.py: start updating exemple for exception
  handling as pointed by Jim Meyering
Daniel

ChangeLog
python/libvir.c
python/tests/basic.py
python/tests/create.py
python/tests/uuid.py
src/libvirt.c
src/libvirt_sym.version

index 73534d0f159617eaa459355305c6775467167115..fb6732039169324e863556d455d5fb43c2c13aa8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Mar 28 16:40:08 CEST 2006 Daniel Veillard <veillard@redhat.com>
+
+       * python/libvir.c: call the initialize entry point
+       * src/libvirt_sym.version: add initialize entry point
+       * src/libvirt.c: make sure we always initialize the lib
+       * python/tests/*.py: start updating exemple for exception
+         handling as pointed by Jim Meyering
+
 Tue Mar 28 11:49:59 CEST 2006 Daniel Veillard <veillard@redhat.com>
 
        * doc/site.xsl doc/libvir.html doc/*: added informations about
index 47da369d2532e92928436477f3b7ae72bed54ee1..1d97037704621cfc419b44aed207737a5c2d0b47 100644 (file)
@@ -269,6 +269,8 @@ initlibvirtmod(void)
     if (initialized != 0)
         return;
 
+    virInitialize();
+
     /* intialize the python extension module */
     Py_InitModule((char *) "libvirtmod", libvirtMethods);
 
index b6f8831a1e40e11e9440e91a36da098c77bf44b9..c6dec81f9bae5ccdf7191cfab513d2f12f0c0280 100755 (executable)
@@ -14,8 +14,9 @@ if conn == None:
 
 # print conn
 
-dom0 = conn.lookupByName("Domain-0")
-if dom0 == None:
+try:
+    dom0 = conn.lookupByName("Domain-0")
+except:
     print 'Failed to find the main domain'
     sys.exit(1)
 
index c897741edd4d0b345ceb87bacd0c1e629c1a8b15..b717db18819e4747c5629ced9ba08a045243c6a2 100755 (executable)
@@ -115,13 +115,20 @@ time.sleep(10)
 print "shutdown of test domain"
 
 if dom.shutdown() != 0:
+    okay = 0
     print 'Failed to shutdown domain test'
 
 i = 0
 while i < 30:
     time.sleep(1)
     i = i + 1
-    t = dom.info()[4]
+    try:
+       t = dom.info()[4]
+    except:
+        okay = 0
+       t = -1
+       break;
+        
     if t == 0:
         break
 
index d71d420687420fb81953ef421433aa3cb19763e4..605b7594242530ba6f5289593dabed5b9a07aa74 100755 (executable)
@@ -19,16 +19,18 @@ if ids == None or len(ids) == 0:
 
 id = ids[-1]
 
-dom = conn.lookupByID(id)
-if dom == None:
+try:
+    dom = conn.lookupByID(id)
+except:
     print 'Failed to find the domain %d'
     sys.exit(1)
 
 name0 = dom.name()
 uuid = dom.UUID()
 print "Using domain %s" % (name0)
-dom2 = conn.lookupByUUID(uuid)
-if dom2 == None:
+try:
+    dom2 = conn.lookupByUUID(uuid)
+except:
     print 'Failed to lookup domain %d based on its UUID'
     sys.exit(1)
 if dom2.name() != name0:
index eedf52d00d8ebdd7701d150c542d52dc7924c3ab..d5c268bb2e6cbc045fa3a973976d6d4efbb59d89 100644 (file)
@@ -57,6 +57,7 @@ virInitialize(void)
 
     if (initialized)
         return(0);
+    initialized = 1;
 
     /*
      * should not be needed but...
@@ -70,7 +71,6 @@ virInitialize(void)
     xenHypervisorRegister();
     xenDaemonRegister();
     xenStoreRegister();
-    initialized = 1;
     return(0);
 }
 
@@ -136,6 +136,9 @@ virRegisterDriver(virDriverPtr driver)
 {
     int i;
 
+    if (!initialized)
+        virInitialize();
+
     if (driver == NULL) {
         virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
        return(-1);
@@ -173,6 +176,9 @@ int
 virGetVersion(unsigned long *libVer, const char *type,
               unsigned long *typeVer)
 {
+    if (!initialized)
+        virInitialize();
+
     if (libVer == NULL)
         return (-1);
     *libVer = LIBVIR_VERSION_NUMBER;
@@ -212,6 +218,9 @@ virConnectOpen(const char *name)
 {
     virConnectPtr ret = NULL;
 
+    if (!initialized)
+        virInitialize();
+
     /* we can only talk to the local Xen supervisor ATM */
     if (name != NULL) {
         virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
@@ -270,6 +279,9 @@ virConnectOpenReadOnly(const char *name)
     int res;
     virConnectPtr ret = NULL;
 
+    if (!initialized)
+        virInitialize();
+
     /* we can only talk to the local Xen supervisor ATM */
     if (name != NULL) {
         virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
index 85e2694b1150ebe3696854ed6f42cb994d318977..0a298f82402f40c05cfa59aa7a84ded0509d694d 100644 (file)
@@ -1,5 +1,6 @@
 {
     global:
+        virInitialize;
        virConnectClose;
        virConnectGetType;
        virConnectGetVersion;