libvirt-python-4.0.0/ 0000775 0001750 0001750 00000000000 13230351500 016125 5 ustar veillard veillard 0000000 0000000 libvirt-python-4.0.0/examples/ 0000775 0001750 0001750 00000000000 13230351500 017743 5 ustar veillard veillard 0000000 0000000 libvirt-python-4.0.0/examples/guest-vcpus/ 0000775 0001750 0001750 00000000000 13230351500 022230 5 ustar veillard veillard 0000000 0000000 libvirt-python-4.0.0/examples/guest-vcpus/guest-vcpu-daemon.py 0000775 0001750 0001750 00000010313 13211303124 026144 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
import libvirt
import threading
from xml.dom import minidom
import time
import sys
import getopt
import os
uri = "qemu:///system"
customXMLuri = "guest-cpu.python.libvirt.org"
connectRetryTimeout = 5
def usage():
print("usage: "+os.path.basename(sys.argv[0])+" [-h] [uri]")
print(" uri will default to qemu:///system")
print(" --help, -h Print(this help message")
print("")
print("This service waits for the guest agent lifecycle event and reissues " +
"guest agent calls to modify the cpu count according to the metadata " +
"set by guest-vcpu.py example")
class workerData:
def __init__(self):
self.doms = list()
self.conn = None
self.cond = threading.Condition()
def notify(self):
self.cond.acquire()
self.cond.notify()
self.cond.release()
def waitNotify(self):
self.cond.acquire()
self.cond.wait()
self.cond.release()
def addDomainNotify(self, dom):
self.doms.append(dom)
self.notify()
def closeConnectNotify(self):
conn = self.conn
self.conn = None
conn.close()
self.notify()
def setConnect(self, conn):
self.conn = conn
def hasConn(self):
return self.conn is not None
def hasDom(self):
return len(self.doms) > 0
def getDom(self):
return self.doms.pop()
def setDoms(self, doms):
self.doms = doms
def virEventLoopNativeRun():
while True:
libvirt.virEventRunDefaultImpl()
def handleAgentLifecycleEvent(conn, dom, state, reason, opaque):
if state == libvirt.VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_STATE_CONNECTED:
opaque.addDomainNotify(dom)
def handleConnectClose(conn, reason, opaque):
print('Disconnected from ' + uri)
opaque.closeConnectNotify()
def handleLibvirtLibraryError(opaque, error):
pass
def processAgentConnect(dom):
try:
cpus = dom.metadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT, customXMLuri,
libvirt.VIR_DOMAIN_AFFECT_LIVE)
doc = minidom.parseString(cpus)
ncpus = int(doc.getElementsByTagName('ncpus')[0].getAttribute('count'))
except:
return
try:
dom.setVcpusFlags(ncpus, libvirt.VIR_DOMAIN_AFFECT_LIVE | libvirt.VIR_DOMAIN_VCPU_GUEST)
print("set vcpu count for domain " + dom.name() + " to " + str(ncpus))
except:
print("failed to set vcpu count for domain " + dom.name())
def work():
data = workerData()
print("Using uri: " + uri)
while True:
if not data.hasConn():
try:
conn = libvirt.open(uri)
except:
print('Failed to connect to ' + uri + ', retry in ' + str(connectRetryTimeout)) + ' seconds'
time.sleep(connectRetryTimeout)
continue
print('Connected to ' + uri)
data.setConnect(conn)
conn.registerCloseCallback(handleConnectClose, data)
conn.setKeepAlive(5, 3)
conn.domainEventRegisterAny(None,
libvirt.VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE,
handleAgentLifecycleEvent,
data)
data.setDoms(conn.listAllDomains(libvirt.VIR_CONNECT_LIST_DOMAINS_ACTIVE))
while data.hasConn() and data.hasDom():
processAgentConnect(data.getDom())
data.waitNotify()
def main():
libvirt.virEventRegisterDefaultImpl()
libvirt.registerErrorHandler(handleLibvirtLibraryError, None)
worker = threading.Thread(target=work)
worker.setDaemon(True)
worker.start()
eventLoop = threading.Thread(target=virEventLoopNativeRun)
eventLoop.setDaemon(True)
eventLoop.start()
while True:
time.sleep(1)
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
except getopt.GetoptError as err:
print(str(err))
usage()
sys.exit(2)
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
if len(args) > 1:
usage()
sys.exit(1)
elif len(args) == 1:
uri = args[0]
main()
libvirt-python-4.0.0/examples/guest-vcpus/guest-vcpu.py 0000775 0001750 0001750 00000004105 13211303124 024705 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
import libvirt
import sys
import getopt
import os
customXMLuri = "guest-cpu.python.libvirt.org"
def usage():
print("usage: "+os.path.basename(sys.argv[0])+" [-hcl] domain count [uri]")
print(" uri will default to qemu:///system")
print(" --help, -h Print(this help message")
print(" --config, -c Modify persistent domain configuration")
print(" --live, -l Modify live domain configuration")
print("")
print("Sets the vCPU count via the guest agent and sets the metadata element " +
"used by guest-vcpu-daemon.py example")
uri = "qemu:///system"
flags = 0
live = False;
config = False;
try:
opts, args = getopt.getopt(sys.argv[1:], "hcl", ["help", "config", "live"])
except getopt.GetoptError as err:
# print help information and exit:
print(str(err)) # will print something like "option -a not recognized"
usage()
sys.exit(2)
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
if o in ("-c", "--config"):
config = True
flags |= libvirt.VIR_DOMAIN_AFFECT_CONFIG
if o in ("-l", "--live"):
live = True
flags |= libvirt.VIR_DOMAIN_AFFECT_LIVE
if len(args) < 2:
usage()
sys.exit(1)
elif len(args) >= 3:
uri = args[2]
domain = args[0]
count = int(args[1])
conn = libvirt.open(uri)
dom = conn.lookupByName(domain)
if flags == 0 or config:
confvcpus = dom.vcpusFlags(libvirt.VIR_DOMAIN_AFFECT_CONFIG)
if confvcpus < count:
print("Persistent domain configuration has only " + str(confvcpus) + " vcpus configured")
sys.exit(1)
if flags == 0 or live:
livevcpus = dom.vcpusFlags(libvirt.VIR_DOMAIN_AFFECT_LIVE)
if livevcpus < count:
print("Live domain configuration has only " + str(livevcpus) + " vcpus configured")
sys.exit(1)
if flags == 0 or live:
dom.setVcpusFlags(count, libvirt.VIR_DOMAIN_AFFECT_LIVE | libvirt.VIR_DOMAIN_VCPU_GUEST)
meta = ""
dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_ELEMENT, meta, "guestvcpudaemon", customXMLuri, flags)
libvirt-python-4.0.0/examples/consolecallback.py 0000664 0001750 0001750 00000005550 13211303124 023437 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# consolecallback - provide a persistent console that survives guest reboots
import sys, os, logging, libvirt, tty, termios, atexit
def reset_term():
termios.tcsetattr(0, termios.TCSADRAIN, attrs)
def error_handler(unused, error):
# The console stream errors on VM shutdown; we don't care
if (error[0] == libvirt.VIR_ERR_RPC and
error[1] == libvirt.VIR_FROM_STREAMS):
return
logging.warn(error)
class Console(object):
def __init__(self, uri, uuid):
self.uri = uri
self.uuid = uuid
self.connection = libvirt.open(uri)
self.domain = self.connection.lookupByUUIDString(uuid)
self.state = self.domain.state(0)
self.connection.domainEventRegister(lifecycle_callback, self)
self.stream = None
self.run_console = True
logging.info("%s initial state %d, reason %d",
self.uuid, self.state[0], self.state[1])
def check_console(console):
if (console.state[0] == libvirt.VIR_DOMAIN_RUNNING or
console.state[0] == libvirt.VIR_DOMAIN_PAUSED):
if console.stream is None:
console.stream = console.connection.newStream(libvirt.VIR_STREAM_NONBLOCK)
console.domain.openConsole(None, console.stream, 0)
console.stream.eventAddCallback(libvirt.VIR_STREAM_EVENT_READABLE, stream_callback, console)
else:
if console.stream:
console.stream.eventRemoveCallback()
console.stream = None
return console.run_console
def stdin_callback(watch, fd, events, console):
readbuf = os.read(fd, 1024)
if readbuf.startswith(""):
console.run_console = False
return
if console.stream:
console.stream.send(readbuf)
def stream_callback(stream, events, console):
try:
received_data = console.stream.recv(1024)
except:
return
os.write(0, received_data)
def lifecycle_callback (connection, domain, event, detail, console):
console.state = console.domain.state(0)
logging.info("%s transitioned to state %d, reason %d",
console.uuid, console.state[0], console.state[1])
# main
if len(sys.argv) != 3:
print("Usage:", sys.argv[0], "URI UUID")
print("for example:", sys.argv[0], "'qemu:///system' '32ad945f-7e78-c33a-e96d-39f25e025d81'")
sys.exit(1)
uri = sys.argv[1]
uuid = sys.argv[2]
print("Escape character is ^]")
logging.basicConfig(filename='msg.log', level=logging.DEBUG)
logging.info("URI: %s", uri)
logging.info("UUID: %s", uuid)
libvirt.virEventRegisterDefaultImpl()
libvirt.registerErrorHandler(error_handler, None)
atexit.register(reset_term)
attrs = termios.tcgetattr(0)
tty.setraw(0)
console = Console(uri, uuid)
console.stdin_watch = libvirt.virEventAddHandle(0, libvirt.VIR_EVENT_HANDLE_READABLE, stdin_callback, console)
while check_console(console):
libvirt.virEventRunDefaultImpl()
libvirt-python-4.0.0/examples/dominfo.py 0000775 0001750 0001750 00000004027 13211303124 021754 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# dominfo - print some information about a domain
import libvirt
import sys
import os
import libxml2
import pdb
def usage():
print('Usage: %s DOMAIN' % sys.argv[0])
print(' Print information about the domain DOMAIN')
def print_section(title):
print("\n%s" % title)
print("=" * 60)
def print_entry(key, value):
print("%-10s %-10s" % (key, value))
def print_xml(key, ctx, path):
res = ctx.xpathEval(path)
if res is None or len(res) == 0:
value="Unknown"
else:
value = res[0].content
print_entry(key, value)
return value
if len(sys.argv) != 2:
usage()
sys.exit(2)
name = sys.argv[1]
# Connect to libvirt
conn = libvirt.openReadOnly(None)
if conn is None:
print('Failed to open connection to the hypervisor')
sys.exit(1)
try:
dom = conn.lookupByName(name)
# Annoyiingly, libvirt prints its own error message here
except libvirt.libvirtError:
print("Domain %s is not running" % name)
sys.exit(0)
info = dom.info()
print_section("Domain info")
print_entry("State:", info[0])
print_entry("MaxMem:", info[1])
print_entry("UsedMem:", info[2])
print_entry("VCPUs:", info[3])
# Read some info from the XML desc
xmldesc = dom.XMLDesc(0)
doc = libxml2.parseDoc(xmldesc)
ctx = doc.xpathNewContext()
print_section("Kernel")
print_xml("Type:", ctx, "/domain/os/type")
print_xml("Kernel:", ctx, "/domain/os/kernel")
print_xml("initrd:", ctx, "/domain/os/initrd")
print_xml("cmdline:", ctx, "/domain/os/cmdline")
print_section("Devices")
devs = ctx.xpathEval("/domain/devices/*")
for d in devs:
ctx.setContextNode(d)
#pdb.set_trace()
type = print_xml("Type:", ctx, "@type")
if type == "file":
print_xml("Source:", ctx, "source/@file")
print_xml("Target:", ctx, "target/@dev")
elif type == "block":
print_xml("Source:", ctx, "source/@dev")
print_xml("Target:", ctx, "target/@dev")
elif type == "bridge":
print_xml("Source:", ctx, "source/@bridge")
print_xml("MAC Addr:", ctx, "mac/@address")
libvirt-python-4.0.0/examples/domipaddrs.py 0000775 0001750 0001750 00000002765 13211303124 022456 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# domipaddrs - print domain interfaces along with their MAC and IP addresses
import libvirt
import sys
def usage():
print "Usage: %s [URI] DOMAIN" % sys.argv[0]
print " Print domain interfaces along with their MAC and IP addresses"
uri = None
name = None
args = len(sys.argv)
if args == 2:
name = sys.argv[1]
elif args == 3:
uri = sys.argv[1]
name = sys.argv[2]
else:
usage()
sys.exit(2)
conn = libvirt.open(uri)
if conn == None:
print "Unable to open connection to libvirt"
sys.exit(1)
try:
dom = conn.lookupByName(name)
except libvirt.libvirtError:
print "Domain %s not found" % name
sys.exit(0)
ifaces = dom.interfaceAddresses(libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE);
if (ifaces == None):
print "Failed to get domain interfaces"
sys.exit(0)
print " {0:10} {1:20} {2:12} {3}".format("Interface", "MAC address", "Protocol", "Address")
def toIPAddrType(addrType):
if addrType == libvirt.VIR_IP_ADDR_TYPE_IPV4:
return "ipv4"
elif addrType == libvirt.VIR_IP_ADDR_TYPE_IPV6:
return "ipv6"
for (name, val) in ifaces.iteritems():
if val['addrs']:
for addr in val['addrs']:
print " {0:10} {1:19}".format(name, val['hwaddr']),
print " {0:12} {1}/{2} ".format(toIPAddrType(addr['type']), addr['addr'], addr['prefix']),
print
else:
print " {0:10} {1:19}".format(name, val['hwaddr']),
print " {0:12} {1}".format("N/A", "N/A"),
print
libvirt-python-4.0.0/examples/domrestore.py 0000775 0001750 0001750 00000001436 13211303124 022505 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# domstart - make sure a given domU is running, if not start it
import libvirt
import sys
import os
import libxml2
import pdb
def usage():
print('Usage: %s DIR' % sys.argv[0])
print(' Restore all the domains contained in DIR')
print(' It is assumed that all files in DIR are')
print(' images of domU\'s previously created with save')
if len(sys.argv) != 2:
usage()
sys.exit(2)
dir = sys.argv[1]
imgs = os.listdir(dir)
conn = libvirt.open(None)
if conn is None:
print('Failed to open connection to the hypervisor')
sys.exit(1)
for img in imgs:
file = os.path.join(dir, img)
print("Restoring %s ... " % img)
ret = conn.restore(file)
if ret == 0:
print("done")
else:
print("error %d" % ret)
libvirt-python-4.0.0/examples/domsave.py 0000775 0001750 0001750 00000001514 13211303124 021755 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# domstart - make sure a given domU is running, if not start it
import libvirt
import sys
import os
import libxml2
import pdb
def usage():
print('Usage: %s DIR' % sys.argv[0])
print(' Save all currently running domU\'s into DIR')
print(' DIR must exist and be writable by this process')
if len(sys.argv) != 2:
usage()
sys.exit(2)
dir = sys.argv[1]
conn = libvirt.open(None)
if conn is None:
print('Failed to open connection to the hypervisor')
sys.exit(1)
doms = conn.listDomainsID()
for id in doms:
if id == 0:
continue
dom = conn.lookupByID(id)
print("Saving %s[%d] ... " % (dom.name(), id))
path = os.path.join(dir, dom.name())
ret = dom.save(path)
if ret == 0:
print("done")
else:
print("error %d" % ret)
#pdb.set_trace()
libvirt-python-4.0.0/examples/domstart.py 0000775 0001750 0001750 00000002430 13211303124 022152 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# domstart - make sure a given domU is running, if not start it
import libvirt
import sys
import os
import libxml2
import pdb
# Parse the XML description of domU from FNAME
# and return a tuple (name, xmldesc) where NAME
# is the name of the domain, and xmldesc is the contetn of FNAME
def read_domain(fname):
fp = open(fname, "r")
xmldesc = fp.read()
fp.close()
doc = libxml2.parseDoc(xmldesc)
name = doc.xpathNewContext().xpathEval("/domain/name")[0].content
return (name, xmldesc)
def usage():
print('Usage: %s domain.xml' % sys.argv[0])
print(' Check that the domain described by DOMAIN.XML is running')
print(' If the domain is not running, create it')
print(' DOMAIN.XML must be a XML description of the domain')
print(' in libvirt\'s XML format')
if len(sys.argv) != 2:
usage()
sys.exit(2)
(name, xmldesc) = read_domain(sys.argv[1])
conn = libvirt.open(None)
if conn is None:
print('Failed to open connection to the hypervisor')
sys.exit(1)
try:
dom = conn.lookupByName(name)
except libvirt.libvirtError:
print("Starting domain %s ... " % name)
dom = conn.createLinux(xmldesc, 0)
if dom is None:
print("failed")
sys.exit(1)
else:
print("done")
libvirt-python-4.0.0/examples/esxlist.py 0000775 0001750 0001750 00000012007 13211303124 022011 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# esxlist - list active domains of an ESX host and print some info.
# also demonstrates how to use the libvirt.openAuth() method
import libvirt
import sys
import os
import libxml2
import getpass
def usage():
print("Usage: %s HOSTNAME" % sys.argv[0])
print(" List active domains of HOSTNAME and print some info")
# This is the callback method passed to libvirt.openAuth() (see below).
#
# The credentials argument is a list of credentials that libvirt (actually
# the ESX driver) would like to request. An element of this list is itself a
# list containing 5 items (4 inputs, 1 output):
# - the credential type, e.g. libvirt.VIR_CRED_AUTHNAME
# - a prompt to be displayed to the user
# - a challenge, the ESX driver sets this to the hostname to allow automatic
# distinction between requests for ESX and vCenter credentials
# - a default result for the request
# - a place to store the actual result for the request
#
# The user_data argument is the user data item of the auth argument (see below)
# passed to libvirt.openAuth().
def request_credentials(credentials, user_data):
for credential in credentials:
if credential[0] == libvirt.VIR_CRED_AUTHNAME:
# prompt the user to input a authname. display the provided message
credential[4] = raw_input(credential[1] + ": ")
# if the user just hits enter raw_input() returns an empty string.
# in this case return the default result through the last item of
# the list
if len(credential[4]) == 0:
credential[4] = credential[3]
elif credential[0] == libvirt.VIR_CRED_NOECHOPROMPT:
# use the getpass module to prompt the user to input a password.
# display the provided message and return the result through the
# last item of the list
credential[4] = getpass.getpass(credential[1] + ": ")
else:
return -1
return 0
def print_section(title):
print("\n%s" % title)
print("=" * 60)
def print_entry(key, value):
print("%-10s %-10s" % (key, value))
def print_xml(key, ctx, path):
res = ctx.xpathEval(path)
if res is None or len(res) == 0:
value = "Unknown"
else:
value = res[0].content
print_entry(key, value)
return value
if len(sys.argv) != 2:
usage()
sys.exit(2)
hostname = sys.argv[1]
# Connect to libvirt
uri = "esx://%s/?no_verify=1" % hostname
# The auth argument is a list that contains 3 items:
# - a list of supported credential types
# - a callable that takes 2 arguments
# - user data that will be passed to the callable as second argument
#
# In this example the supported credential types are VIR_CRED_AUTHNAME and
# VIR_CRED_NOECHOPROMPT, the callable is the unbound method request_credentials
# (see above) and the user data is None.
#
# libvirt (actually the ESX driver) will call the callable to request
# credentials in order to log into the ESX host. The callable would also be
# called if the connection URI would reference a vCenter to request credentials
# in order to log into the vCenter
auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_NOECHOPROMPT],
request_credentials, None]
conn = libvirt.openAuth(uri, auth, 0)
if conn is None:
print("Failed to open connection to %s" % hostname)
sys.exit(1)
state_names = { libvirt.VIR_DOMAIN_RUNNING : "running",
libvirt.VIR_DOMAIN_BLOCKED : "idle",
libvirt.VIR_DOMAIN_PAUSED : "paused",
libvirt.VIR_DOMAIN_SHUTDOWN : "in shutdown",
libvirt.VIR_DOMAIN_SHUTOFF : "shut off",
libvirt.VIR_DOMAIN_CRASHED : "crashed",
libvirt.VIR_DOMAIN_NOSTATE : "no state" }
for id in conn.listDomainsID():
domain = conn.lookupByID(id)
info = domain.info()
print_section("Domain " + domain.name())
print_entry("ID:", id)
print_entry("UUID:", domain.UUIDString())
print_entry("State:", state_names[info[0]])
print_entry("MaxMem:", info[1])
print_entry("UsedMem:", info[2])
print_entry("VCPUs:", info[3])
# Read some info from the XML desc
print_section("Devices of " + domain.name())
xmldesc = domain.XMLDesc(0)
doc = libxml2.parseDoc(xmldesc)
ctx = doc.xpathNewContext()
devs = ctx.xpathEval("/domain/devices/*")
first = True
for d in devs:
ctx.setContextNode(d)
if not first:
print("------------------------------------------------------------")
else:
first = False
print_entry("Device", d.name)
type = print_xml("Type:", ctx, "@type")
if type == "file":
print_xml("Source:", ctx, "source/@file")
print_xml("Target:", ctx, "target/@dev")
elif type == "block":
print_xml("Source:", ctx, "source/@dev")
print_xml("Target:", ctx, "target/@dev")
elif type == "bridge":
print_xml("Source:", ctx, "source/@bridge")
print_xml("MAC Addr:", ctx, "mac/@address")
libvirt-python-4.0.0/examples/event-test.py 0000775 0001750 0001750 00000102065 13211303124 022420 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
#
#
#
##############################################################################
# Start off by implementing a general purpose event loop for anyone's use
##############################################################################
import sys
import getopt
import os
import libvirt
import select
import errno
import time
import threading
# This example can use three different event loop impls. It defaults
# to a portable pure-python impl based on poll that is implemented
# in this file.
#
# When Python >= 3.4, it can optionally use an impl based on the
# new asyncio module.
#
# Finally, it can also use the libvirt native event loop impl
#
# This setting thus allows 'poll', 'native' or 'asyncio' as valid
# choices
#
event_impl = "poll"
do_debug = False
def debug(msg):
global do_debug
if do_debug:
print(msg)
#
# This general purpose event loop will support waiting for file handle
# I/O and errors events, as well as scheduling repeatable timers with
# a fixed interval.
#
# It is a pure python implementation based around the poll() API
#
class virEventLoopPoll:
# This class contains the data we need to track for a
# single file handle
class virEventLoopPollHandle:
def __init__(self, handle, fd, events, cb, opaque):
self.handle = handle
self.fd = fd
self.events = events
self.cb = cb
self.opaque = opaque
def get_id(self):
return self.handle
def get_fd(self):
return self.fd
def get_events(self):
return self.events
def set_events(self, events):
self.events = events
def dispatch(self, events):
self.cb(self.handle,
self.fd,
events,
self.opaque)
# This class contains the data we need to track for a
# single periodic timer
class virEventLoopPollTimer:
def __init__(self, timer, interval, cb, opaque):
self.timer = timer
self.interval = interval
self.cb = cb
self.opaque = opaque
self.lastfired = 0
def get_id(self):
return self.timer
def get_interval(self):
return self.interval
def set_interval(self, interval):
self.interval = interval
def get_last_fired(self):
return self.lastfired
def set_last_fired(self, now):
self.lastfired = now
def dispatch(self):
self.cb(self.timer,
self.opaque)
def __init__(self):
self.poll = select.poll()
self.pipetrick = os.pipe()
self.pendingWakeup = False
self.runningPoll = False
self.nextHandleID = 1
self.nextTimerID = 1
self.handles = []
self.timers = []
self.cleanup = []
self.quit = False
# The event loop can be used from multiple threads at once.
# Specifically while the main thread is sleeping in poll()
# waiting for events to occur, another thread may come along
# and add/update/remove a file handle, or timer. When this
# happens we need to interrupt the poll() sleep in the other
# thread, so that it'll see the file handle / timer changes.
#
# Using OS level signals for this is very unreliable and
# hard to implement correctly. Thus we use the real classic
# "self pipe" trick. A anonymous pipe, with one end registered
# with the event loop for input events. When we need to force
# the main thread out of a poll() sleep, we simple write a
# single byte of data to the other end of the pipe.
debug("Self pipe watch %d write %d" %(self.pipetrick[0], self.pipetrick[1]))
self.poll.register(self.pipetrick[0], select.POLLIN)
# Calculate when the next timeout is due to occur, returning
# the absolute timestamp for the next timeout, or 0 if there is
# no timeout due
def next_timeout(self):
next = 0
for t in self.timers:
last = t.get_last_fired()
interval = t.get_interval()
if interval < 0:
continue
if next == 0 or (last + interval) < next:
next = last + interval
return next
# Lookup a virEventLoopPollHandle object based on file descriptor
def get_handle_by_fd(self, fd):
for h in self.handles:
if h.get_fd() == fd:
return h
return None
# Lookup a virEventLoopPollHandle object based on its event loop ID
def get_handle_by_id(self, handleID):
for h in self.handles:
if h.get_id() == handleID:
return h
return None
# This is the heart of the event loop, performing one single
# iteration. It asks when the next timeout is due, and then
# calculates the maximum amount of time it is able to sleep
# for in poll() pending file handle events.
#
# It then goes into the poll() sleep.
#
# When poll() returns, there will zero or more file handle
# events which need to be dispatched to registered callbacks
# It may also be time to fire some periodic timers.
#
# Due to the coarse granularity of scheduler timeslices, if
# we ask for a sleep of 500ms in order to satisfy a timer, we
# may return up to 1 scheduler timeslice early. So even though
# our sleep timeout was reached, the registered timer may not
# technically be at its expiry point. This leads to us going
# back around the loop with a crazy 5ms sleep. So when checking
# if timeouts are due, we allow a margin of 20ms, to avoid
# these pointless repeated tiny sleeps.
def run_once(self):
sleep = -1
self.runningPoll = True
for opaque in self.cleanup:
libvirt.virEventInvokeFreeCallback(opaque)
self.cleanup = []
try:
next = self.next_timeout()
debug("Next timeout due at %d" % next)
if next > 0:
now = int(time.time() * 1000)
if now >= next:
sleep = 0
else:
sleep = (next - now) / 1000.0
debug("Poll with a sleep of %d" % sleep)
events = self.poll.poll(sleep)
# Dispatch any file handle events that occurred
for (fd, revents) in events:
# See if the events was from the self-pipe
# telling us to wakup. if so, then discard
# the data just continue
if fd == self.pipetrick[0]:
self.pendingWakeup = False
data = os.read(fd, 1)
continue
h = self.get_handle_by_fd(fd)
if h:
debug("Dispatch fd %d handle %d events %d" % (fd, h.get_id(), revents))
h.dispatch(self.events_from_poll(revents))
now = int(time.time() * 1000)
for t in self.timers:
interval = t.get_interval()
if interval < 0:
continue
want = t.get_last_fired() + interval
# Deduct 20ms, since scheduler timeslice
# means we could be ever so slightly early
if now >= (want-20):
debug("Dispatch timer %d now %s want %s" % (t.get_id(), str(now), str(want)))
t.set_last_fired(now)
t.dispatch()
except (os.error, select.error) as e:
if e.args[0] != errno.EINTR:
raise
finally:
self.runningPoll = False
# Actually run the event loop forever
def run_loop(self):
self.quit = False
while not self.quit:
self.run_once()
def interrupt(self):
if self.runningPoll and not self.pendingWakeup:
self.pendingWakeup = True
os.write(self.pipetrick[1], 'c'.encode("UTF-8"))
# Registers a new file handle 'fd', monitoring for 'events' (libvirt
# event constants), firing the callback cb() when an event occurs.
# Returns a unique integer identier for this handle, that should be
# used to later update/remove it
def add_handle(self, fd, events, cb, opaque):
handleID = self.nextHandleID + 1
self.nextHandleID = self.nextHandleID + 1
h = self.virEventLoopPollHandle(handleID, fd, events, cb, opaque)
self.handles.append(h)
self.poll.register(fd, self.events_to_poll(events))
self.interrupt()
debug("Add handle %d fd %d events %d" % (handleID, fd, events))
return handleID
# Registers a new timer with periodic expiry at 'interval' ms,
# firing cb() each time the timer expires. If 'interval' is -1,
# then the timer is registered, but not enabled
# Returns a unique integer identier for this handle, that should be
# used to later update/remove it
def add_timer(self, interval, cb, opaque):
timerID = self.nextTimerID + 1
self.nextTimerID = self.nextTimerID + 1
h = self.virEventLoopPollTimer(timerID, interval, cb, opaque)
self.timers.append(h)
self.interrupt()
debug("Add timer %d interval %d" % (timerID, interval))
return timerID
# Change the set of events to be monitored on the file handle
def update_handle(self, handleID, events):
h = self.get_handle_by_id(handleID)
if h:
h.set_events(events)
self.poll.unregister(h.get_fd())
self.poll.register(h.get_fd(), self.events_to_poll(events))
self.interrupt()
debug("Update handle %d fd %d events %d" % (handleID, h.get_fd(), events))
# Change the periodic frequency of the timer
def update_timer(self, timerID, interval):
for h in self.timers:
if h.get_id() == timerID:
h.set_interval(interval)
self.interrupt()
debug("Update timer %d interval %d" % (timerID, interval))
break
# Stop monitoring for events on the file handle
def remove_handle(self, handleID):
handles = []
for h in self.handles:
if h.get_id() == handleID:
debug("Remove handle %d fd %d" % (handleID, h.get_fd()))
self.poll.unregister(h.get_fd())
self.cleanup.append(h.opaque)
else:
handles.append(h)
self.handles = handles
self.interrupt()
# Stop firing the periodic timer
def remove_timer(self, timerID):
timers = []
for h in self.timers:
if h.get_id() != timerID:
timers.append(h)
else:
debug("Remove timer %d" % timerID)
self.cleanup.append(h.opaque)
self.timers = timers
self.interrupt()
# Convert from libvirt event constants, to poll() events constants
def events_to_poll(self, events):
ret = 0
if events & libvirt.VIR_EVENT_HANDLE_READABLE:
ret |= select.POLLIN
if events & libvirt.VIR_EVENT_HANDLE_WRITABLE:
ret |= select.POLLOUT
if events & libvirt.VIR_EVENT_HANDLE_ERROR:
ret |= select.POLLERR
if events & libvirt.VIR_EVENT_HANDLE_HANGUP:
ret |= select.POLLHUP
return ret
# Convert from poll() event constants, to libvirt events constants
def events_from_poll(self, events):
ret = 0
if events & select.POLLIN:
ret |= libvirt.VIR_EVENT_HANDLE_READABLE
if events & select.POLLOUT:
ret |= libvirt.VIR_EVENT_HANDLE_WRITABLE
if events & select.POLLNVAL:
ret |= libvirt.VIR_EVENT_HANDLE_ERROR
if events & select.POLLERR:
ret |= libvirt.VIR_EVENT_HANDLE_ERROR
if events & select.POLLHUP:
ret |= libvirt.VIR_EVENT_HANDLE_HANGUP
return ret
###########################################################################
# Now glue an instance of the general event loop into libvirt's event loop
###########################################################################
# This single global instance of the event loop wil be used for
# monitoring libvirt events
eventLoop = virEventLoopPoll()
# This keeps track of what thread is running the event loop,
# (if it is run in a background thread)
eventLoopThread = None
# These next set of 6 methods are the glue between the official
# libvirt events API, and our particular impl of the event loop
#
# There is no reason why the 'virEventLoopPoll' has to be used.
# An application could easily may these 6 glue methods hook into
# another event loop such as GLib's, or something like the python
# Twisted event framework.
def virEventAddHandleImpl(fd, events, cb, opaque):
global eventLoop
return eventLoop.add_handle(fd, events, cb, opaque)
def virEventUpdateHandleImpl(handleID, events):
global eventLoop
return eventLoop.update_handle(handleID, events)
def virEventRemoveHandleImpl(handleID):
global eventLoop
return eventLoop.remove_handle(handleID)
def virEventAddTimerImpl(interval, cb, opaque):
global eventLoop
return eventLoop.add_timer(interval, cb, opaque)
def virEventUpdateTimerImpl(timerID, interval):
global eventLoop
return eventLoop.update_timer(timerID, interval)
def virEventRemoveTimerImpl(timerID):
global eventLoop
return eventLoop.remove_timer(timerID)
# This tells libvirt what event loop implementation it
# should use
def virEventLoopPollRegister():
libvirt.virEventRegisterImpl(virEventAddHandleImpl,
virEventUpdateHandleImpl,
virEventRemoveHandleImpl,
virEventAddTimerImpl,
virEventUpdateTimerImpl,
virEventRemoveTimerImpl)
# Directly run the event loop in the current thread
def virEventLoopPollRun():
global eventLoop
eventLoop.run_loop()
def virEventLoopAIORun(loop):
import asyncio
asyncio.set_event_loop(loop)
loop.run_forever()
def virEventLoopNativeRun():
while True:
libvirt.virEventRunDefaultImpl()
# Spawn a background thread to run the event loop
def virEventLoopPollStart():
global eventLoopThread
virEventLoopPollRegister()
eventLoopThread = threading.Thread(target=virEventLoopPollRun, name="libvirtEventLoop")
eventLoopThread.setDaemon(True)
eventLoopThread.start()
def virEventLoopAIOStart():
global eventLoopThread
import libvirtaio
import asyncio
loop = asyncio.new_event_loop()
libvirtaio.virEventRegisterAsyncIOImpl(loop=loop)
eventLoopThread = threading.Thread(target=virEventLoopAIORun, args=(loop,), name="libvirtEventLoop")
eventLoopThread.setDaemon(True)
eventLoopThread.start()
def virEventLoopNativeStart():
global eventLoopThread
libvirt.virEventRegisterDefaultImpl()
eventLoopThread = threading.Thread(target=virEventLoopNativeRun, name="libvirtEventLoop")
eventLoopThread.setDaemon(True)
eventLoopThread.start()
##########################################################################
# Everything that now follows is a simple demo of domain lifecycle events
##########################################################################
def domEventToString(event):
domEventStrings = ( "Defined",
"Undefined",
"Started",
"Suspended",
"Resumed",
"Stopped",
"Shutdown",
"PMSuspended",
"Crashed",
)
return domEventStrings[event]
def domDetailToString(event, detail):
domEventStrings = (
( "Added", "Updated" ),
( "Removed", ),
( "Booted", "Migrated", "Restored", "Snapshot", "Wakeup" ),
( "Paused", "Migrated", "IOError", "Watchdog", "Restored", "Snapshot", "API error" ),
( "Unpaused", "Migrated", "Snapshot" ),
( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot"),
( "Finished", "On guest request", "On host request"),
( "Memory", "Disk" ),
( "Panicked", ),
)
return domEventStrings[event][detail]
def blockJobTypeToString(type):
blockJobTypes = ( "unknown", "Pull", "Copy", "Commit", "ActiveCommit", )
return blockJobTypes[type]
def blockJobStatusToString(status):
blockJobStatus = ( "Completed", "Failed", "Canceled", "Ready", )
return blockJobStatus[status]
def agentLifecycleStateToString(state):
agentStates = ( "unknown", "connected", "disconnected", )
return agentStates[state]
def agentLifecycleReasonToString(reason):
agentReasons = ( "unknown", "domain started", "channel event", )
return agentReasons[reason]
def myDomainEventCallback1 (conn, dom, event, detail, opaque):
print("myDomainEventCallback1 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
domEventToString(event),
domDetailToString(event, detail)))
def myDomainEventCallback2 (conn, dom, event, detail, opaque):
print("myDomainEventCallback2 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
domEventToString(event),
domDetailToString(event, detail)))
def myDomainEventRebootCallback(conn, dom, opaque):
print("myDomainEventRebootCallback: Domain %s(%s)" % (dom.name(), dom.ID()))
def myDomainEventRTCChangeCallback(conn, dom, utcoffset, opaque):
print("myDomainEventRTCChangeCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), utcoffset))
def myDomainEventWatchdogCallback(conn, dom, action, opaque):
print("myDomainEventWatchdogCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), action))
def myDomainEventIOErrorCallback(conn, dom, srcpath, devalias, action, opaque):
print("myDomainEventIOErrorCallback: Domain %s(%s) %s %s %d" % (dom.name(), dom.ID(), srcpath, devalias, action))
def myDomainEventIOErrorReasonCallback(conn, dom, srcpath, devalias, action, reason, opaque):
print("myDomainEventIOErrorReasonCallback: Domain %s(%s) %s %s %d %s" % (dom.name(), dom.ID(), srcpath, devalias, action, reason))
def myDomainEventGraphicsCallback(conn, dom, phase, localAddr, remoteAddr, authScheme, subject, opaque):
print("myDomainEventGraphicsCallback: Domain %s(%s) %d %s" % (dom.name(), dom.ID(), phase, authScheme))
def myDomainEventControlErrorCallback(conn, dom, opaque):
print("myDomainEventControlErrorCallback: Domain %s(%s)" % (dom.name(), dom.ID()))
def myDomainEventBlockJobCallback(conn, dom, disk, type, status, opaque):
print("myDomainEventBlockJobCallback: Domain %s(%s) %s on disk %s %s" % (dom.name(), dom.ID(), blockJobTypeToString(type), disk, blockJobStatusToString(status)))
def myDomainEventDiskChangeCallback(conn, dom, oldSrcPath, newSrcPath, devAlias, reason, opaque):
print("myDomainEventDiskChangeCallback: Domain %s(%s) disk change oldSrcPath: %s newSrcPath: %s devAlias: %s reason: %s" % (
dom.name(), dom.ID(), oldSrcPath, newSrcPath, devAlias, reason))
def myDomainEventTrayChangeCallback(conn, dom, devAlias, reason, opaque):
print("myDomainEventTrayChangeCallback: Domain %s(%s) tray change devAlias: %s reason: %s" % (
dom.name(), dom.ID(), devAlias, reason))
def myDomainEventPMWakeupCallback(conn, dom, reason, opaque):
print("myDomainEventPMWakeupCallback: Domain %s(%s) system pmwakeup" % (
dom.name(), dom.ID()))
def myDomainEventPMSuspendCallback(conn, dom, reason, opaque):
print("myDomainEventPMSuspendCallback: Domain %s(%s) system pmsuspend" % (
dom.name(), dom.ID()))
def myDomainEventBalloonChangeCallback(conn, dom, actual, opaque):
print("myDomainEventBalloonChangeCallback: Domain %s(%s) %d" % (dom.name(), dom.ID(), actual))
def myDomainEventPMSuspendDiskCallback(conn, dom, reason, opaque):
print("myDomainEventPMSuspendDiskCallback: Domain %s(%s) system pmsuspend_disk" % (
dom.name(), dom.ID()))
def myDomainEventDeviceRemovedCallback(conn, dom, dev, opaque):
print("myDomainEventDeviceRemovedCallback: Domain %s(%s) device removed: %s" % (
dom.name(), dom.ID(), dev))
def myDomainEventBlockJob2Callback(conn, dom, disk, type, status, opaque):
print("myDomainEventBlockJob2Callback: Domain %s(%s) %s on disk %s %s" % (dom.name(), dom.ID(), blockJobTypeToString(type), disk, blockJobStatusToString(status)))
def myDomainEventTunableCallback(conn, dom, params, opaque):
print("myDomainEventTunableCallback: Domain %s(%s) %s" % (dom.name(), dom.ID(), params))
def myDomainEventAgentLifecycleCallback(conn, dom, state, reason, opaque):
print("myDomainEventAgentLifecycleCallback: Domain %s(%s) %s %s" % (dom.name(), dom.ID(), agentLifecycleStateToString(state), agentLifecycleReasonToString(reason)))
def myDomainEventDeviceAddedCallback(conn, dom, dev, opaque):
print("myDomainEventDeviceAddedCallback: Domain %s(%s) device added: %s" % (
dom.name(), dom.ID(), dev))
def myDomainEventMigrationIteration(conn, dom, iteration, opaque):
print("myDomainEventMigrationIteration: Domain %s(%s) started migration iteration %d" % (
dom.name(), dom.ID(), iteration))
def myDomainEventJobCompletedCallback(conn, dom, params, opaque):
print("myDomainEventJobCompletedCallback: Domain %s(%s) %s" % (dom.name(), dom.ID(), params))
def myDomainEventDeviceRemovalFailedCallback(conn, dom, dev, opaque):
print("myDomainEventDeviceRemovalFailedCallback: Domain %s(%s) failed to remove device: %s" % (
dom.name(), dom.ID(), dev))
def myDomainEventMetadataChangeCallback(conn, dom, mtype, nsuri, opaque):
print("myDomainEventMetadataChangeCallback: Domain %s(%s) changed metadata mtype=%d nsuri=%s" % (
dom.name(), dom.ID(), mtype, nsuri))
def myDomainEventBlockThresholdCallback(conn, dom, dev, path, threshold, excess, opaque):
print("myDomainEventBlockThresholdCallback: Domain %s(%s) block device %s(%s) threshold %d exceeded by %d" % (
dom.name(), dom.ID(), dev, path, threshold, excess))
##########################################################################
# Network events
##########################################################################
def netEventToString(event):
netEventStrings = ( "Defined",
"Undefined",
"Started",
"Stopped",
)
return netEventStrings[event]
def netDetailToString(event, detail):
netEventStrings = (
( "Added", ),
( "Removed", ),
( "Started", ),
( "Stopped", ),
)
return netEventStrings[event][detail]
def myNetworkEventLifecycleCallback(conn, net, event, detail, opaque):
print("myNetworkEventLifecycleCallback: Network %s %s %s" % (net.name(),
netEventToString(event),
netDetailToString(event, detail)))
##########################################################################
# Storage pool events
##########################################################################
def storageEventToString(event):
storageEventStrings = ( "Defined",
"Undefined",
"Started",
"Stopped",
)
return storageEventStrings[event]
def myStoragePoolEventLifecycleCallback(conn, pool, event, detail, opaque):
print("myStoragePoolEventLifecycleCallback: Storage pool %s %s %d" % (pool.name(),
storageEventToString(event),
detail))
def myStoragePoolEventRefreshCallback(conn, pool, opaque):
print("myStoragePoolEventRefreshCallback: Storage pool %s" % pool.name())
##########################################################################
# Node device events
##########################################################################
def nodeDeviceEventToString(event):
nodeDeviceEventStrings = ( "Created",
"Deleted",
)
return nodeDeviceEventStrings[event]
def myNodeDeviceEventLifecycleCallback(conn, dev, event, detail, opaque):
print("myNodeDeviceEventLifecycleCallback: Node device %s %s %d" % (dev.name(),
nodeDeviceEventToString(event),
detail))
def myNodeDeviceEventUpdateCallback(conn, dev, opaque):
print("myNodeDeviceEventUpdateCallback: Node device %s" % dev.name())
##########################################################################
# Secret events
##########################################################################
def secretEventToString(event):
secretEventStrings = ( "Defined",
"Undefined",
)
return secretEventStrings[event]
def mySecretEventLifecycleCallback(conn, secret, event, detail, opaque):
print("mySecretEventLifecycleCallback: Secret %s %s %d" % (secret.UUIDString(),
secretEventToString(event),
detail))
def mySecretEventValueChanged(conn, secret, opaque):
print("mySecretEventValueChanged: Secret %s" % secret.UUIDString())
##########################################################################
# Set up and run the program
##########################################################################
run = True
def myConnectionCloseCallback(conn, reason, opaque):
reasonStrings = (
"Error", "End-of-file", "Keepalive", "Client",
)
print("myConnectionCloseCallback: %s: %s" % (conn.getURI(), reasonStrings[reason]))
run = False
def usage():
print("usage: "+os.path.basename(sys.argv[0])+" [-hdl] [uri]")
print(" uri will default to qemu:///system")
print(" --help, -h Print(this help message")
print(" --debug, -d Print(debug output")
print(" --loop=TYPE, -l Choose event-loop-implementation (native, poll, asyncio)")
print(" --timeout=SECS Quit after SECS seconds running")
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "hdl:", ["help", "debug", "loop=", "timeout="])
except getopt.GetoptError as err:
# print help information and exit:
print(str(err)) # will print something like "option -a not recognized"
usage()
sys.exit(2)
timeout = None
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
if o in ("-d", "--debug"):
global do_debug
do_debug = True
if o in ("-l", "--loop"):
global event_impl
event_impl = a
if o in ("--timeout"):
timeout = int(a)
if len(args) >= 1:
uri = args[0]
else:
uri = "qemu:///system"
print("Using uri '%s' and event loop '%s'" % (uri, event_impl))
# Run a background thread with the event loop
if event_impl == "poll":
virEventLoopPollStart()
elif event_impl == "asyncio":
virEventLoopAIOStart()
else:
virEventLoopNativeStart()
vc = libvirt.openReadOnly(uri)
# Close connection on exit (to test cleanup paths)
old_exitfunc = getattr(sys, 'exitfunc', None)
def exit():
print("Closing " + vc.getURI())
vc.close()
if (old_exitfunc): old_exitfunc()
sys.exitfunc = exit
vc.registerCloseCallback(myConnectionCloseCallback, None)
#Add 2 lifecycle callbacks to prove this works with more than just one
vc.domainEventRegister(myDomainEventCallback1,None)
domcallbacks = []
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, myDomainEventCallback2, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_REBOOT, myDomainEventRebootCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_RTC_CHANGE, myDomainEventRTCChangeCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_WATCHDOG, myDomainEventWatchdogCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR, myDomainEventIOErrorCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_GRAPHICS, myDomainEventGraphicsCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON, myDomainEventIOErrorReasonCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_CONTROL_ERROR, myDomainEventControlErrorCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BLOCK_JOB, myDomainEventBlockJobCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DISK_CHANGE, myDomainEventDiskChangeCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_TRAY_CHANGE, myDomainEventTrayChangeCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMWAKEUP, myDomainEventPMWakeupCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMSUSPEND, myDomainEventPMSuspendCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE, myDomainEventBalloonChangeCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK, myDomainEventPMSuspendDiskCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, myDomainEventDeviceRemovedCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2, myDomainEventBlockJob2Callback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_TUNABLE, myDomainEventTunableCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_AGENT_LIFECYCLE, myDomainEventAgentLifecycleCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_ADDED, myDomainEventDeviceAddedCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_MIGRATION_ITERATION, myDomainEventMigrationIteration, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_JOB_COMPLETED, myDomainEventJobCompletedCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, myDomainEventDeviceRemovalFailedCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_METADATA_CHANGE, myDomainEventMetadataChangeCallback, None))
domcallbacks.append(vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD, myDomainEventBlockThresholdCallback, None))
netcallbacks = []
netcallbacks.append(vc.networkEventRegisterAny(None, libvirt.VIR_NETWORK_EVENT_ID_LIFECYCLE, myNetworkEventLifecycleCallback, None))
poolcallbacks = []
poolcallbacks.append(vc.storagePoolEventRegisterAny(None, libvirt.VIR_STORAGE_POOL_EVENT_ID_LIFECYCLE, myStoragePoolEventLifecycleCallback, None))
poolcallbacks.append(vc.storagePoolEventRegisterAny(None, libvirt.VIR_STORAGE_POOL_EVENT_ID_REFRESH, myStoragePoolEventRefreshCallback, None))
devcallbacks = []
devcallbacks.append(vc.nodeDeviceEventRegisterAny(None, libvirt.VIR_NODE_DEVICE_EVENT_ID_LIFECYCLE, myNodeDeviceEventLifecycleCallback, None))
devcallbacks.append(vc.nodeDeviceEventRegisterAny(None, libvirt.VIR_NODE_DEVICE_EVENT_ID_UPDATE, myNodeDeviceEventUpdateCallback, None))
seccallbacks = []
seccallbacks.append(vc.secretEventRegisterAny(None, libvirt.VIR_SECRET_EVENT_ID_LIFECYCLE, mySecretEventLifecycleCallback, None))
seccallbacks.append(vc.secretEventRegisterAny(None, libvirt.VIR_SECRET_EVENT_ID_VALUE_CHANGED, mySecretEventValueChanged, None))
vc.setKeepAlive(5, 3)
# The rest of your app would go here normally, but for sake
# of demo we'll just go to sleep. The other option is to
# run the event loop in your main thread if your app is
# totally event based.
count = 0
while run and (timeout is None or count < timeout):
count = count + 1
time.sleep(1)
vc.domainEventDeregister(myDomainEventCallback1)
for id in seccallbacks:
vc.secretEventDeregisterAny(id)
for id in devcallbacks:
vc.nodeDeviceEventDeregisterAny(id)
for id in poolcallbacks:
vc.storagePoolEventDeregisterAny(id)
for id in netcallbacks:
vc.networkEventDeregisterAny(id)
for id in domcallbacks:
vc.domainEventDeregisterAny(id)
vc.unregisterCloseCallback()
vc.close()
# Allow delayed event loop cleanup to run, just for sake of testing
time.sleep(2)
if __name__ == "__main__":
main()
libvirt-python-4.0.0/examples/nodestats.py 0000775 0001750 0001750 00000005201 13211303124 022320 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# Print some host NUMA node statistics
#
# Authors:
# Michal Privoznik
import libvirt
import sys
from xml.dom import minidom
import libxml2
def xpath_eval(ctxt, path):
res = ctxt.xpathEval(path)
if res is None or len(res) == 0:
value = None
else:
value = res[0].content
return value
try:
conn = libvirt.openReadOnly(None)
except libvirt.libvirtError:
print("Failed to connect to the hypervisor")
sys.exit(1)
try:
capsXML = conn.getCapabilities()
except libvirt.libvirtError:
print("Failed to request capabilities")
sys.exit(1)
caps = minidom.parseString(capsXML)
cells = caps.getElementsByTagName("cells")[0]
nodesIDs = [ int(proc.getAttribute("id"))
for proc in cells.getElementsByTagName("cell") ]
nodesMem = [ conn.getMemoryStats(int(proc))
for proc in nodesIDs]
doms = conn.listAllDomains(libvirt.VIR_CONNECT_LIST_DOMAINS_ACTIVE)
domsStrict = [ proc
for proc in doms
if proc.numaParameters()["numa_mode"] == libvirt.VIR_DOMAIN_NUMATUNE_MEM_STRICT ]
domsStrictCfg = {}
for dom in domsStrict:
xmlStr = dom.XMLDesc()
doc = libxml2.parseDoc(xmlStr)
ctxt = doc.xpathNewContext()
domsStrictCfg[dom] = {}
pin = ctxt.xpathEval("string(/domain/numatune/memory/@nodeset)")
memsize = ctxt.xpathEval("string(/domain/memory)")
domsStrictCfg[dom]["memory"] = {"size": int(memsize), "pin": pin}
for memnode in ctxt.xpathEval("/domain/numatune/memnode"):
ctxt.setContextNode(memnode)
cellid = xpath_eval(ctxt, "@cellid")
nodeset = xpath_eval(ctxt, "@nodeset")
nodesize = xpath_eval(ctxt, "/domain/cpu/numa/cell[@id='%s']/@memory" % cellid)
domsStrictCfg[dom][cellid] = {"size": int(nodesize), "pin": nodeset}
print("NUMA stats")
print("NUMA nodes:\t" + "\t".join(str(node) for node in nodesIDs))
print("MemTotal:\t" + "\t".join(str(i.get("total") // 1024) for i in nodesMem))
print("MemFree:\t" + "\t".join(str(i.get("free") // 1024) for i in nodesMem))
for dom, v in domsStrictCfg.items():
print("Domain '%s':\t" % dom.name())
toPrint = "\tOverall memory: %d MiB" % (v["memory"]["size"] // 1024)
if v["memory"]["pin"] is not None and v["memory"]["pin"] is not "":
toPrint = toPrint + " nodes %s" % v["memory"]["pin"]
print(toPrint)
for k, node in sorted(v.items()):
if k is "memory":
continue
toPrint = "\tNode %s:\t%d MiB" % (k, node["size"] // 1024)
if node["pin"] is not None and node["pin"] is not "":
toPrint = toPrint + " nodes %s" % node["pin"]
print(toPrint)
libvirt-python-4.0.0/examples/topology.py 0000775 0001750 0001750 00000002411 13211303124 022170 0 ustar veillard veillard 0000000 0000000 #!/usr/bin/env python
# Parse topology information from the capabilities XML and use
# them to calculate host topology
#
# Authors:
# Amador Pahim
# Peter Krempa
import libvirt
import sys
from xml.dom import minidom
try:
conn = libvirt.openReadOnly(None)
except libvirt.libvirtError:
print('Failed to connect to the hypervisor')
sys.exit(1)
try:
capsXML = conn.getCapabilities()
except libvirt.libvirtError:
print('Failed to request capabilities')
sys.exit(1)
caps = minidom.parseString(capsXML)
host = caps.getElementsByTagName('host')[0]
cells = host.getElementsByTagName('cells')[0]
total_cpus = cells.getElementsByTagName('cpu').length
socketIds = []
siblingsIds = []
socketIds = [ proc.getAttribute('socket_id')
for proc in cells.getElementsByTagName('cpu')
if proc.getAttribute('socket_id') not in socketIds ]
siblingsIds = [ proc.getAttribute('siblings')
for proc in cells.getElementsByTagName('cpu')
if proc.getAttribute('siblings') not in siblingsIds ]
print("Host topology")
print("NUMA nodes:", cells.getAttribute('num'))
print(" Sockets:", len(set(socketIds)))
print(" Cores:", len(set(siblingsIds)))
print(" Threads:", total_cpus)
libvirt-python-4.0.0/tests/ 0000775 0001750 0001750 00000000000 13230351500 017267 5 ustar veillard veillard 0000000 0000000 libvirt-python-4.0.0/tests/test_conn.py 0000664 0001750 0001750 00000000651 13211303124 021635 0 ustar veillard veillard 0000000 0000000
import unittest
import libvirt
class TestLibvirtConn(unittest.TestCase):
def setUp(self):
self.conn = libvirt.open("test:///default")
def tearDown(self):
self.conn = None
def testConnDomainList(self):
doms = self.conn.listAllDomains()
self.assertEquals(len(doms), 1)
self.assertEquals(type(doms[0]), libvirt.virDomain)
self.assertEquals(doms[0].name(), "test")
libvirt-python-4.0.0/tests/test_domain.py 0000664 0001750 0001750 00000001015 13211303124 022142 0 ustar veillard veillard 0000000 0000000
import unittest
import libvirt
class TestLibvirtDomain(unittest.TestCase):
def setUp(self):
self.conn = libvirt.open("test:///default")
self.dom = self.conn.lookupByName("test")
def tearDown(self):
self.dom = None
self.conn = None
def testDomainSchedParams(self):
params = self.dom.schedulerParameters()
self.assertEquals(len(params), 1)
self.assertTrue("weight" in params)
params["weight"] = 100
self.dom.setSchedulerParameters(params)
libvirt-python-4.0.0/AUTHORS 0000664 0001750 0001750 00000006256 13230351500 017206 0 ustar veillard veillard 0000000 0000000 Libvirt Python Binding Authors
==============================
The libvirt python binding is maintained by the
libvirt development team, who can be contacted
at
libvir-list@redhat.com
The individual contributors are
Adam Litke
Alex Jia
Brian Rak
Chris Lalancette
Claudio Bley
Cole Robinson
Cédric Bosdonnat
Dan Kenigsberg
Daniel P. Berrange
Daniel Veillard
Diego Elio Pettenò
Dmitry Guryanov
Don Dugger
Doug Goldstein
Eric Blake
Federico Simoncelli
Giuseppe Scrivano
Guan Qiang
Guannan Ren
Gui Jianfeng
Guido Günther
Hu Tao
Jason Andryuk
Jim Fehlig
Jim Meyering
Jiri Denemark
John Ferlan
Jovanka Gulicoska
Ján Tomko
KAMEZAWA Hiroyuki
Konstantin Neumoin
Lai Jiangshan
Laine Stump
Lei Li
Luyao Huang
Marcelo Cerri
Marian Neagul
Mark McLoughlin
Markus Rothe
Martin Kletzander
MATSUDA Daiki
Matthias Bolte
Michal Privoznik
Miloslav Trmač
Minoru Usui
Mo Yuxiang
Nehal J Wani
Nikunj A. Dadhania
Nir Soffer
Osier Yang
Oskari Saarenmaa
Pavel Boldin
Pavel Hrdina
Peng Hao
Peter Krempa
Philipp Hahn
Prabodh Agarwal
Pradipta Kr. Banerjee
Qiaowei Ren
Richard W.M. Jones
Robie Basak
Serge E. Hallyn
Stefan Berger
Taizo ITO
Taku Izumi
Tomoki Sekiyama
Tomáš Golembiovský
Victor Stinner
Viktor Mihajlovski
Wojtek Porczyk
Wu Zongyong
Xavier Fernandez
Zeeshan Ali (Khattak)
Zhou Yimin
libvirt-python-4.0.0/COPYING 0000664 0001750 0001750 00000043254 13211303124 017166 0 ustar veillard veillard 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
libvirt-python-4.0.0/COPYING.LESSER 0000664 0001750 0001750 00000063642 13211303124 020165 0 ustar veillard veillard 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
libvirt-python-4.0.0/ChangeLog 0000664 0001750 0001750 00001050542 13230351500 017706 0 ustar veillard veillard 0000000 0000000 2018-01-19 Daniel Veillard
Release of libvirt-python-4.0.0
2018-01-12 Daniel P. Berrange
Use python*_sitearch macros instead of manually defining the dir
Note we use python_sitearch not python2_sitearch, since the former
is more portable.
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Fix filtering of RPM provides for .so files
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Require libvirt native version matching py version by default
Although we're capable of building against any libvirt >= 0.9.11, 99% of the
time we want RPM builds to be done against matching libvirt version, otherwise
we might silently build against an unexpected/wrong version.
We don't support building against a native libvirt that's newer than the
python binding, since the generator may incorrectly handle new APIs. So use
== instead of >= too.
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Turn on python3 sub-RPMs for RHEL > 7
It is expected that future RHEL-8 will have python3 by default, so enable that.
It is unclear whether python2 will still be available, so leave that enabled
for now.
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Adapt to rename of py2 RPMs from python- to python2- prefix
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Add emacs mode marker to activate rpm-spec highlighting
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Add checks for min supported distros
Be clear about which distros we aim to support with the specfile, so we know
what we can cleanup in the spec later.
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Allow override of which sub-RPMs to build
Allow using
rpmbuild --define "with_python2 0"
to override the default logic about which python sub-RPMs to build
Reviewed-by: Pavel Hrdina
2018-01-12 Daniel P. Berrange
Allow disabling of python2 RPM build
With Fedora modularity, it is possible to have add-on repos for multiple
versions of python3. It is thus desirable to be able to build libvirt-python
in these repos, with only the python3 sub-RPMs enabled.
Thus also helps if future RHEL/Fedora drop python2 entirely from their default
repos.
Reviewed-by: Pavel Hrdina
2017-12-11 Peng Hao
libvirt-python : PyObject memory leak
libvirt_virConnectDomainEventTunableCallback leak a PyObject.
2017-12-04 Daniel Veillard
Release of libvirt-python 3.10.0
2017-11-30 Cédric Bosdonnat
Don't hardcode interpreter path
This is particularly useful on operating systems that don't ship
Python as part of the base system (eg. FreeBSD) while still working
just as well as it did before on Linux.
Reviewed-by: Daniel P. Berrange
2017-11-02 Daniel Veillard
Release of libvirt-python-3.9.0
2017-09-29 Nir Soffer
Unify whitespace around *_ALLOW_THREADS macros
Most of the code treats libvirt API calls as separate block, keeping one
blank line before the LIBVIRT_BEGIN_ALLOW_THREAD, and one blank line
after LIBVIRT_END_ALLOW_THREADS. Unify the whitespace so all calls
wrapped with these macros are treated as a separate block.
2017-09-27 Nir Soffer
Release the GIL during virDomainGetMemoryStats & virDomainGetDiskErrors
We discovered that the entire python process get stuck for about 30
seconds when calling virDomain.getMemoryStats() if libvirt is stuck in
virConnect.getAllDomainStats() on inaccessible storage. This blocking
cause a horrible mess in oVirt.
This patches adds the standard *_ALLOW_THREADS around the call to avoid
this unwanted blocking.
2017-09-26 Daniel P. Berrange
Avoid implicit treatment of an arithmetic result as a boolean
Latest GCC versions are unhappy with us treating an integer
arithmetic result as a boolean:
libvirt-utils.c: In function ‘virReallocN’:
libvirt-utils.c:111:23: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
if (!tmp && (size * count)) {
~~~~~~^~~~~~~~
Add an explicit comparison '!= 0' to keep it happy, since its
suggestion to use '&&' is nonsense.
2017-09-26 Daniel P. Berrange
Fix comparisons between signed & unsigned integers
When python3 builds C modules, it adds the -Wsign-compare flag to GCC.
This creates lots of warnings where we compare a 'size_t' value against
an 'int' value due to signed/unsigned difference. Change all the size_t
types to ssize_t to address this.
2017-09-26 Wojtek Porczyk
libvirtaio: add .drain() coroutine
The intended use is to ensure that the implementation is empty, which is
one way to ensure that all connections were properly closed and file
descriptors reclaimed.
2017-09-26 Wojtek Porczyk
libvirtaio: keep track of the current implementation
Since 7534c19 it is not possible to register event implementation twice.
Instead, allow for retrieving the current one, should it be needed
afterwards.
2017-09-26 Wojtek Porczyk
libvirtaio: fix closing of the objects
- Descriptor.close() was a dead code, never used.
- TimeoutCallback.close(), as a cleanup function, should have called
super() as last statement, not first
2017-09-26 Wojtek Porczyk
libvirtaio: do not double-add callbacks
This was a harmless bug, without any impact, but it is wrong to manage
the collection of callbacks from it's members.
2017-09-26 Wojtek Porczyk
libvirtaio: cache the list of callbacks when calling
When the callback causes something that results in changes wrt
registered handles, python aborts iteration.
Relevant error message:
Exception in callback None()
handle:
Traceback (most recent call last):
File "/usr/lib64/python3.5/asyncio/events.py", line 126, in _run
self._callback(*self._args)
File "/usr/lib64/python3.5/site-packages/libvirtaio.py", line 99, in _handle
for callback in self.callbacks.values():
RuntimeError: dictionary changed size during iteration
QubesOS/qubes-issues#2805
2017-09-26 Wojtek Porczyk
libvirtaio: add more debug logging
This logging is helpful for tracing problems with unclosed connections
and leaking file descriptors.
2017-09-19 Daniel P. Berrange
Add travis build config
Enable builds on several python versions, and against several versions
of libvirt. Ideally we would build all the way back to 0.9.11, since
that is the min supported libvirt for python binding. It is not possible
to build this old libvirt version on modern distros though, so using
1.2.0 as the oldest for now.
Reviewed-by: Martin Kletzander
2017-09-18 Daniel P. Berrange
Skip sparseRecvAll / sparseSendAll in sanity test
The sanity test check aims to ensure that every function listed in
the Python code maps to a corresponding C function. The Sparse
send/recv methods are special though - we're never calling the
corresponding C APIs, instead we have a pure python impl.
2017-09-06 Daniel P. Berrange
Post-release version bump to 3.8.0
2017-09-06 Daniel P. Berrange
Report an error if registering an event loop twice
The C library will now ignore an attempt to register an event
loop twice. It is unable to report an error in this case though
due to the C API returning 'void'. To improve this we must
manually report an error at the python level.
2017-09-06 Daniel P. Berrange
Remove unused variables for event callbacks
2017-09-04 Daniel P. Berrange
Change Obsoletes to an explicit version
We only want to obsolete versions which actually had the
original name, not all future versions.
2017-09-04 Daniel Veillard
Release of libvirt-python 3.7.0
* setup.py: updated for release
2017-08-26 John Ferlan
Implement virDomainMigrateGetMaxDowntime
Add override code for virDomainMigrateGetMaxDowntime
2017-08-26 John Ferlan
Introduce virDomainMigrateGetMaxDowntime API
Introduce wrapper for virDomainMigrateGetMaxDowntime
2017-08-10 Daniel P. Berrange
Fix package name in description of sub-RPMs
2017-08-10 Daniel P. Berrange
Revert "rpm: assume python3 is always available"
This reverts commit b302b6d884ad4c6c917203a463f3377f3615b030.
Only drop the Fedora 18 test - RHEL must still build without
python 3
2017-08-10 Daniel P. Berrange
rpm: rename packages to python2-libvirt / python3-libvirt
This complies with Fedora naming policy for python packages
Reviewed-by: Martin Kletzander
2017-08-10 Daniel P. Berrange
rpm: assume python3 is always available
Reviewed-by: Martin Kletzander
2017-08-02 Tomáš Golembiovský
virDomainMemoryStats: include usable memory and last update
We've forgot to include VIR_DOMAIN_MEMORY_STAT_USABLE and
VIR_DOMAIN_MEMORY_STAT_LAST_UPDATE constants.
2017-08-02 Daniel Veillard
Release of libvirt-python-3.6.0
virtually identical to 3.5.0 except for the bump of version in setup.py
2017-07-04 Daniel Veillard
Release of libvirt-python-3.5.0
* setup.py: bump version number
2017-06-20 Martin Kletzander
Add details for shutdown event
In commit a8eba5036cb4b0e2ec827e9e6e019ce70e451377, libvirt added
support for two more details. In python bindings it all worked fine
automagically except an example that was not updated.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1463188
2017-06-02 Daniel Veillard
Release of libvirt-python-3.4.0
2017-05-24 Daniel P. Berrange
Fix error check for virDomainGetTime method
The virDomainGetTime returns either a dict or None, but the python
glue layer for checking for '-1'. Thus it failed to raise an
exception on error.
2017-05-24 Michal Privoznik
examples: Introduce sparsestream.py
Sparse streams are not that straight forward to use for the very
first time. Especially the sparseRecvAll() and sparseSendAll()
methods which expects callbacks. What we can do to make it easier
for developers is to have an example where they can take an
inspiration from.
2017-05-24 Michal Privoznik
virStream: Introduce virStreamSparse{Recv,Send}All
Yet again, our parser is not capable of generating proper
wrapper. To be fair, this one wold be really tough anyway.
2017-05-23 Michal Privoznik
virStream: Introduce virStreamRecvFlags
Yet again, we need a custom wrapper over virStreamRecvFlags
because our generator is not capable of generating it.
2017-05-23 Michal Privoznik
Implement virStreamSendHole/virStreamRecvHole
The return value for virStreamRecvHole is slightly different to
its C counterpart. In python, either it returns the hole size or
None if C API fails.
2017-05-17 Xavier Fernandez
Use better comparison in virStream.sendAll for Python 3
In Python 3, if the file is open in binary mode, @got will end up
being equal to b"" and b"" != "" in Python 3.
2017-05-15 Martin Kletzander
spec: Install egg-info with rpm package
This was being done due to now deprecated policy and that file should
be installed so that pip can recognize that the packages is already
installed in the system.
2017-05-05 Daniel Veillard
Release of libvirt-python-3.3.0
2017-04-04 Daniel P. Berrange
event-test: add ability to run the asyncio event loop
The event test program '--loop' arg is modified to take the name
of an event loop impl to run. eg 'event-test.py --loop asyncio'
2017-04-04 Daniel P. Berrange
event-test: rename example event loop impl
Use the name 'Poll' instead of 'Pure' for the event loop demo,
since there's now a second pure python loop impl available.
2017-04-04 Daniel P. Berrange
event-test: unregister callbacks & close conn on exit
In order to test cleanup code paths we must unregister all callbacks
and close the connection on shutdown. Since cleanup happens in the
background, we do a short sleep to allow the main loop to run its
cleanup too.
2017-04-04 Daniel P. Berrange
event-test: add timeout to exit event loop
2017-04-04 Daniel P. Berrange
event-test: free opaque data when removing callbacks
The pure python event loop impl has to call
libvirt.virEventInvokeFreeCallback
to free the event opaque data from a clean stack context
2017-04-04 Wojtek Porczyk
Add asyncio event loop implementation
This is usable only on python >= 3.4 (or 3.3 with out-of-tree asyncio),
however it should be harmless for anyone with older python versions.
In simplest case, to have the callbacks queued on the default loop:
>>> import libvirtaio
>>> libvirtaio.virEventRegisterAsyncIOImpl()
The function is not present on non-compatible platforms.
2017-04-04 Wojtek Porczyk
Allow for ff callbacks to be called by custom event implementations
The documentation says:
> If the opaque user data requires free'ing when the handle is
> unregistered, then a 2nd callback can be supplied for this purpose.
> This callback needs to be invoked from a clean stack. If 'ff'
> callbacks are invoked directly from the virEventRemoveHandleFunc they
> will likely deadlock in libvirt.
And they did deadlock. In removeTimeout too. Now we supply a custom
function to pick it from the opaque blob and fire.
2017-04-02 Daniel Veillard
Release of libvirt-python-3.2.0
* setup.py: bumped version
2017-03-29 Peter Krempa
event: Add handler for block threshold event
Unfortunately python doesn't generate those.
2017-03-29 Peter Krempa
event: fix comment for _dispatchDomainEventMetadataChangeCallback
The comment was copied from the device removal failed event.
2017-01-27 Daniel P. Berrange
Removed unused 'functions_list_exception_test' code from generator
The 'functions_list_exception_test' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.
2017-01-27 Daniel P. Berrange
Removed unused 'converter_type' code from generator
The 'converter_type' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.
2017-01-27 Daniel P. Berrange
Removed unused 'classes_ancestor' code from generator
The 'classes_ancestor' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.
2017-01-27 Daniel P. Berrange
Removed unused 'py_return_types' code from generator
The 'py_return_types' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.
2017-01-27 Daniel P. Berrange
Removed unused 'foreign_encoding_args' code from generator
The 'foreign_encoding_args' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.
2017-01-27 Daniel P. Berrange
Removed unused 'function_post' code from generator
The 'function_post' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.
2017-01-27 Daniel P. Berrange
Removed unused 'reference_keepers' code from generator
The 'reference_keepers' data structure and associated code
in the generator is inherited from libxml. This has never
been used in libvirt, so delete it to simplify the generator.
2017-01-27 Daniel P. Berrange
Protect against user accidentally calling constructors directly
When using libvirt python you must never call the object
constructors directly, as these are expecting to be passed
a wrapped C object. For example
import libvirt
c = libvirt.virConnect("qemu:///system")
c.listAllDomains()
will mysteriously segfault. With this change the user now
gets an slightly more helpful error
Traceback (most recent call last):
File "", line 1, in
File "/home/berrange/src/virt/libvirt-python/build/libvirt.py", line 3409, in __init__
raise Exception("Expected a wrapped C Object but got %s" % type(_obj))
Exception: Expected a wrapped C Object but got
2017-01-18 Wu Zongyong
Fix the incorrect memory freeing which will result in crash
Commit id '71fd95409' neglected to adjust a couple of API's do that now.
The number of elements in new_params is equal to the length of info,
instead of nparams, so it's wrong to free new_params using nparams.
2017-01-18 John Ferlan
Post-release version bump to 3.1.0
2017-01-17 Daniel Veillard
Release of libvirt-python-3.0.0
2017-01-10 Michal Privoznik
examples: Update event-test.py
With recent changes there are new events known to libvirt.
Reflect those changes in our event-test.py example script.
2017-01-10 Daniel P. Berrange
Fix typos in previous secrets event patch
2017-01-09 Daniel P. Berrange
Add support for domain metadata change event
2017-01-09 Daniel P. Berrange
Add support for secret event APIs
2016-12-21 Daniel P. Berrange
Add override impl for virStorageVolGetInfoFlags
2016-12-21 Daniel P. Berrange
Remove bogus \o escape in regex
One of the regexes has a bogus \o instead of plain 'o'. Somehow
this magically worked on all versions of python, until 3.6 came
along and complained
2016-12-14 Daniel P. Berrange
Fix running of nosetests on python 3
Previously the way Fedora installed /usr/bin/nosetests allowed it
to be invoked with either python 2 or 3. Since Fedora 25 though,
it contains a module name that only exists on python 2. So we need
to be more intelligent and pick a different nosetests binary per
version.
2016-12-13 Prabodh Agarwal
HACKING: fix grammar
2016-12-05 Daniel P. Berrange
Fill out more fields for PKG-INFO file
Ensure the description and license are set in PKG-INFO,
and clarify the summary field.
2016-11-11 Konstantin Neumoin
don't overrun buffer when converting cpumap
If we pass large(more than cpunum) cpu mask to any libvirt_virDomainPin*
function, it could leads to crash. So we have to check tuple size in
virPyCpumapConvert and ignore extra tuple members.
Since we allocate a zeroed buffer, we don't need to bother with setting
the bits to zero.
2016-11-11 Konstantin Neumoin
move cpumap conversion code to a common helper
All libvirt_virDomainPin* functions do the same thing for convert
pycpumap to cpumap, so this patch moves all common logic to new
helper - virPyCpumapConvert.
2016-11-02 Pavel Hrdina
Post-release version bump to 2.5.0
2016-11-01 Daniel Veillard
Release of libvirt-2.4.0
* setup.py: just bumped up the release number
2016-09-19 Peter Krempa
override: Properly override wrapper for virDomainGetGuestVcpus
Without the change to libvirt-override-api.xml generator.py would
generate the following function header:
def guestVcpus(self, params, nparams, flags=0):
Since @params and @nparams are output-only in C and the python C
implementation actualy creates a dict from them we should not need to
pass them. Add the API definition to drop the two unnecessary args:
def guestVcpus(self, flags=0):
The code did not work at all until this change as the C impl expects
only two arguments but the python required use of four.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1377071
2016-09-19 Peter Krempa
Post-release version bump to 2.3.0
2016-08-24 Michal Privoznik
PyArg_ParseTuple: Provide correct function names
At the end of the format string we put :virFunctionName where ':'
says "this is the end of argument list", and virFunctionName is
the prefix for error messages then. However, in some cases we
have had wrong names there. Some of them are actually quite
funny: xmlRegisterErrorHandler.
2016-08-17 Jovanka Gulicoska
event-test: support node device update callback
2016-08-17 Jovanka Gulicoska
Add support for node device update callback
2016-08-02 Jovanka Gulicoska
event-test: Add node device lifecycle event tests
2016-08-02 Jovanka Gulicoska
Python binding for node poll lifecycle events API
2016-08-02 Cole Robinson
Post-release version bump to 2.2.0
2016-07-28 Markus Rothe
allow pkg-config binary to be set by env
https://bugzilla.redhat.com/show_bug.cgi?id=1350523
2016-07-25 Pavel Hrdina
Post-release version bump to 2.1.0
2016-07-23 Pavel Hrdina
Fix crash in storage pool refresh callback
Fixes copy-paste typo introduced by commit cb84e36c.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1354271
2016-06-24 Daniel P. Berrange
Add support for storage pool refesh callback
2016-06-24 Daniel P. Berrange
Fix signedness of arg to virDomainGetGuestVcpus
2016-06-23 Michal Privoznik
Add support for virDomainGetGuestVcpus
This function has virTypedParameterPtr as one of the args and our
generator is unable to deal with that. Therefore we must provide
implementation.
2016-06-16 Jovanka Gulicoska
event-test: Add storage pool lifecycle event tests
2016-06-16 Jovanka Gulicoska
Python binding for storage pool lifecycle events API
Code matches the network event API implementation
2016-06-14 Daniel P. Berrange
Post-release version bump to 2.0.0
2016-06-04 Daniel Veillard
Release of libvirt-python-1.3.5
* setup.py: bumped to 1.3.5, the release is virtually identical to 1.3.4
2016-04-21 Peter Krempa
generator.py: Consider symbols from libvirt-common
Some of the libvirt public API was moved into the libvirt-common.h file.
We should consider it while building python too.
2016-04-20 Cole Robinson
spec: Don't pull in dependencies for example scripts
If the scripts are marked as executable, RPM magic will scan them
for dependencies, which can pull in python2 for the python3 package
2016-04-18 Pavel Hrdina
fix crash in getAllDomainStats
Commits 1d39dbaf and 827ed9b4 broke the libvirt-python API by removing
virDomainRef() and virDomainFree(). virDomainStatsRecordListFree() will
free that domain pointer and later when virDomain (python object) call
its destructor and tries to free that same pointer again.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1326839
2016-04-18 Peter Krempa
event: Add support VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED
2016-04-18 Peter Krempa
Post-release version bump to 1.3.4
2016-04-06 Daniel Veillard
Release of libvirt-python-1.3.3
2016-03-31 Qiaowei Ren
python: add python binding for Perf API
This patch adds the python binding for virDomainSetPerfEvents and
virDomainSetPerfEvents API.
2016-03-08 Jiri Denemark
Add support for JOB_COMPLETED event
2016-02-23 Pavel Hrdina
libvirt-override: fix PyArg_ParseTuple for size_t
Format string uses 'n' for Py_ssize_t but size_t is unsigned long, we
need to use 'k'.
2016-02-23 Pavel Hrdina
libvirt-override: fix PyArg_ParseTuple for unsigned long long
Format string uses 'L' for long long type and 'K' for unsigned long long
type.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1260356
2016-02-23 Pavel Hrdina
libvirt-override: fix PyArg_ParseTuple for unsigned int
Format string uses 'i' for int type and 'I' for unsigned int type.
2016-02-23 Pavel Hrdina
libvirt-override: all flags should be defined as unsigned int
2016-01-18 Jiri Denemark
Add support for MIGRATION_ITERATION event
2016-01-18 Jiri Denemark
setup: Use cflags and ldflags properly
The setup.py script reads cflags and ldflags from pkg-config and uses
them when compiling/linking C modules. Since both cflags and ldflags may
include multiple compiler arguments we need to split them rather than
concatenating them into a single argument.
2016-01-18 Jiri Denemark
Post-release version bump to 1.3.2
2016-01-17 Daniel Veillard
Version bump to 1.3.1
For release but no change from 1.3.0
2015-11-24 Pavel Hrdina
Post-release version bump to 1.3.0
2015-10-31 Pavel Hrdina
fix crash introduced by commit 1d39dbaf
Some of the libvirt_*Wrap functions steals the reference and we need to
set the item in array to NULL no not free it on success. Those three
places was accidentally removed by commit 1d39dbaf.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1270977
2015-10-15 Martin Kletzander
Post-release version bump to 1.2.21
2015-10-05 Pavel Hrdina
use VIR_PY_DICT_SET_GOTO
2015-10-05 Pavel Hrdina
use VYR_PY_LIST_SET_GOTO and VIR_PY_LIST_APPEND_GOTO
2015-10-05 Pavel Hrdina
use VIR_PY_TUPLE_GOTO
2015-10-05 Pavel Hrdina
utils: introduce new macro helpers for tuple, list and dict objects
2015-10-05 Pavel Hrdina
improve usage of cleanup paths
This removes several code duplicates and also some unusual code structures.
2015-10-05 Pavel Hrdina
drop unnecessary py_retval variable
2015-10-05 Pavel Hrdina
change the order of some statements
This change makes it easier to free allocated object especially for
python objects. We can benefit from the fact, that if you call
Py_DECREF on any python object it will also remove reference for all
assigned object to the root object. For example, calling Py_DECREF on
dict will also remove reference recursively on all elements in that
dictionary. Our job is then just call Py_DECREF on the root element and
don't care about anything else.
2015-10-05 Pavel Hrdina
Must check return value for all Py*_New functions
If the function fails, we need to cleanup memory and return NULL.
2015-10-05 Pavel Hrdina
use Py_CLEAR instead of Py_XDECREF followed by NULL assignment
2015-10-05 Pavel Hrdina
Use VIR_PY_NONE instead of increment and Py_None
To insert Py_None into some other python object like dict or tuple, you
need to increase reference to the Py_None. We have a macro to do that.
2015-10-05 Pavel Hrdina
Return NULL and set an exception if allocation fails
This is a recommended work-flow for allocation failures and we should
follow it.
2015-10-05 Pavel Hrdina
Return correct python object
In case of error without setting an python exception we need to return
a correct python object. For functions that returns anything else than
a number the return value is 'None', otherwise it's '-1'.
2015-10-05 Pavel Hrdina
Return NULL if python exception is set
There is a rule, python API fails, it also in those cases sets an
exception. We should follow those rules and in those cases return NULL.
2015-10-05 Pavel Hrdina
wrap lines to 80 columns
2015-10-05 Pavel Hrdina
fix indentation
2015-10-05 Pavel Hrdina
indent labels by one space
2015-10-05 Pavel Hrdina
cleanup functions definition
Follow the libvirt hacking guide and make the code consistent.
2015-10-05 Pavel Hrdina
Move utils and shared code into libvirt-utils
2015-10-05 Pavel Hrdina
drop unnecessary goto
2015-10-05 Pavel Hrdina
remove useless check for NULL before Py_XDECREF
2015-10-05 Pavel Hrdina
refactor the function to not override python exceptions
2015-10-05 Pavel Hrdina
update virDomainGetVcpus xml API description
Python api returns a tuple with the vcpus information.
2015-10-02 Daniel Veillard
Release of libvirt-python-1.2.20
2015-09-21 Luyao Huang
generator: fix build fail with old xml lib
https://bugzilla.redhat.com/show_bug.cgi?id=1222795#c6
if build libvirt-python with some old xml lib (python-pyxml),
build will fail and error like this:
File "generator.py", line 139, in start
if "string" in attrs:
File "/usr/local/lib/python2.7/site-packages/_xmlplus/sax/xmlreader.py" \
, line 316, in __getitem__
return self._attrs[name]
KeyError: 0
This is an old issue and have been mentioned in commit 3ae0a76d.
There is no __contains__ in class AttributesImpl, python will use
__getitem__ in this place, so we will get error.
Let's use 'YYY in XXX.keys()' to avoid this issue.
2015-08-26 Luyao Huang
examples: small fix for nodestats.py example
Add nodestats.py in MANIFEST.in and add a
small description for nodestats.py in README
2015-08-03 Jiri Denemark
Check return value of PyList_Append
libvirt_virDomainGetSecurityLabelList called PyList_Append without
checking its return value. While looking at it I noticed the function
did not properly check several other return values either so I fixed
them all.
https://bugzilla.redhat.com/show_bug.cgi?id=1249511
2015-08-03 Jiri Denemark
Post-release version bump to 1.2.19
2015-08-03 Daniel Veillard
Forgot to bump version to 1.2.18
2015-07-30 Peter Krempa
iothread: Fix crash if virDomainGetIOThreadInfo returns error
The cleanup portion of libvirt_virDomainGetIOThreadInfo would try to
clean the returned structures but the count of iothreads was set to -1.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1248295
2015-07-17 Michal Privoznik
examples: Introduce nodestats example
So, this is an exercise to show libvirt capabilities. Firstly, for
each host NUMA nodes some statistics are printed out, i.e. total
memory and free memory. Then, for each running domain, that has memory
strictly bound to certain host nodes, a small statistics of how much
memory it takes is printed out too. For instance:
# ./examples/nodestats.py
NUMA stats
NUMA nodes: 0 1 2 3
MemTotal: 3950 3967 3937 3943
MemFree: 66 56 42 41
Domain 'fedora':
Overall memory: 1536 MiB
Domain 'fedora22':
Overall memory: 2048 MiB
Domain 'fedora21':
Overall memory: 1024 MiB nodes 0-1
Node 0: 1024 MiB nodes 0-1
Domain 'gentoo':
Overall memory: 4096 MiB nodes 0-3
Node 0: 1024 MiB nodes 0
Node 1: 1024 MiB nodes 1
Node 2: 1024 MiB nodes 2
Node 3: 1024 MiB nodes 3
We can see 4 host NUMA nodes, all of them having roughly 4GB of RAM.
Yeah, all of them has nearly all the memory consumed. Then, there are
four domains running. For instance, domain 'fedora' has 1.5GB memory
which is not pinned onto any specific host NUMA node. Domain 'gentoo' on
the other hand has 4GB memory and has 4 NUMA nodes which are pinned 1:1
to host nodes.
2015-06-29 Pavel Boldin
virPyDictToTypedParams: packing lists of values
Pack a list or a tuple of values passed to a Python method to the
multi-value parameter.
2015-06-28 Martin Kletzander