mirror of https://gitee.com/openkylin/libvirt.git
* 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 Daniel
This commit is contained in:
parent
7743c7a7b1
commit
538686f9c0
|
@ -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>
|
Tue Mar 28 11:49:59 CEST 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* doc/site.xsl doc/libvir.html doc/*: added informations about
|
* doc/site.xsl doc/libvir.html doc/*: added informations about
|
||||||
|
|
|
@ -269,6 +269,8 @@ initlibvirtmod(void)
|
||||||
if (initialized != 0)
|
if (initialized != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
virInitialize();
|
||||||
|
|
||||||
/* intialize the python extension module */
|
/* intialize the python extension module */
|
||||||
Py_InitModule((char *) "libvirtmod", libvirtMethods);
|
Py_InitModule((char *) "libvirtmod", libvirtMethods);
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,9 @@ if conn == None:
|
||||||
|
|
||||||
# print conn
|
# print conn
|
||||||
|
|
||||||
dom0 = conn.lookupByName("Domain-0")
|
try:
|
||||||
if dom0 == None:
|
dom0 = conn.lookupByName("Domain-0")
|
||||||
|
except:
|
||||||
print 'Failed to find the main domain'
|
print 'Failed to find the main domain'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
@ -115,13 +115,20 @@ time.sleep(10)
|
||||||
print "shutdown of test domain"
|
print "shutdown of test domain"
|
||||||
|
|
||||||
if dom.shutdown() != 0:
|
if dom.shutdown() != 0:
|
||||||
|
okay = 0
|
||||||
print 'Failed to shutdown domain test'
|
print 'Failed to shutdown domain test'
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < 30:
|
while i < 30:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
t = dom.info()[4]
|
try:
|
||||||
|
t = dom.info()[4]
|
||||||
|
except:
|
||||||
|
okay = 0
|
||||||
|
t = -1
|
||||||
|
break;
|
||||||
|
|
||||||
if t == 0:
|
if t == 0:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -19,16 +19,18 @@ if ids == None or len(ids) == 0:
|
||||||
|
|
||||||
id = ids[-1]
|
id = ids[-1]
|
||||||
|
|
||||||
dom = conn.lookupByID(id)
|
try:
|
||||||
if dom == None:
|
dom = conn.lookupByID(id)
|
||||||
|
except:
|
||||||
print 'Failed to find the domain %d'
|
print 'Failed to find the domain %d'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
name0 = dom.name()
|
name0 = dom.name()
|
||||||
uuid = dom.UUID()
|
uuid = dom.UUID()
|
||||||
print "Using domain %s" % (name0)
|
print "Using domain %s" % (name0)
|
||||||
dom2 = conn.lookupByUUID(uuid)
|
try:
|
||||||
if dom2 == None:
|
dom2 = conn.lookupByUUID(uuid)
|
||||||
|
except:
|
||||||
print 'Failed to lookup domain %d based on its UUID'
|
print 'Failed to lookup domain %d based on its UUID'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if dom2.name() != name0:
|
if dom2.name() != name0:
|
||||||
|
|
|
@ -57,6 +57,7 @@ virInitialize(void)
|
||||||
|
|
||||||
if (initialized)
|
if (initialized)
|
||||||
return(0);
|
return(0);
|
||||||
|
initialized = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* should not be needed but...
|
* should not be needed but...
|
||||||
|
@ -70,7 +71,6 @@ virInitialize(void)
|
||||||
xenHypervisorRegister();
|
xenHypervisorRegister();
|
||||||
xenDaemonRegister();
|
xenDaemonRegister();
|
||||||
xenStoreRegister();
|
xenStoreRegister();
|
||||||
initialized = 1;
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +136,9 @@ virRegisterDriver(virDriverPtr driver)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
virInitialize();
|
||||||
|
|
||||||
if (driver == NULL) {
|
if (driver == NULL) {
|
||||||
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -173,6 +176,9 @@ int
|
||||||
virGetVersion(unsigned long *libVer, const char *type,
|
virGetVersion(unsigned long *libVer, const char *type,
|
||||||
unsigned long *typeVer)
|
unsigned long *typeVer)
|
||||||
{
|
{
|
||||||
|
if (!initialized)
|
||||||
|
virInitialize();
|
||||||
|
|
||||||
if (libVer == NULL)
|
if (libVer == NULL)
|
||||||
return (-1);
|
return (-1);
|
||||||
*libVer = LIBVIR_VERSION_NUMBER;
|
*libVer = LIBVIR_VERSION_NUMBER;
|
||||||
|
@ -212,6 +218,9 @@ virConnectOpen(const char *name)
|
||||||
{
|
{
|
||||||
virConnectPtr ret = NULL;
|
virConnectPtr ret = NULL;
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
virInitialize();
|
||||||
|
|
||||||
/* we can only talk to the local Xen supervisor ATM */
|
/* we can only talk to the local Xen supervisor ATM */
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
|
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
|
||||||
|
@ -270,6 +279,9 @@ virConnectOpenReadOnly(const char *name)
|
||||||
int res;
|
int res;
|
||||||
virConnectPtr ret = NULL;
|
virConnectPtr ret = NULL;
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
virInitialize();
|
||||||
|
|
||||||
/* we can only talk to the local Xen supervisor ATM */
|
/* we can only talk to the local Xen supervisor ATM */
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
|
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
global:
|
global:
|
||||||
|
virInitialize;
|
||||||
virConnectClose;
|
virConnectClose;
|
||||||
virConnectGetType;
|
virConnectGetType;
|
||||||
virConnectGetVersion;
|
virConnectGetVersion;
|
||||||
|
|
Loading…
Reference in New Issue