mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
* python/tests/create.py: trying to make test more generic, but it's
difficult since it requires a system image * src/libvirt.c src/xend_internal.c: fixed the shutdown API which was broken due to a bad reason at the xend level. Daniel
This commit is contained in:
parent
77e8b6c62c
commit
82402982c8
@ -1,3 +1,10 @@
|
|||||||
|
Fri Feb 17 08:17:36 EST 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
|
* python/tests/create.py: trying to make test more generic, but it's
|
||||||
|
difficult since it requires a system image
|
||||||
|
* src/libvirt.c src/xend_internal.c: fixed the shutdown API which
|
||||||
|
was broken due to a bad reason at the xend level.
|
||||||
|
|
||||||
Thu Feb 16 17:47:00 EST 2006 Daniel Veillard <veillard@redhat.com>
|
Thu Feb 16 17:47:00 EST 2006 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* configure.in src/Makefile.am: adding dependency to libxml2
|
* configure.in src/Makefile.am: adding dependency to libxml2
|
||||||
|
@ -1,6 +1,49 @@
|
|||||||
#!/usr/bin/python -u
|
#!/usr/bin/python -u
|
||||||
import libvirt
|
import libvirt
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
#
|
||||||
|
# Try to provide default OS images paths here, of course non standard
|
||||||
|
#
|
||||||
|
osroots = [
|
||||||
|
"/u/fc4.img",
|
||||||
|
]
|
||||||
|
|
||||||
|
okay = 1
|
||||||
|
|
||||||
|
osroot = None
|
||||||
|
for root in osroots:
|
||||||
|
if os.access(root, os.R_OK):
|
||||||
|
osroot = root
|
||||||
|
break
|
||||||
|
|
||||||
|
if osroot == None:
|
||||||
|
print "Could not find a guest OS root, edit to add the path in osroots"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not os.access("/proc/xen", os.R_OK):
|
||||||
|
print 'System is not running a Xen kernel'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
kernel=open("/proc/version").read().split()
|
||||||
|
kernelOv = kernel[2]
|
||||||
|
kernelU = "/boot/vmlinuz-" + kernelOv.replace('hypervisor', 'guest')
|
||||||
|
initrdU = "/boot/initrd-" + kernelOv.replace('hypervisor', 'guest') + ".img"
|
||||||
|
|
||||||
|
if not os.access(kernelU, os.R_OK):
|
||||||
|
print "Did not found the guest kernel %s" % (kernelU)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
kernelU = "<kernel>" + kernelU + "</kernel>"
|
||||||
|
|
||||||
|
if not os.access(initrdU, os.R_OK):
|
||||||
|
print "Did not found the guest initrd %s" % (initrdU)
|
||||||
|
initrdU = ""
|
||||||
|
else:
|
||||||
|
initrdU = "<initrd>" + initrdU + "</initrd>"
|
||||||
|
|
||||||
|
|
||||||
conn = libvirt.openReadOnly(None)
|
conn = libvirt.openReadOnly(None)
|
||||||
if conn == None:
|
if conn == None:
|
||||||
@ -11,15 +54,14 @@ xmldesc="""<domain type='xen'>
|
|||||||
<name>test</name>
|
<name>test</name>
|
||||||
<os>
|
<os>
|
||||||
<type>linux</type>
|
<type>linux</type>
|
||||||
<kernel>/boot/vmlinuz-2.6.15-1.43_FC5guest</kernel>
|
""" + kernelU + initrdU + """
|
||||||
<initrd>/boot/initrd-2.6.15-1.43_FC5guest.img</initrd>
|
|
||||||
<cmdline> root=/dev/sda1 ro selinux=0 3</cmdline>
|
<cmdline> root=/dev/sda1 ro selinux=0 3</cmdline>
|
||||||
</os>
|
</os>
|
||||||
<memory>131072</memory>
|
<memory>131072</memory>
|
||||||
<vcpu>1</vcpu>
|
<vcpu>1</vcpu>
|
||||||
<devices>
|
<devices>
|
||||||
<disk type='file'>
|
<disk type='file'>
|
||||||
<source file='/u/fc4.img'/>
|
<source file='%s'/>
|
||||||
<target dev='sda1'/>
|
<target dev='sda1'/>
|
||||||
</disk>
|
</disk>
|
||||||
<interface type='bridge'>
|
<interface type='bridge'>
|
||||||
@ -29,18 +71,62 @@ xmldesc="""<domain type='xen'>
|
|||||||
</interface>
|
</interface>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
"""
|
""" % (osroot)
|
||||||
|
|
||||||
dom = conn.createLinux(xmldesc, 0)
|
dom = conn.createLinux(xmldesc, 0)
|
||||||
if dom == None:
|
if dom == None:
|
||||||
print 'Failed to create a domain'
|
print 'Failed to create a test domain'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# print dom0
|
# print dom0
|
||||||
|
|
||||||
print "Domain: id %d running %s" % (dom.ID(), dom.OSType())
|
print "Domain: id %d running %s" % (dom.ID(), dom.OSType())
|
||||||
print dom.info()
|
|
||||||
|
print "Suspending test domain for 5 seconds"
|
||||||
|
if dom.suspend() != 0:
|
||||||
|
print 'Failed to suspend domain test'
|
||||||
|
dom.destroy()
|
||||||
|
del dom
|
||||||
|
del conn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
infos = dom.info()
|
||||||
|
time.sleep(5)
|
||||||
|
infos2 = dom.info()
|
||||||
|
if infos[4] != infos2[4]:
|
||||||
|
print 'Suspended domain test got CPU cycles'
|
||||||
|
okay = 0
|
||||||
|
|
||||||
|
print "resuming test domain for 10 seconds"
|
||||||
|
if dom.resume() != 0:
|
||||||
|
print 'Failed to resume domain test'
|
||||||
|
dom.destroy()
|
||||||
|
del dom
|
||||||
|
del conn
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
time.sleep(10)
|
||||||
|
print "shutdown of test domain"
|
||||||
|
|
||||||
|
if dom.shutdown() != 0:
|
||||||
|
print 'Failed to shutdown domain test'
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while i < 30:
|
||||||
|
time.sleep(1)
|
||||||
|
i = i + 1
|
||||||
|
t = dom.info()[4]
|
||||||
|
if t == 0:
|
||||||
|
break
|
||||||
|
|
||||||
|
if t != 0:
|
||||||
|
print 'Shutdown failed destroying domain test'
|
||||||
|
okay = 0
|
||||||
|
dom.destroy()
|
||||||
|
|
||||||
del dom
|
del dom
|
||||||
del conn
|
del conn
|
||||||
print "OK"
|
if okay == 1:
|
||||||
|
print "OK"
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -967,12 +967,10 @@ virDomainShutdown(virDomainPtr domain) {
|
|||||||
* try first with the xend daemon
|
* try first with the xend daemon
|
||||||
*/
|
*/
|
||||||
ret = xend_shutdown(domain->conn, domain->name);
|
ret = xend_shutdown(domain->conn, domain->name);
|
||||||
/* disabled as this seems to not work ...
|
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return(0);
|
return(0);
|
||||||
*/
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
/*
|
||||||
* this is very hackish, the domU kernel probes for a special
|
* this is very hackish, the domU kernel probes for a special
|
||||||
* node in the xenstore and launch the shutdown command if found.
|
* node in the xenstore and launch the shutdown command if found.
|
||||||
*/
|
*/
|
||||||
|
@ -1146,7 +1146,7 @@ xend_shutdown(virConnectPtr xend, const char *name)
|
|||||||
if ((xend == NULL) || (name == NULL))
|
if ((xend == NULL) || (name == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
return xend_op(xend, name,
|
return xend_op(xend, name,
|
||||||
"op", "shutdown", "reason", "shutdown", NULL);
|
"op", "shutdown", "reason", "halt", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2037,7 +2037,7 @@ xend_get_node(virConnectPtr xend)
|
|||||||
int
|
int
|
||||||
xend_node_shutdown(virConnectPtr xend)
|
xend_node_shutdown(virConnectPtr xend)
|
||||||
{
|
{
|
||||||
return xend_node_op(xend, "/xend/node/", "op", "shutdown", NULL);
|
return xend_node_op(xend, "/xend/node/", "op", "halt", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user