Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 35 participants
- 40201 discussions
28 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Validate that every public API method is mapped into the python
and that every python method has a sane C API.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
sanitytest.py | 309 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
setup.py | 35 +++----
2 files changed, 294 insertions(+), 50 deletions(-)
mode change 100755 => 100644 sanitytest.py
diff --git a/sanitytest.py b/sanitytest.py
old mode 100755
new mode 100644
index 517054b..9e4c261
--- a/sanitytest.py
+++ b/sanitytest.py
@@ -1,40 +1,283 @@
#!/usr/bin/python
import sys
+import lxml
+import lxml.etree
+import string
+# Munge import path to insert build location for libvirt mod
sys.path.insert(0, sys.argv[1])
-
import libvirt
+import libvirtmod
+
+# Path to the libvirt API XML file
+xml = sys.argv[2]
+
+f = open(xml, "r")
+tree = lxml.etree.parse(f)
+
+verbose = False
+
+wantenums = []
+wantfunctions = []
+
+# Phase 1: Identify all functions and enums in public API
+set = tree.xpath('/api/files/file/exports[@type="function"]/@symbol')
+for n in set:
+ wantfunctions.append(n)
+
+set = tree.xpath('/api/files/file/exports[@type="enum"]/@symbol')
+for n in set:
+ wantenums.append(n)
+
+
+# Phase 2: Identify all classes and methods in the 'libvirt' python module
+gotenums = []
+gottypes = []
+gotfunctions = { "libvirt": [] }
+
+for name in dir(libvirt):
+ if name[0] == '_':
+ continue
+ thing = getattr(libvirt, name)
+ if type(thing) == int:
+ gotenums.append(name)
+ elif type(thing) == type:
+ gottypes.append(name)
+ gotfunctions[name] = []
+ elif callable(thing):
+ gotfunctions["libvirt"].append(name)
+ else:
+ pass
+
+for klassname in gottypes:
+ klassobj = getattr(libvirt, klassname)
+ for name in dir(klassobj):
+ if name[0] == '_':
+ continue
+ thing = getattr(klassobj, name)
+ if callable(thing):
+ gotfunctions[klassname].append(name)
+ else:
+ pass
+
+
+# Phase 3: First cut at mapping of C APIs to python classes + methods
+basicklassmap = {}
+
+for cname in wantfunctions:
+ name = cname
+ # Some virConnect APIs have stupid names
+ if name[0:7] == "virNode" and name[0:13] != "virNodeDevice":
+ name = "virConnect" + name[7:]
+ if name[0:7] == "virConn" and name[0:10] != "virConnect":
+ name = "virConnect" + name[7:]
+
+ # The typed param APIs are only for internal use
+ if name[0:14] == "virTypedParams":
+ continue
+
+ # These aren't functions, they're callback signatures
+ if name in ["virConnectAuthCallbackPtr", "virConnectCloseFunc",
+ "virStreamSinkFunc", "virStreamSourceFunc", "virStreamEventCallback",
+ "virEventHandleCallback", "virEventTimeoutCallback", "virFreeCallback"]:
+ continue
+ if name[0:21] == "virConnectDomainEvent" and name[-8:] == "Callback":
+ continue
+
+
+ # virEvent APIs go into main 'libvirt' namespace not any class
+ if name[0:8] == "virEvent":
+ if name[-4:] == "Func":
+ continue
+ basicklassmap[name] = ["libvirt", name, cname]
+ else:
+ found = False
+ # To start with map APIs to classes based on the
+ # naming prefix. Mistakes will be fixed in next
+ # loop
+ for klassname in gottypes:
+ klen = len(klassname)
+ if name[0:klen] == klassname:
+ found = True
+ if name not in basicklassmap:
+ basicklassmap[name] = [klassname, name[klen:], cname]
+ elif len(basicklassmap[name]) < klassname:
+ basicklassmap[name] = [klassname, name[klen:], cname]
+
+ # Anything which can't map to a class goes into the
+ # global namespaces
+ if not found:
+ basicklassmap[name] = ["libvirt", name[3:], cname]
+
+
+# Phase 4: Deal with oh so many special cases in C -> python mapping
+finalklassmap = {}
+
+for name in sorted(basicklassmap):
+ klass = basicklassmap[name][0]
+ func = basicklassmap[name][1]
+ cname = basicklassmap[name][2]
+
+ # The object lifecycle APIs are irrelevant since they're
+ # used inside the object constructors/destructors.
+ if func in ["Ref", "Free", "New", "GetConnect", "GetDomain"]:
+ if klass == "virStream" and func == "New":
+ klass = "virConnect"
+ func = "NewStream"
+ else:
+ continue
+
+
+ # All the error handling methods need special handling
+ if klass == "libvirt":
+ if func in ["CopyLastError", "DefaultErrorFunc",
+ "ErrorFunc", "FreeError",
+ "SaveLastError", "ResetError"]:
+ continue
+ elif func in ["GetLastError", "GetLastErrorMessage", "ResetLastError", "Initialize"]:
+ func = "vir" + func
+ elif func == "SetErrorFunc":
+ func = "RegisterErrorHandler"
+ elif klass == "virConnect":
+ if func in ["CopyLastError", "SetErrorFunc"]:
+ continue
+ elif func in ["GetLastError", "ResetLastError"]:
+ func = "virConn" + func
+
+ # Remove 'Get' prefix from most APIs, except those in virConnect
+ # and virDomainSnapshot namespaces which stupidly used a different
+ # convention which we now can't fix without breaking API
+ if func[0:3] == "Get" and klass not in ["virConnect", "virDomainSnapshot", "libvirt"]:
+ if func not in ["GetCPUStats"]:
+ func = func[3:]
+
+ # The object creation and lookup APIs all have to get re-mapped
+ # into the parent class
+ if func in ["CreateXML", "CreateLinux", "CreateXMLWithFiles",
+ "DefineXML", "CreateXMLFrom", "LookupByUUID",
+ "LookupByUUIDString", "LookupByVolume" "LookupByName",
+ "LookupByID", "LookupByName", "LookupByKey", "LookupByPath",
+ "LookupByMACString", "LookupByUsage", "LookupByVolume",
+ "LookupSCSIHostByWWN", "Restore", "RestoreFlags",
+ "SaveImageDefineXML", "SaveImageGetXMLDesc"]:
+ if klass != "virDomain":
+ func = klass[3:] + func
+
+ if klass == "virDomainSnapshot":
+ klass = "virDomain"
+ func = func[6:]
+ elif klass == "virStorageVol" and func in ["StorageVolCreateXMLFrom", "StorageVolCreateXML"]:
+ klass = "virStoragePool"
+ func = func[10:]
+ elif func == "StoragePoolLookupByVolume":
+ klass = "virStorageVol"
+ elif func == "StorageVolLookupByName":
+ klass = "virStoragePool"
+ else:
+ klass = "virConnect"
+
+ # The open methods get remapped to primary namespace
+ if klass == "virConnect" and func in ["Open", "OpenAuth", "OpenReadOnly"]:
+ klass = "libvirt"
+
+ # These are inexplicably renamed in the python API
+ if func == "ListDomains":
+ func = "ListDomainsID"
+ elif func == "ListAllNodeDevices":
+ func = "ListAllDevices"
+ elif func == "ListNodeDevices":
+ func = "ListDevices"
+
+ # The virInterfaceChangeXXXX APIs go into virConnect. Stupidly
+ # they have lost their 'interface' prefix in names, but we can't
+ # fix this name
+ if func[0:6] == "Change":
+ klass = "virConnect"
+
+ # Need to special case the snapshot APIs
+ if klass == "virDomainSnapshot" and func in ["Current", "ListNames", "Num"]:
+ klass = "virDomain"
+ func = "snapshot" + func
+
+ # Names should stsart with lowercase letter...
+ func = string.lower(func[0:1]) + func[1:]
+ if func[0:8] == "nWFilter":
+ func = "nwfilter" + func[8:]
+
+ # ...except when they don't. More stupid naming
+ # decisions we can't fix
+ if func == "iD":
+ func = "ID"
+ if func == "uUID":
+ func = "UUID"
+ if func == "uUIDString":
+ func = "UUIDString"
+ if func == "oSType":
+ func = "OSType"
+ if func == "xMLDesc":
+ func = "XMLDesc"
+ if func == "mACString":
+ func = "MACString"
+
+ finalklassmap[name] = [klass, func, cname]
+
+
+# Phase 5: Validate sure that every C API is mapped to a python API
+fail = False
+usedfunctions = {}
+for name in sorted(finalklassmap):
+ klass = finalklassmap[name][0]
+ func = finalklassmap[name][1]
+
+ if func in gotfunctions[klass]:
+ usedfunctions["%s.%s" % (klass, func)] = 1
+ if verbose:
+ print "PASS %s -> %s.%s" % (name, klass, func)
+ else:
+ print "FAIL %s -> %s.%s (C API not mapped to python)" % (name, klass, func)
+ fail = True
+
+
+# Phase 6: Validate that every python API has a corresponding C API
+for klass in gotfunctions:
+ if klass == "libvirtError":
+ continue
+ for func in sorted(gotfunctions[klass]):
+ # These are pure python methods with no C APi
+ if func in ["connect", "getConnect", "domain", "getDomain"]:
+ continue
+
+ key = "%s.%s" % (klass, func)
+ if not key in usedfunctions:
+ print "FAIL %s.%s (Python API not mapped to C)" % (klass, func)
+ fail = True
+ else:
+ if verbose:
+ print "PASS %s.%s" % (klass, func)
+
+# Phase 7: Validate that all the low level C APIs have binding
+for name in sorted(finalklassmap):
+ cname = finalklassmap[name][2]
+
+ pyname = cname
+ if pyname == "virSetErrorFunc":
+ pyname = "virRegisterErrorHandler"
+ elif pyname == "virConnectListDomains":
+ pyname = "virConnectListDomainsID"
+
+ # These exist in C and exist in python, but we've got
+ # a pure-python impl so don't check them
+ if name in ["virStreamRecvAll", "virStreamSendAll"]:
+ continue
+
+ try:
+ thing = getattr(libvirtmod, pyname)
+ except AttributeError:
+ print "FAIL libvirtmod.%s (C binding does not exist)" % pyname
+ fail = True
-globals = dir(libvirt)
-
-# Sanity test that the generator hasn't gone wrong
-
-# Look for core classes
-for clsname in ["virConnect",
- "virDomain",
- "virDomainSnapshot",
- "virInterface",
- "virNWFilter",
- "virNodeDevice",
- "virNetwork",
- "virSecret",
- "virStoragePool",
- "virStorageVol",
- "virStream",
- ]:
- assert(clsname in globals)
- assert(object in getattr(libvirt, clsname).__bases__)
-
-# Constants
-assert("VIR_CONNECT_RO" in globals)
-
-# Error related bits
-assert("libvirtError" in globals)
-assert("VIR_ERR_AUTH_FAILED" in globals)
-assert("virGetLastError" in globals)
-
-# Some misc methods
-assert("virInitialize" in globals)
-assert("virEventAddHandle" in globals)
-assert("virEventRegisterDefaultImpl" in globals)
+if fail:
+ sys.exit(1)
+else:
+ sys.exit(0)
diff --git a/setup.py b/setup.py
index 17b4722..bf222f8 100755
--- a/setup.py
+++ b/setup.py
@@ -59,6 +59,20 @@ def get_pkgconfig_data(args, mod, required=True):
return line
+def get_api_xml_files():
+ """Check with pkg-config that libvirt is present and extract
+ the API XML file paths we need from it"""
+
+ libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"], "libvirt")
+
+ offset = libvirt_api.index("-api.xml")
+ libvirt_qemu_api = libvirt_api[0:offset] + "-qemu-api.xml"
+
+ offset = libvirt_api.index("-api.xml")
+ libvirt_lxc_api = libvirt_api[0:offset] + "-lxc-api.xml"
+
+ return (libvirt_api, libvirt_qemu_api, libvirt_lxc_api)
+
ldflags = get_pkgconfig_data(["--libs-only-L"], "libvirt", False)
cflags = get_pkgconfig_data(["--cflags"], "libvirt", False)
@@ -105,23 +119,8 @@ if have_libvirt_lxc:
class my_build(build):
- def get_api_xml_files(self):
- """Check with pkg-config that libvirt is present and extract
- the API XML file paths we need from it"""
-
- libvirt_api = get_pkgconfig_data(["--variable", "libvirt_api"], "libvirt")
-
- offset = libvirt_api.index("-api.xml")
- libvirt_qemu_api = libvirt_api[0:offset] + "-qemu-api.xml"
-
- offset = libvirt_api.index("-api.xml")
- libvirt_lxc_api = libvirt_api[0:offset] + "-lxc-api.xml"
-
- return (libvirt_api, libvirt_qemu_api, libvirt_lxc_api)
-
-
def run(self):
- apis = self.get_api_xml_files()
+ apis = get_api_xml_files()
self.spawn(["python", "generator.py", "libvirt", apis[0]])
self.spawn(["python", "generator.py", "libvirt-qemu", apis[1]])
@@ -266,7 +265,9 @@ class my_test(Command):
Run test suite
"""
- self.spawn(["python", "sanitytest.py", self.build_platlib])
+ apis = get_api_xml_files()
+
+ self.spawn(["python", "sanitytest.py", self.build_platlib, apis[0]])
class my_clean(clean):
--
1.8.3.1
3
4
28 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Dan Walsh identified that if you ask LXC to mount both
/etc/aliases and /etc/aliases.db in the container you
only end up with one of them mounted. This was due to
a bogus subpath check.
It is a one line fix which turned into a much bigger
series so that I could add a test case for this code.
Daniel P. Berrange (3):
Remove 'abs_srcdir' variable from test files
Pull lxcContainerGetSubtree out into shared virfile module
Fix bug in identifying sub-mounts
.gitignore | 1 +
src/libvirt_private.syms | 4 ++
src/lxc/lxc_container.c | 63 ++-------------------
src/util/virfile.c | 114 +++++++++++++++++++++++++++++++++++++
src/util/virfile.h | 9 +++
src/util/virstring.c | 29 ++++++++++
src/util/virstring.h | 3 +
tests/Makefile.am | 7 +++
tests/testutils.c | 12 ----
tests/testutils.h | 1 -
tests/virfiledata/mounts1.txt | 31 ++++++++++
tests/virfiledata/mounts2.txt | 33 +++++++++++
tests/virfiletest.c | 128 ++++++++++++++++++++++++++++++++++++++++++
tests/virpcimock.c | 5 --
14 files changed, 363 insertions(+), 77 deletions(-)
create mode 100644 tests/virfiledata/mounts1.txt
create mode 100644 tests/virfiledata/mounts2.txt
create mode 100644 tests/virfiletest.c
--
1.8.3.1
2
7
qemu removes the builtin pvpanic device for all qemu versions since 1.7,
in order to support <on_crash>, '-device pvpanic' has to be added to
qemu command line.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
src/qemu/qemu_capabilities.c | 8 ++++++++
src/qemu/qemu_capabilities.h | 2 ++
src/qemu/qemu_command.c | 4 ++++
3 files changed, 14 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 548b988..7783997 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -243,6 +243,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"virtio-mmio",
"ich9-intel-hda",
"kvm-pit-lost-tick-policy",
+
+ "pvpanic", /* 160 */
);
struct _virQEMUCaps {
@@ -1198,6 +1200,9 @@ virQEMUCapsComputeCmdFlags(const char *help,
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_SHARE_POLICY);
}
+ if (version >= 1005000)
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_PVPANIC);
+
return 0;
}
@@ -2561,6 +2566,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
if (qemuCaps->version >= 1006000)
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+ if (qemuCaps->version >= 1005000)
+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_PVPANIC);
+
if (virQEMUCapsProbeQMPCommands(qemuCaps, mon) < 0)
goto cleanup;
if (virQEMUCapsProbeQMPEvents(qemuCaps, mon) < 0)
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 02d47c6..06d2fac 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -199,6 +199,8 @@ enum virQEMUCapsFlags {
QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */
QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */
+ QEMU_CAPS_PVPANIC = 160, /* -device pvpanic */
+
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 763417f..b1307a3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9588,6 +9588,10 @@ qemuBuildCommandLine(virConnectPtr conn,
goto error;
}
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PVPANIC)) {
+ virCommandAddArgList(cmd, "-device", "pvpanic", NULL);
+ }
+
if (mlock) {
unsigned long long memKB;
--
1.8.3.1
4
5
[libvirt] [PATCH] libvirt-perl: Fix the wrong binding of virNodeDeviceLookupSCSIHostByWWN
by Osier Yang 28 Nov '13
by Osier Yang 28 Nov '13
28 Nov '13
The second parameter for virNodeDeviceLookupSCSIHostByWWN is "wwnn"
instead of "wwpn", and the API supports "flags".
---
AUTHORS | 1 +
lib/Sys/Virt/NodeDevice.pm | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index d53f191..c2af49a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,5 +12,6 @@ Patches contributed by:
Stepan Kasal <skasal-at-redhat-dot-com>
Ludwig Nussel <ludwig-dot-nussel-at-suse-dot-de>
Zhe Peng <zpeng-at-redhat-dot-com>
+ Osier Yang <jyang-at-redhat-dot-com>
-- End
diff --git a/lib/Sys/Virt/NodeDevice.pm b/lib/Sys/Virt/NodeDevice.pm
index 984910d..29ceac7 100644
--- a/lib/Sys/Virt/NodeDevice.pm
+++ b/lib/Sys/Virt/NodeDevice.pm
@@ -51,10 +51,11 @@ sub _new {
my $self;
if (exists $params{name}) {
$self = Sys::Virt::NodeDevice::_lookup_by_name($con, $params{name});
- } elsif (exists $params{wwpn}) {
+ } elsif (exists $params{wwnn}) {
$self = Sys::Virt::NodeDevice::_lookup_scsihost_by_wwn($con,
+ $params{wwnn},
$params{wwpn},
- $params{wwnn});
+ $params{flags});
} elsif (exists $params{xml}) {
$self = Sys::Virt::NodeDevice::_create_xml($con, $params{xml});
} else {
--
1.8.1.4
2
2
[libvirt] [test-API][PATCH V2] Add blockjob related test functions and cases
by Jincheng Miao 28 Nov '13
by Jincheng Miao 28 Nov '13
28 Nov '13
* repos/domain/blkstatsflags.py
* repos/domain/block_iotune.py
* repos/domain/block_peek.py
* repos/domain/block_resize.py
* repos/domain/domain_blkio.py
* cases/basic_blockjob.conf
V1->V2:
Removed diskpath params for block_resize, this hard code disk device is
not convenient for users.
---
cases/basic_blockjob.conf | 83 +++++++++++++++++++++
repos/domain/blkstatsflags.py | 63 ++++++++++++++++
repos/domain/block_iotune.py | 118 ++++++++++++++++++++++++++++++
repos/domain/block_peek.py | 69 ++++++++++++++++++
repos/domain/block_resize.py | 94 ++++++++++++++++++++++++
repos/domain/domain_blkio.py | 163 ++++++++++++++++++++++++++++++++++++++++++
6 files changed, 590 insertions(+)
create mode 100644 cases/basic_blockjob.conf
create mode 100644 repos/domain/blkstatsflags.py
create mode 100644 repos/domain/block_iotune.py
create mode 100644 repos/domain/block_peek.py
create mode 100644 repos/domain/block_resize.py
create mode 100644 repos/domain/domain_blkio.py
diff --git a/cases/basic_blockjob.conf b/cases/basic_blockjob.conf
new file mode 100644
index 0000000..21332dc
--- /dev/null
+++ b/cases/basic_blockjob.conf
@@ -0,0 +1,83 @@
+domain:install_linux_cdrom
+ guestname
+ $defaultname
+ guestos
+ $defaultos
+ guestarch
+ $defaultarch
+ vcpu
+ $defaultvcpu
+ memory
+ $defaultmem
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+ macaddr
+ 54:52:00:45:c3:8a
+
+domain:install_linux_check
+ guestname
+ $defaultname
+ virt_type
+ $defaulthv
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+
+domain:block_iotune
+ guestname
+ $defaultname
+ bytes_sec
+ 100000
+ iops_sec
+ 0
+
+domain:block_iotune
+ guestname
+ $defaultname
+ bytes_sec
+ 0
+ iops_sec
+ 1000
+
+domain:block_peek
+ guestname
+ $defaultname
+
+domain:block_peek
+ guestname
+ $defaultname
+
+domain:block_resize
+ guestname
+ $defaultname
+ disksize
+ 1G
+
+domain:blkstats
+ guestname
+ $defaultname
+
+domain:blkstatsflags
+ guestname
+ $defaultname
+ flags
+ 0
+
+domain:domain_blkinfo
+ guestname
+ $defaultname
+
+domain:domain_blkio
+ guestname
+ $defaultname
+ weight
+ 500
+
+domain:undefine
+ guestname
+ $defaultname
+
+options cleanup=enable
diff --git a/repos/domain/blkstatsflags.py b/repos/domain/blkstatsflags.py
new file mode 100644
index 0000000..4c84a18
--- /dev/null
+++ b/repos/domain/blkstatsflags.py
@@ -0,0 +1,63 @@
+#!/usr/bin/evn python
+# To test domain block device statistics with flags
+
+import time
+import libxml2
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'flags')
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def check_blkstats():
+ """Check block device statistic result"""
+ pass
+
+def blkstatsflags(params):
+ """Domain block device statistic"""
+ logger = params['logger']
+ guestname = params['guestname']
+ flags = int(params['flags'])
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ devs = cont.xpathEval("/domain/devices/disk/target/@dev")
+
+ for dev in devs:
+ path = dev.content
+ blkstats = domobj.blockStatsFlags(path, flags)
+ # check_blkstats()
+ logger.debug(blkstats)
+ for entry in blkstats.keys():
+ logger.info("%s %s %s" %(path, entry, blkstats[entry]))
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/block_iotune.py b/repos/domain/block_iotune.py
new file mode 100644
index 0000000..26e4823
--- /dev/null
+++ b/repos/domain/block_iotune.py
@@ -0,0 +1,118 @@
+#!/usr/bin/evn python
+# To test domain block device iotune
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'bytes_sec', 'iops_sec')
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def prepare_block_iotune(param, wbs, rbs, tbs, wis, ris, tis, logger):
+ """prepare the block iotune parameter
+ """
+ logger.info("write_bytes_sec : %s" % wbs)
+ param['write_bytes_sec'] = wbs
+ logger.info("read_bytes_sec : %s" % rbs)
+ param['read_bytes_sec'] = rbs
+ logger.info("total_bytes_sec : %s" % tbs)
+ param['total_bytes_sec'] = tbs
+ logger.info("write_iops_sec : %s" % wis)
+ param['write_iops_sec'] = wis
+ logger.info("read_iops_sec : %s" % ris)
+ param['read_iops_sec'] = ris
+ logger.info("total_iops_sec : %s\n" % tis)
+ param['total_iops_sec'] = tis
+ return 0
+
+def check_iotune(expected_param, result_param):
+ """check block iotune configuration
+ """
+ for k in expected_param.keys():
+ if expected_param[k] != result_param[k]:
+ return 1
+ return 0
+
+def block_iotune(params):
+ """Domain block device iotune"""
+ logger = params['logger']
+ guestname = params['guestname']
+ bytes_sec = int(params['bytes_sec'])
+ iops_sec = int(params['iops_sec'])
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/target/@dev")
+ vdev = vdevs[0].content
+
+ iotune_para = {'write_bytes_sec': 0L,
+ 'total_iops_sec': 0L,
+ 'read_iops_sec': 0L,
+ 'read_bytes_sec': 0L,
+ 'write_iops_sec': 0L,
+ 'total_bytes_sec': 0L
+ }
+
+ logger.info("prepare block iotune:")
+ prepare_block_iotune(iotune_para, bytes_sec, bytes_sec, 0,
+ iops_sec, iops_sec, 0, logger)
+
+ logger.info("start to set block iotune:")
+ domobj.setBlockIoTune(vdev, iotune_para, flag)
+
+ res = domobj.blockIoTune(vdev, flag)
+ ret = check_iotune(iotune_para, res)
+ if not ret:
+ logger.info("set pass")
+ else:
+ logger.error("fails to set")
+ return 1
+
+ logger.info("prepare block iotune:")
+ prepare_block_iotune(iotune_para, 0, 0, bytes_sec,
+ 0, 0, iops_sec, logger)
+
+ logger.info("start to set block iotune:")
+ domobj.setBlockIoTune(vdev, iotune_para, flag)
+
+ res = domobj.blockIoTune(vdev, flag)
+ ret = check_iotune(iotune_para, res)
+ if not ret:
+ logger.info("set pass")
+ else:
+ logger.error("fails to set")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/block_peek.py b/repos/domain/block_peek.py
new file mode 100644
index 0000000..b88668a
--- /dev/null
+++ b/repos/domain/block_peek.py
@@ -0,0 +1,69 @@
+#!/usr/bin/evn python
+# To test domain block device peek
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname',)
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def block_peek(params):
+ """domain block peek test function
+ """
+ logger = params['logger']
+ guestname = params['guestname']
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/target/@dev")
+ vdev = vdevs[0].content
+
+ logger.info("start to test block_peek.")
+ logger.info("get the MBR's last byte of domain %s %s is:"
+ % (guestname, vdev))
+
+ last_byte = domobj.blockPeek(vdev, 511, 1, flag)
+ logger.info(last_byte)
+
+ # compare with '\xaa'
+ if last_byte == '\xaa':
+ logger.info("Pass: the last byte is \\xaa")
+ else:
+ logger.error("Failed: the last byte is not \\xaa")
+ logger.error("please make sure the guest is bootable")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/block_resize.py b/repos/domain/block_resize.py
new file mode 100644
index 0000000..6070c22
--- /dev/null
+++ b/repos/domain/block_resize.py
@@ -0,0 +1,94 @@
+#!/usr/bin/evn python
+# To test domain block device resize
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'disksize',)
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def block_resize(params):
+ """domain block resize test function
+ """
+ logger = params['logger']
+ guestname = params['guestname']
+ disksize = params['disksize']
+ flag = 0
+
+ out = utils.get_capacity_suffix_size(disksize)
+ if len(out) == 0:
+ logger.error("disksize parse error: \'%s\'" % disksize)
+ logger.error("disksize should be a number with capacity suffix")
+ return 1
+
+ if out['suffix'] == 'K':
+ flag = 0
+ disksize = long(out['capacity'])
+ elif out['suffix'] == 'B':
+ flag = 1
+ disksize = long(out['capacity_byte'])
+ elif out['suffix'] == 'M':
+ flag = 0
+ disksize = long(out['capacity']) * 1024
+ elif out['suffix'] == 'G':
+ flag = 0
+ disksize = long(out['capacity']) * 1024 * 1024
+ else:
+ logger.error("disksize parse error: with a unsupported suffix \'%s\'"
+ % out['suffix'])
+ logger.error("the available disksize suffix of block_resize is: ")
+ logger.error("B, K, M, G, T")
+ return 1
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/source/@file")
+ diskpath = vdevs[0].content
+ logger.info("the disk is %s" % diskpath)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ logger.info("resize domain disk to %s" % disksize)
+ domobj.blockResize(diskpath, disksize, flag)
+
+ # Currently, the units of disksize which get from blockInfo is byte.
+ block_info = domobj.blockInfo(diskpath, 0)
+
+ if block_info[0] == disksize * (1 + 1023 * (1 - flag)):
+ logger.info("domain disk resize success")
+ else:
+ logger.error("error: domain disk change into %s" % block_info[0])
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/domain_blkio.py b/repos/domain/domain_blkio.py
new file mode 100644
index 0000000..f1c637d
--- /dev/null
+++ b/repos/domain/domain_blkio.py
@@ -0,0 +1,163 @@
+#!/usr/bin/evn python
+# To test domain blkio parameters
+
+import os
+import time
+import libxml2
+import libvirt
+import commands
+from libvirt import libvirtError
+
+from src import sharedmod
+
+CGROUP_PATH = "/cgroup"
+BLKIO_PATH1 = "%s/blkio/libvirt/qemu/%s"
+BLKIO_PATH2 = "/sys/fs%s/blkio/machine/%s.libvirt-qemu"
+GET_PARTITION = "df -P %s | tail -1 | awk {'print $1'}"
+
+required_params = ('guestname', 'weight',)
+optional_params = {}
+
+def get_output(command, logger):
+ """execute shell command
+ """
+ status, ret = commands.getstatusoutput(command)
+ if status:
+ logger.error("executing "+ "\"" + command + "\"" + " failed")
+ logger.error(ret)
+ return status, ret
+
+def get_device(domobj, logger):
+ """get the disk device which domain image stored in
+ """
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ devs = cont.xpathEval("/domain/devices/disk/source/@file")
+ image_file = devs[0].content
+
+ status, output = get_output(GET_PARTITION % image_file, logger)
+ if not status:
+ return output[:-1]
+ else:
+ logger.error("get device error: ")
+ logger.error(GET_PARTITION % image_file)
+ return ""
+
+def check_blkio_paras(domain_blkio_path, domainname, blkio_paras, logger):
+ """check blkio parameters according to cgroup filesystem
+ """
+ logger.info("checking blkio parameters from cgroup")
+ if 'weight' in blkio_paras:
+ expected_weight = blkio_paras['weight']
+ status, output = get_output("cat %s/blkio.weight"
+ % domain_blkio_path, logger)
+ if not status:
+ logger.info("%s/blkio.weight is \"%s\""
+ % (domain_blkio_path, output))
+ else:
+ return 1
+
+ if int(output) == expected_weight:
+ logger.info("the weight matches with cgroup blkio.weight")
+ return 0
+ else:
+ logger.error("the weight mismatches with cgroup blkio.weight")
+ return 1
+
+ if 'device_weight' in blkio_paras:
+ expected_device_weight = blkio_paras['device_weight']
+ status, output = get_output("cat %s/blkio.weight_device"
+ % domain_blkio_path, logger)
+ if not status:
+ logger.info("%s/blkio.weight_device is \"%s\""
+ % (domain_blkio_path, output))
+ else:
+ return 1
+
+ if output.split(' ')[1] == expected_device_weight.split(',')[1]:
+ logger.info("the device_weight matches with cgroup \
+ blkio.weight_device")
+ return 0
+ else:
+ logger.error("the device_weight mismatches with cgroup \
+ blkio.weight_device")
+ return 1
+
+ return 0
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def domain_blkio(params):
+ """domain blkio parameters test function"""
+ logger = params['logger']
+ guestname = params['guestname']
+ expected_weight = params['weight']
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ if os.path.exists(CGROUP_PATH):
+ blkio_path = BLKIO_PATH1 % (CGROUP_PATH, guestname)
+ else:
+ blkio_path = BLKIO_PATH2 % (CGROUP_PATH, guestname)
+
+ try:
+ blkio_paras = domobj.blkioParameters(flag)
+
+ logger.info("the blkio weight of %s is: %d"
+ % (guestname, blkio_paras['weight']))
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ logger.info("start to set param weight to %s" % expected_weight)
+ blkio_paras = {'weight':int(expected_weight)}
+ status = domobj.setBlkioParameters(blkio_paras, flag)
+ if status != 0:
+ return 1
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ device = get_device(domobj, logger)
+ device_weight = "%s,%s" % (device, expected_weight)
+ logger.info("start to set param device_weight to %s"
+ % device_weight)
+ blkio_paras = {'device_weight':device_weight}
+ status = domobj.setBlkioParameters(blkio_paras, flag)
+ if status != 0:
+ return 1
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
--
1.8.3.1
2
3
So as planned we are entering freeze for libvirt-1.2.0,
I just tagged the git trees - plural as we now use libvirt-python
separate git for this binding - and pushed tarballs and rpms to
the usual place at:
ftp://libvirt.org/libvirt/
it did allows a correct update at the rpm level for me and
virt-manager does work correctly at least with my minimal testing.
We now need further reviews, obviously on the portability front
especially as the python bindings are a separate tarball. It would be
cool to get more testing on specific aspects of the release too, like
the gluster pool and VBox 4.3 support.
Give it a try,
thanks !
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
2
3
As of 21685c955 the 'distcheck' is broken. The problem is, by default it
copies all the necessary files and make them read only. However, pci
device detach test doesn't work that way. The PCI device configs are
stored within our tests/ directory and need to be writable (detaching
and resetting means writing into the config file). Hence, we must make
those files writable again.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/Makefile.am | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e46d5f7..29dbf76 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -921,3 +921,8 @@ endif ! WITH_CIL
CLEANFILES = *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda *.cmi *.cmx \
object-locking-files.txt
+
+# Some tests tend to write into files. Notably, the virpcitest, which detach
+# and reset a pci device (achieved byt writing into a pci config file).
+check-local:
+ chmod -R u+w $(srcdir)/virpcitestdata/
--
1.8.4.4
3
3
[libvirt] [PATCH] network: properly update iptables rules during net-update
by Laine Stump 27 Nov '13
by Laine Stump 27 Nov '13
27 Nov '13
This patch resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=1035336
The basic problem is that during a network update, the required
iptables rules sometimes change, and this was being handled by simply
removing and re-adding the rules. However, the removal of the old
rules was done based on the *new* state of the network, which would
mean that some of the rules would not match those currently in the
system, so the old rules wouldn't be removed.
This patch removes the old rules prior to updating the network
definitionm then adds the new rules as soon as the definition is
updated. Note that this could lead to a stray packet or two during the
interim, but that was already a problem before (the period of limbo is
now just slightly longer).
While moving the location for the rules, I added a few more sections that should result in the iptables rules being redone:
DHCP_RANGE and DHCP_HOST - these are needed because adding/removing a dhcp
host entry could lead to the dhcp service being started/stopped, which
would require that the mangle rule that fixes up dhcp response
checksums sould need to be added/removed, and this wasn't being done.
---
src/network/bridge_driver.c | 47 +++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 83dc931..d7f12e1 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2642,6 +2642,7 @@ networkUpdate(virNetworkPtr net,
size_t i;
virNetworkIpDefPtr ipdef;
bool oldDhcpActive = false;
+ bool needFirewallRefresh = false;
virCheckFlags(VIR_NETWORK_UPDATE_AFFECT_LIVE |
@@ -2683,8 +2684,39 @@ networkUpdate(virNetworkPtr net,
flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
}
+ if (isActive && (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE)) {
+ /* Take care of anything that must be done before updating the
+ * live NetworkDef.
+ */
+ if (network->def->forward.type == VIR_NETWORK_FORWARD_NONE ||
+ network->def->forward.type == VIR_NETWORK_FORWARD_NAT ||
+ network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE) {
+ switch (section) {
+ case VIR_NETWORK_SECTION_FORWARD:
+ case VIR_NETWORK_SECTION_FORWARD_INTERFACE:
+ case VIR_NETWORK_SECTION_IP:
+ case VIR_NETWORK_SECTION_IP_DHCP_RANGE:
+ case VIR_NETWORK_SECTION_IP_DHCP_HOST:
+ /* these could affect the firewall rules, so remove the
+ * old rules (and remember to load new ones after the
+ * update).
+ */
+ networkRemoveFirewallRules(network);
+ needFirewallRefresh = true;
+ default:
+ break;
+ }
+ }
+ }
+
/* update the network config in memory/on disk */
- if (virNetworkObjUpdate(network, command, section, parentIndex, xml, flags) < 0)
+ if (virNetworkObjUpdate(network, command, section, parentIndex, xml, flags) < 0) {
+ if (needFirewallRefresh)
+ ignore_value(networkAddFirewallRules(network));
+ goto cleanup;
+ }
+
+ if (needFirewallRefresh && networkAddFirewallRules(network) < 0)
goto cleanup;
if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) {
@@ -2754,19 +2786,6 @@ networkUpdate(virNetworkPtr net,
goto cleanup;
}
- if ((section == VIR_NETWORK_SECTION_IP ||
- section == VIR_NETWORK_SECTION_FORWARD ||
- section == VIR_NETWORK_SECTION_FORWARD_INTERFACE) &&
- (network->def->forward.type == VIR_NETWORK_FORWARD_NONE ||
- network->def->forward.type == VIR_NETWORK_FORWARD_NAT ||
- network->def->forward.type == VIR_NETWORK_FORWARD_ROUTE)) {
- /* these could affect the iptables rules */
- networkRemoveFirewallRules(network);
- if (networkAddFirewallRules(network) < 0)
- goto cleanup;
-
- }
-
/* save current network state to disk */
if ((ret = virNetworkSaveStatus(driverState->stateDir,
network)) < 0) {
--
1.8.4.2
2
1
'make distcheck' has been broken since commit 21685c9; basically,
it emulates the case of a read-only $(srcdir) (such as building
from a tarball exploded onto a CD-ROM), but we were creating our
fake pci device as a symlink into $(srcdir) and failing when that
requires opening the config file for writing:
3) testVirPCIDeviceReset ... libvirt: error : Failed to open config space file '/sys/bus/pci/devices/0000:00:01.0/config': Permission denied
Fix it by copying rather than symlinking.
* tests/virpcimock.c (make_file): Add parameter to allow binary
creation; adjust all callers.
(pci_device_new_from_stub): Copy rather than symlink.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule, as an alternative
to the earlier attempt that I nak'ed:
https://www.redhat.com/archives/libvir-list/2013-November/msg00999.html
tests/virpcimock.c | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 48d5f16..a5cef46 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -154,10 +154,13 @@ static int pci_driver_handle_remove_id(const char *path);
static void
make_file(const char *path,
const char *name,
- const char *value)
+ const char *value,
+ ssize_t len)
{
int fd = -1;
char *filepath = NULL;
+ if (value && len == -1)
+ len = strlen(value);
if (virAsprintfQuiet(&filepath, "%s/%s", path, name) < 0)
ABORT_OOM();
@@ -165,7 +168,7 @@ make_file(const char *path,
if ((fd = realopen(filepath, O_CREAT|O_WRONLY, 0666)) < 0)
ABORT("Unable to open: %s", filepath);
- if (value && safewrite(fd, value, strlen(value)) != strlen(value))
+ if (value && safewrite(fd, value, len) != len)
ABORT("Unable to write: %s", filepath);
VIR_FORCE_CLOSE(fd);
@@ -302,7 +305,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
{
struct pciDevice *dev;
char *devpath;
- char *configSrc, *configDst;
+ char *configSrc;
char tmp[32];
struct stat sb;
@@ -321,25 +324,32 @@ pci_device_new_from_stub(const struct pciDevice *data)
* symlink it. Otherwise create a dummy config file. */
if ((realstat && realstat(configSrc, &sb) == 0) ||
(real__xstat && real__xstat(_STAT_VER, configSrc, &sb) == 0)) {
- /* On success make symlink to @configSrc */
- if (virAsprintfQuiet(&configDst, "%s/config", devpath) < 0)
- ABORT_OOM();
-
- if (symlink(configSrc, configDst) < 0)
- ABORT("Unable to create symlink: %s", configDst);
+ /* On success, copy @configSrc into the destination (a copy,
+ * rather than a symlink, is required since we write into the
+ * file, and parallel VPATH builds must not stomp on the
+ * original; besides, 'make distcheck' requires the original
+ * to be read-only */
+ char *buf;
+ ssize_t len;
+
+ if ((len = virFileReadAll(configSrc, 4096, &buf)) < 0)
+ ABORT("Unable to read config file '%s'", configSrc);
+
+ make_file(devpath, "config", buf, len);
+ VIR_FREE(buf);
} else {
/* If there's no config data in the virpcitestdata dir, create a dummy
* config file */
- make_file(devpath, "config", "some dummy config");
+ make_file(devpath, "config", "some dummy config", -1);
}
if (snprintf(tmp, sizeof(tmp), "0x%.4x", dev->vendor) < 0)
ABORT("@tmp overflow");
- make_file(devpath, "vendor", tmp);
+ make_file(devpath, "vendor", tmp, -1);
if (snprintf(tmp, sizeof(tmp), "0x%.4x", dev->device) < 0)
ABORT("@tmp overflow");
- make_file(devpath, "device", tmp);
+ make_file(devpath, "device", tmp, -1);
if (pci_device_autobind(dev) < 0)
ABORT("Unable to bind: %s", data->id);
@@ -348,6 +358,7 @@ pci_device_new_from_stub(const struct pciDevice *data)
ABORT_OOM();
VIR_FREE(devpath);
+ VIR_FREE(configSrc);
}
static struct pciDevice *
@@ -425,10 +436,10 @@ pci_driver_new(const char *name, ...)
va_end(args);
- make_file(driverpath, "bind", NULL);
- make_file(driverpath, "unbind", NULL);
- make_file(driverpath, "new_id", NULL);
- make_file(driverpath, "remove_id", NULL);
+ make_file(driverpath, "bind", NULL, -1);
+ make_file(driverpath, "unbind", NULL, -1);
+ make_file(driverpath, "new_id", NULL, -1);
+ make_file(driverpath, "remove_id", NULL, -1);
if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPciDrivers, driver) < 0)
ABORT_OOM();
--
1.8.3.1
1
0
While trying to debug a failure of virpcitest during 'make distcheck',
I noticed that with a VPATH build, 'cd tests; ./virpcitest' fails for
an entirely different reason. To reproduce the distcheck failure, I
had to run 'cd tests; abs_srcdir=/path/to/src ./virpcitest'. But we
document in HACKING that all of our tests are supposed to be runnable
without requiring extra environment variables.
The solution: hardcode the location of srcdir into the just-built
binaries, rather than requiring make to prepopulate environment
variables. With this, './virpcitest' passes even in a VPATH build
(provided that $(srcdir) is writable; a followup patch will fix the
conditions required by 'make distcheck').
* tests/Makefile.am (AM_CFLAGS): Define abs_srcdir in all compiled
tests.
* tests/testutils.h (abs_srcdir): Quit declaring.
* tests/testutils.c (virtTestMain): Rely on define rather than
environment variable.
* tests/virpcimock.c (pci_device_new_from_stub): Rely on define.
* tests/cputest.c (mymain): Adjust abs_top_srcdir default.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxmlnstest.c (mymain): Likewise.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
tests/Makefile.am | 1 +
tests/cputest.c | 2 +-
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxmlnstest.c | 2 +-
tests/testutils.c | 11 +----------
tests/testutils.h | 6 +++++-
tests/virpcimock.c | 12 ++++--------
7 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e46d5f7..520fd2a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -29,6 +29,7 @@ INCLUDES = \
AM_CFLAGS = \
-Dabs_builddir="\"`pwd`\"" \
+ -Dabs_srcdir="\"`cd '$(srcdir)'; pwd`\"" \
$(LIBXML_CFLAGS) \
$(GNUTLS_CFLAGS) \
$(SASL_CFLAGS) \
diff --git a/tests/cputest.c b/tests/cputest.c
index b80fac7..20bc544 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -503,7 +503,7 @@ mymain(void)
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir)
- abs_top_srcdir = "..";
+ abs_top_srcdir = abs_srcdir "/..";
if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 ||
cpuMapOverride(map) < 0) {
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index a290062..dad5973 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -297,7 +297,7 @@ mymain(void)
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir)
- abs_top_srcdir = "..";
+ abs_top_srcdir = abs_srcdir "/..";
driver.config = virQEMUDriverConfigNew(false);
VIR_FREE(driver.config->spiceListen);
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 2cc15d1..2093e1e 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -203,7 +203,7 @@ mymain(void)
abs_top_srcdir = getenv("abs_top_srcdir");
if (!abs_top_srcdir)
- abs_top_srcdir = "..";
+ abs_top_srcdir = abs_srcdir "/..";
driver.config = virQEMUDriverConfigNew(false);
if ((driver.caps = testQemuCapsInit()) == NULL)
diff --git a/tests/testutils.c b/tests/testutils.c
index 5d634b4..32fe374 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -69,7 +69,6 @@ static size_t testStart = 0;
static size_t testEnd = 0;
char *progname;
-char *abs_srcdir;
void virtTestResult(const char *name, int ret, const char *msg, ...)
{
@@ -535,15 +534,9 @@ int virtTestMain(int argc,
int (*func)(void))
{
int ret;
- bool abs_srcdir_cleanup = false;
char *testRange = NULL;
- abs_srcdir = getenv("abs_srcdir");
- if (!abs_srcdir) {
- abs_srcdir = getcwd(NULL, 0);
- abs_srcdir_cleanup = true;
- }
- if (!abs_srcdir)
+ if (!virFileExists(abs_srcdir))
return EXIT_AM_HARDFAIL;
progname = last_component(argv[0]);
@@ -599,8 +592,6 @@ int virtTestMain(int argc,
ret = (func)();
- if (abs_srcdir_cleanup)
- VIR_FREE(abs_srcdir);
virResetLastError();
if (!virTestGetVerbose() && ret != EXIT_AM_SKIP) {
if (testCounter == 0 || testCounter % 40)
diff --git a/tests/testutils.h b/tests/testutils.h
index 478b53c..674d3df 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -38,7 +38,11 @@
# endif
extern char *progname;
-extern char *abs_srcdir;
+
+/* Makefile.am provides these two definitions */
+# if !defined(abs_srcdir) || !defined(abs_builddir)
+# error Fix Makefile.am
+# endif
void virtTestResult(const char *name, int ret, const char *msg, ...)
ATTRIBUTE_FMT_PRINTF(3,4);
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 19062c3..48d5f16 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -305,14 +305,10 @@ pci_device_new_from_stub(const struct pciDevice *data)
char *configSrc, *configDst;
char tmp[32];
struct stat sb;
- char *abs_srcdir;
-
- abs_srcdir = getenv("abs_srcdir");
- if (!abs_srcdir)
- abs_srcdir = getcwd(NULL, 0);
if (VIR_ALLOC_QUIET(dev) < 0 ||
- virAsprintfQuiet(&configSrc, "%s/virpcitestdata/%s.config", abs_srcdir, data->id) < 0 ||
+ virAsprintfQuiet(&configSrc, "%s/virpcitestdata/%s.config",
+ abs_srcdir, data->id) < 0 ||
virAsprintfQuiet(&devpath, "%s/devices/%s", fakesysfsdir, data->id) < 0)
ABORT_OOM();
@@ -480,7 +476,7 @@ pci_driver_bind(struct pciDriver *driver,
char *devpath = NULL, *driverpath = NULL;
if (dev->driver) {
- /* Device already binded */
+ /* Device already bound */
errno = ENODEV;
return ret;
}
@@ -527,7 +523,7 @@ pci_driver_unbind(struct pciDriver *driver,
char *devpath = NULL, *driverpath = NULL;
if (dev->driver != driver) {
- /* Device not binded to the @driver */
+ /* Device not bound to the @driver */
errno = ENODEV;
return ret;
}
--
1.8.3.1
1
1
[libvirt] [PATCH] Remove invalid parsing of pty path from XML for PTY type chardevs
by Nehal J Wani 27 Nov '13
by Nehal J Wani 27 Nov '13
27 Nov '13
While running valgrind on the qemuhotplugtest, one of the many memory leaks
detected are:
==3915== 12 bytes in 1 blocks are definitely lost in loss record 36 of 129
==3915== at 0x4A0887C: malloc (vg_replace_malloc.c:270)
==3915== by 0x34268AF275: xmlStrndup (in /usr/lib64/libxml2.so.2.9.1)
==3915== by 0x4CCC3BB: virDomainChrSourceDefParseXML (domain_conf.c:6957)
==3915== by 0x4CD6A29: virDomainChrDefParseXML (domain_conf.c:7243)
==3915== by 0x4CEC0C9: virDomainDeviceDefParse (domain_conf.c:9616)
==3915== by 0x41D14F: testQemuHotplug (qemuhotplugtest.c:247)
==3915== by 0x41E421: virtTestRun (testutils.c:139)
==3915== by 0x41C6E3: mymain (qemuhotplugtest.c:428)
==3915== by 0x41EAB2: virtTestMain (testutils.c:600)
==3915== by 0x341F421A04: (below main) (libc-start.c:225)
==3915==
The main reason behind this error is that for the PTY type chardevs, it is
not valid to specify or parse a pty path from the XML. This is an output-only
attribute, not under user control. Hence, the parsing code inside
qemuMonitorJSONAttachCharDev() was wrong.
Refer the discussion: https://www.redhat.com/archives/libvir-list/2013-November/msg01255.html
tests/qemumonitorjsontest.c
* Remove unwanted parsing code inside qemuMonitorJSONAttachCharDev
src/qemu/qemu_monitor_json.c:
* Remove erraneous testcase
---
src/qemu/qemu_monitor_json.c | 20 --------------------
tests/qemumonitorjsontest.c | 16 ----------------
2 files changed, 36 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index ec3b958..1bfeef0 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5368,26 +5368,6 @@ qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon,
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
- if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
- virJSONValuePtr data;
- const char *path;
-
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("chardev-add reply was missing return data"));
- goto cleanup;
- }
-
- if (!(path = virJSONValueObjectGetString(data, "pty"))) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("chardev-add reply was missing pty path"));
- goto cleanup;
- }
-
- if (VIR_STRDUP(chr->data.file.path, path) < 0)
- goto cleanup;
- }
-
ret = 0;
cleanup:
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 2152e4a..a3c38b6 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -708,22 +708,6 @@ testQemuMonitorJSONAttachChardev(const void *data)
chr = (virDomainChrSourceDef) { .type =VIR_DOMAIN_CHR_TYPE_VC };
CHECK("chr_vc", "{\"return\": {}}");
-#define PTY_PATH "/dev/ttyS0"
- chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_PTY };
- CHECK("chr_pty", "{\"return\": {\"pty\" : \"" PTY_PATH "\"}}");
- if (STRNEQ_NULLABLE(PTY_PATH, chr.data.file.path)) {
- VIR_FREE(chr.data.file.path);
- virReportError(VIR_ERR_INTERNAL_ERROR,
- "expected PTY path: %s got: %s",
- PTY_PATH, NULLSTR(chr.data.file.path));
- ret = -1;
- }
- VIR_FREE(chr.data.file.path);
-
- chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_PTY };
- CHECK_FAIL("chr_pty_fail", "{\"return\": {}}");
-#undef PTY_PATH
-
chr = (virDomainChrSourceDef) { .type = VIR_DOMAIN_CHR_TYPE_FILE };
CHECK("chr_file", "{\"return\": {}}");
--
1.8.1.4
2
2
[libvirt] [PATCH] Memory Leak Fix: Check def->info->alias before assigning
by Nehal J Wani 27 Nov '13
by Nehal J Wani 27 Nov '13
27 Nov '13
On running the command make -C tests valgrind, there used to be a bunch of
memory leaks shown by valgrind. Specifically, one can check it by running:
libtool --mode=execute valgrind --quiet --leak-check=full --suppressions=./.valgrind.supp qemuhotplugtest
The issue was that def->info->alias was already malloc'ed by xmlStrndup in
virDomainDeviceInfoParseXML (domain_conf.c:3439). The new alias was being
assigned again without freeing the old one in qemuAssignDeviceAliases().
This patch checks if the entity exists, and frees accordingly, hence making
valgrind cry lesser.
---
src/qemu/qemu_command.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 763417f..bbec1d4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -979,6 +979,8 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
size_t i;
for (i = 0; i < def->ndisks; i++) {
+ if (def->disks[i]->info.alias)
+ VIR_FREE(def->disks[i]->info.alias);
if (qemuAssignDeviceDiskAlias(def, def->disks[i], qemuCaps) < 0)
return -1;
}
@@ -988,6 +990,9 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
/* type='hostdev' interfaces are also on the hostdevs list,
* and will have their alias assigned with other hostdevs.
*/
+ if (def->nets[i]->info.alias)
+ VIR_FREE(def->nets[i]->info.alias);
+
if (virDomainNetGetActualType(def->nets[i])
!= VIR_DOMAIN_NET_TYPE_HOSTDEV &&
qemuAssignDeviceNetAlias(def, def->nets[i], i) < 0) {
@@ -1000,70 +1005,104 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
return 0;
for (i = 0; i < def->nfss; i++) {
+ if (def->fss[i]->info.alias)
+ VIR_FREE(def->fss[i]->info.alias);
if (virAsprintf(&def->fss[i]->info.alias, "fs%zu", i) < 0)
return -1;
}
for (i = 0; i < def->nsounds; i++) {
+ if (def->sounds[i]->info.alias)
+ VIR_FREE(def->sounds[i]->info.alias);
if (virAsprintf(&def->sounds[i]->info.alias, "sound%zu", i) < 0)
return -1;
}
for (i = 0; i < def->nhostdevs; i++) {
+ if (def->hostdevs[i]->info->alias)
+ VIR_FREE(def->hostdevs[i]->info->alias);
if (qemuAssignDeviceHostdevAlias(def, def->hostdevs[i], i) < 0)
return -1;
}
for (i = 0; i < def->nredirdevs; i++) {
+ if (def->redirdevs[i]->info.alias)
+ VIR_FREE(def->redirdevs[i]->info.alias);
if (qemuAssignDeviceRedirdevAlias(def, def->redirdevs[i], i) < 0)
return -1;
}
for (i = 0; i < def->nvideos; i++) {
+ if (def->videos[i]->info.alias)
+ VIR_FREE(def->videos[i]->info.alias);
if (virAsprintf(&def->videos[i]->info.alias, "video%zu", i) < 0)
return -1;
}
for (i = 0; i < def->ncontrollers; i++) {
+ if (def->controllers[i]->info.alias)
+ VIR_FREE(def->controllers[i]->info.alias);
if (qemuAssignDeviceControllerAlias(def->controllers[i]) < 0)
return -1;
}
for (i = 0; i < def->ninputs; i++) {
+ if (def->inputs[i]->info.alias)
+ VIR_FREE(def->inputs[i]->info.alias);
if (virAsprintf(&def->inputs[i]->info.alias, "input%zu", i) < 0)
return -1;
}
for (i = 0; i < def->nparallels; i++) {
+ if (def->parallels[i]->info.alias)
+ VIR_FREE(def->parallels[i]->info.alias);
if (qemuAssignDeviceChrAlias(def, def->parallels[i], i) < 0)
return -1;
}
for (i = 0; i < def->nserials; i++) {
+ if (def->serials[i]->info.alias)
+ VIR_FREE(def->serials[i]->info.alias);
if (qemuAssignDeviceChrAlias(def, def->serials[i], i) < 0)
return -1;
}
for (i = 0; i < def->nchannels; i++) {
+ if (def->channels[i]->info.alias)
+ VIR_FREE(def->channels[i]->info.alias);
if (qemuAssignDeviceChrAlias(def, def->channels[i], i) < 0)
return -1;
}
for (i = 0; i < def->nconsoles; i++) {
+ if (def->consoles[i]->info.alias)
+ VIR_FREE(def->consoles[i]->info.alias);
if (qemuAssignDeviceChrAlias(def, def->consoles[i], i) < 0)
return -1;
}
for (i = 0; i < def->nhubs; i++) {
+ if (def->hubs[i]->info.alias)
+ VIR_FREE(def->hubs[i]->info.alias);
if (virAsprintf(&def->hubs[i]->info.alias, "hub%zu", i) < 0)
return -1;
}
for (i = 0; i < def->nsmartcards; i++) {
+ if (def->smartcards[i]->info.alias)
+ VIR_FREE(def->smartcards[i]->info.alias);
if (virAsprintf(&def->smartcards[i]->info.alias, "smartcard%zu", i) < 0)
return -1;
}
if (def->watchdog) {
+ if (def->watchdog->info.alias)
+ VIR_FREE(def->watchdog->info.alias);
if (virAsprintf(&def->watchdog->info.alias, "watchdog%d", 0) < 0)
return -1;
}
if (def->memballoon) {
+ if (def->memballoon->info.alias)
+ VIR_FREE(def->memballoon->info.alias);
if (virAsprintf(&def->memballoon->info.alias, "balloon%d", 0) < 0)
return -1;
}
if (def->rng) {
+ if (def->rng->info.alias)
+ VIR_FREE(def->rng->info.alias);
if (virAsprintf(&def->rng->info.alias, "rng%d", 0) < 0)
return -1;
}
if (def->tpm) {
+ if (def->tpm->info.alias)
+ VIR_FREE(def->tpm->info.alias);
if (virAsprintf(&def->tpm->info.alias, "tpm%d", 0) < 0)
return -1;
}
--
1.8.1.4
4
7
[libvirt] [PATCH python] Deal with old filenames for events/error functions
by Daniel P. Berrange 27 Nov '13
by Daniel P. Berrange 27 Nov '13
27 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Older libvirt has files named 'events' and 'virterror'
rather than 'virevent' and 'virerror'. This is visible
in the API XML files. We must look for both names to
ensure we don't loose generation of methods with older
versions of libvirt.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/generator.py b/generator.py
index 273efbd..cd857b4 100755
--- a/generator.py
+++ b/generator.py
@@ -113,7 +113,8 @@ class docParser(xml.sax.handler.ContentHandler):
elif tag == 'enum':
# enums come from header files, hence virterror.h
if (attrs['file'] == "libvirt" or
- attrs['file'] == "virterror"):
+ attrs['file'] == "virterror" or
+ attrs['file'] == "virerror"):
enum(attrs['type'],attrs['name'],attrs['value'])
elif attrs['file'] == "libvirt-lxc":
lxc_enum(attrs['type'],attrs['name'],attrs['value'])
@@ -127,8 +128,10 @@ class docParser(xml.sax.handler.ContentHandler):
# fuctions come from source files, hence 'virerror.c'
if self.function is not None:
if (self.function_module == "libvirt" or
+ self.function_module == "event" or
self.function_module == "virevent" or
- self.function_module == "virerror"):
+ self.function_module == "virerror" or
+ self.function_module == "virterror"):
function(self.function, self.function_descr,
self.function_return, self.function_args,
self.function_file, self.function_module,
--
1.8.3.1
3
2
27 Nov '13
When attempting to backport gluster pools to an older version
where there is no VIR_STRDUP, I got a crash from calling
strdup(,NULL). Rather than relying on the current else branch
safely doing nothing when there is no fd, it is easier to just
skip it. While at it, there's no need to explicitly set
perms.label to NULL after a VIR_FREE().
* src/storage/storage_backend.c
(virStorageBackendUpdateVolTargetInfoFD): Minor optimization.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/storage/storage_backend.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index bde39d6..b08d646 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1383,28 +1383,26 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
VIR_FREE(target->perms.label);
#if WITH_SELINUX
/* XXX: make this a security driver call */
- if (fd >= 0 && fgetfilecon_raw(fd, &filecon) == -1) {
- if (errno != ENODATA && errno != ENOTSUP) {
- virReportSystemError(errno,
- _("cannot get file context of '%s'"),
- target->path);
- return -1;
+ if (fd >= 0) {
+ if (fgetfilecon_raw(fd, &filecon) == -1) {
+ if (errno != ENODATA && errno != ENOTSUP) {
+ virReportSystemError(errno,
+ _("cannot get file context of '%s'"),
+ target->path);
+ return -1;
+ }
} else {
- target->perms.label = NULL;
- }
- } else {
- if (VIR_STRDUP(target->perms.label, filecon) < 0) {
+ if (VIR_STRDUP(target->perms.label, filecon) < 0) {
+ freecon(filecon);
+ return -1;
+ }
freecon(filecon);
- return -1;
}
- freecon(filecon);
}
-#else
- target->perms.label = NULL;
#endif
return 0;
}
--
1.8.3.1
2
2
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Fix the RPM summary line, add placeholder %changelog tag,
make %setup quiet, add Url: tag and filter out bogus
provides and add example programs as docs.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
libvirt-python.spec.in | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/libvirt-python.spec.in b/libvirt-python.spec.in
index e6c229f..7c6257e 100644
--- a/libvirt-python.spec.in
+++ b/libvirt-python.spec.in
@@ -1,14 +1,19 @@
-Summary: The libvirt virtualization API
+Summary: The libvirt virtualization API python binding
Name: libvirt-python
Version: @PY_VERSION@
Release: 1%{?dist}%{?extra_release}
Source0: http://libvirt.org/sources/python/%{name}-%{version}.tar.gz
+Url: http://libvirt.org
License: LGPLv2+
Group: Development/Libraries
BuildRequires: libvirt-devel >= @C_VERSION@
BuildRequires: python-devel
+# Don't want provides for python shared objects
+%{?filter_provides_in: %filter_provides_in %{python_sitearch}/.*\.so}
+%{?filter_setup}
+
%description
The libvirt-python package contains a module that permits applications
written in the Python programming language to use the interface
@@ -16,7 +21,7 @@ supplied by the libvirt library to use the virtualization capabilities
of recent versions of Linux (and other OSes).
%prep
-%setup
+%setup -q
%build
CFLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
@@ -27,8 +32,10 @@ rm -f %{buildroot}%{_libdir}/python*/site-packages/*egg-info
%files
%defattr(-,root,root)
-%doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER
+%doc ChangeLog AUTHORS NEWS README COPYING COPYING.LESSER examples/
%{_libdir}/python*/site-packages/libvirt.py*
%{_libdir}/python*/site-packages/libvirt_qemu.py*
%{_libdir}/python*/site-packages/libvirt_lxc.py*
%{_libdir}/python*/site-packages/libvirtmod*
+
+%changelog
--
1.8.3.1
2
1
[libvirt] [PATCH python] Fix code for avoiding overrides of non-existant functions
by Daniel P. Berrange 27 Nov '13
by Daniel P. Berrange 27 Nov '13
27 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
When reading/writing a global variable from inside a method
it must be declared as a global, otherwise a local variable
by the same name will be used.
Special case the virConnectListDomainsID method which is
bizarrely renamed for no obvious reason.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/generator.py b/generator.py
index cd857b4..e8d8ea9 100755
--- a/generator.py
+++ b/generator.py
@@ -187,16 +187,21 @@ class docParser(xml.sax.handler.ContentHandler):
def function(name, desc, ret, args, file, module, cond):
+ global onlyOverrides
if onlyOverrides and name not in functions:
return
+ if name == "virConnectListDomains":
+ name = "virConnectListDomainsID"
functions[name] = (desc, ret, args, file, module, cond)
def qemu_function(name, desc, ret, args, file, module, cond):
+ global onlyOverrides
if onlyOverrides and name not in qemu_functions:
return
qemu_functions[name] = (desc, ret, args, file, module, cond)
def lxc_function(name, desc, ret, args, file, module, cond):
+ global onlyOverrides
if onlyOverrides and name not in lxc_functions:
return
lxc_functions[name] = (desc, ret, args, file, module, cond)
@@ -786,6 +791,7 @@ def buildStubs(module, api_xml):
global py_types
global py_return_types
global unknown_types
+ global onlyOverrides
if module not in ["libvirt", "libvirt-qemu", "libvirt-lxc"]:
print "ERROR: Unknown module type: %s" % module
--
1.8.3.1
2
1
[libvirt] [PATCH] Make virsh command 'domxml-to-native' copy the MAC addr parsed from XML
by marsï¼ linux.vnet.ibm.com 27 Nov '13
by marsï¼ linux.vnet.ibm.com 27 Nov '13
27 Nov '13
From: Bing Bu Cao <mars(a)linux.vnet.ibm.com>
virsh command 'domxml-to-native' did not copy the
MAC address which parsed from a domain xml, in the commandline
the MAC addr of network device always was 00:00:00:00:00:00.
This patch fix it.
Signed-off-by: Bing Bu Cao <mars(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8a1eefd..4693dad 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5821,6 +5821,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
virDomainNetDefPtr net = def->nets[i];
int bootIndex = net->info.bootIndex;
char *model = net->model;
+ virMacAddr mac = net->mac;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
int actualType = virDomainNetGetActualType(net);
@@ -5843,6 +5844,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = NULL;
net->data.ethernet.dev = brnamecopy;
net->data.ethernet.ipaddr = NULL;
+ net->mac = mac;
} else {
/* actualType is either NETWORK or DIRECT. In either
* case, the best we can do is NULL everything out.
@@ -5854,6 +5856,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = NULL;
net->data.ethernet.dev = NULL;
net->data.ethernet.ipaddr = NULL;
+ net->mac = mac;
}
} else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
VIR_FREE(net->data.direct.linkdev);
@@ -5864,6 +5867,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = NULL;
net->data.ethernet.dev = NULL;
net->data.ethernet.ipaddr = NULL;
+ net->mac = mac;
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
char *script = net->script;
char *brname = net->data.bridge.brname;
@@ -5875,6 +5879,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
net->script = script;
net->data.ethernet.dev = brname;
net->data.ethernet.ipaddr = ipaddr;
+ net->mac = mac;
}
VIR_FREE(net->virtPortProfile);
--
1.7.7.6
2
1
[libvirt] [PATCH python] Add missing binding of security model/label APIs
by Daniel P. Berrange 27 Nov '13
by Daniel P. Berrange 27 Nov '13
27 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The virNodeGetSecurityModel, virDomainGetSecurityLabel and
virDomainGetSecurityLabelList methods were disabled in the
python binding for inexplicable reasons.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 6 ++--
libvirt-override-api.xml | 15 +++++++++
libvirt-override.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
typewrappers.c | 9 ++++++
typewrappers.h | 1 +
5 files changed, 110 insertions(+), 3 deletions(-)
diff --git a/generator.py b/generator.py
index ab2a97f..273efbd 100755
--- a/generator.py
+++ b/generator.py
@@ -381,6 +381,9 @@ skip_impl = (
'virDomainGetJobInfo',
'virDomainGetJobStats',
'virNodeGetInfo',
+ 'virNodeGetSecurityModel',
+ 'virDomainGetSecurityLabel',
+ 'virDomainGetSecurityLabelList',
'virDomainGetUUID',
'virDomainGetUUIDString',
'virDomainLookupByUUID',
@@ -476,9 +479,6 @@ skip_function = (
'virCopyLastError', # Python API is called virGetLastError instead
'virConnectOpenAuth', # Python C code is manually written
'virDefaultErrorFunc', # Python virErrorFuncHandler impl calls this from C
- 'virDomainGetSecurityLabel', # Needs investigation...
- 'virDomainGetSecurityLabelList', # Needs investigation...
- 'virNodeGetSecurityModel', # Needs investigation...
'virConnectDomainEventRegister', # overridden in virConnect.py
'virConnectDomainEventDeregister', # overridden in virConnect.py
'virConnectDomainEventRegisterAny', # overridden in virConnect.py
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 337d0a0..d5b25b5 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -104,6 +104,21 @@
<return type='char *' info='the list of information or None in case of error'/>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
</function>
+ <function name='virNodeGetSecurityModel' file='python'>
+ <info>Extract information about the host security model</info>
+ <return type='char *' info='the list of information or None in case of error'/>
+ <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
+ </function>
+ <function name='virDomainGetSecurityLabel' file='python'>
+ <info>Extract information about the domain security label. Only the first label will be returned.</info>
+ <return type='char *' info='the list of information or None in case of error'/>
+ <arg name='domain' type='virDomainPtr' info='a domain object'/>
+ </function>
+ <function name='virDomainGetSecurityLabelList' file='python'>
+ <info>Extract information about the domain security label. A list of all labels will be returned.</info>
+ <return type='char *' info='the list of information or None in case of error'/>
+ <arg name='domain' type='virDomainPtr' info='a domain object'/>
+ </function>
<function name='virNodeGetCPUStats' file='python'>
<info>Extract node's CPU statistics.</info>
<return type='char *' info='dictionary mapping field names to values or None in case of error'/>
diff --git a/libvirt-override.c b/libvirt-override.c
index d3802de..42e253e 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -2865,6 +2865,83 @@ libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
}
static PyObject *
+libvirt_virNodeGetSecurityModel(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ PyObject *py_retval;
+ int c_retval;
+ virConnectPtr conn;
+ PyObject *pyobj_conn;
+ virSecurityModel model;
+
+ if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityModel", &pyobj_conn))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virNodeGetSecurityModel(conn, &model);
+ LIBVIRT_END_ALLOW_THREADS;
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+ py_retval = PyList_New(2);
+ PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&model.model[0]));
+ PyList_SetItem(py_retval, 1, libvirt_constcharPtrWrap(&model.doi[0]));
+ return py_retval;
+}
+
+static PyObject *
+libvirt_virDomainGetSecurityLabel(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ PyObject *py_retval;
+ int c_retval;
+ virDomainPtr dom;
+ PyObject *pyobj_dom;
+ virSecurityLabel label;
+
+ if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityLabel", &pyobj_dom))
+ return NULL;
+ dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainGetSecurityLabel(dom, &label);
+ LIBVIRT_END_ALLOW_THREADS;
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+ py_retval = PyList_New(2);
+ PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&label.label[0]));
+ PyList_SetItem(py_retval, 1, libvirt_boolWrap(label.enforcing));
+ return py_retval;
+}
+
+#if LIBVIR_CHECK_VERSION(0, 9, 13)
+static PyObject *
+libvirt_virDomainGetSecurityLabelList(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
+ PyObject *py_retval;
+ int c_retval;
+ virDomainPtr dom;
+ PyObject *pyobj_dom;
+ virSecurityLabel *labels;
+ size_t i;
+
+ if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityLabel", &pyobj_dom))
+ return NULL;
+ dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virDomainGetSecurityLabelList(dom, &labels);
+ LIBVIRT_END_ALLOW_THREADS;
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+ py_retval = PyList_New(0);
+ for (i = 0 ; i < c_retval ; i++) {
+ PyObject *entry = PyList_New(2);
+ PyList_SetItem(entry, 0, libvirt_constcharPtrWrap(&labels[i].label[0]));
+ PyList_SetItem(entry, 1, libvirt_boolWrap(labels[i].enforcing));
+ PyList_Append(py_retval, entry);
+ }
+ free(labels);
+ return py_retval;
+}
+#endif
+
+static PyObject *
libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
PyObject *py_retval;
unsigned char uuid[VIR_UUID_BUFLEN];
@@ -7304,6 +7381,11 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo, METH_VARARGS, NULL},
{(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo, METH_VARARGS, NULL},
{(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
+ {(char *) "virNodeGetSecurityModel", libvirt_virNodeGetSecurityModel, METH_VARARGS, NULL},
+ {(char *) "virDomainGetSecurityLabel", libvirt_virDomainGetSecurityLabel, METH_VARARGS, NULL},
+#if LIBVIR_CHECK_VERSION(0, 9, 13)
+ {(char *) "virDomainGetSecurityLabelList", libvirt_virDomainGetSecurityLabelList, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
{(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats, METH_VARARGS, NULL},
{(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats, METH_VARARGS, NULL},
{(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
diff --git a/typewrappers.c b/typewrappers.c
index d6cbbf1..1622986 100644
--- a/typewrappers.c
+++ b/typewrappers.c
@@ -116,6 +116,15 @@ libvirt_constcharPtrWrap(const char *str)
return ret;
}
+PyObject *
+libvirt_boolWrap(int val)
+{
+ if (val)
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
int
libvirt_intUnwrap(PyObject *obj, int *val)
{
diff --git a/typewrappers.h b/typewrappers.h
index d871d3f..04e364f 100644
--- a/typewrappers.h
+++ b/typewrappers.h
@@ -164,6 +164,7 @@ PyObject * libvirt_ulonglongWrap(unsigned long long val);
PyObject * libvirt_charPtrWrap(char *str);
PyObject * libvirt_charPtrSizeWrap(char *str, Py_ssize_t size);
PyObject * libvirt_constcharPtrWrap(const char *str);
+PyObject * libvirt_boolWrap(int val);
int libvirt_intUnwrap(PyObject *obj, int *val);
int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
int libvirt_longUnwrap(PyObject *obj, long *val);
--
1.8.3.1
2
2
[libvirt] [PATCH python] Avoid generating the migrate methods in multiple classes
by Daniel P. Berrange 27 Nov '13
by Daniel P. Berrange 27 Nov '13
27 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The python code generator tries to figure out what class a
method should be in by looking at the list of arguments for
any which are object types. Unfortunately missing break
statements meant that methods which have multiple object
arguments (eg migrate as a virDomainPtr followed by a
virConnectPtr) got added to multiple classes. The migrate
methods should only be visible in the virDomain class, and
the versions in the virConnect class have fubar arguments.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/generator.py b/generator.py
index c769ed0..ab2a97f 100755
--- a/generator.py
+++ b/generator.py
@@ -1264,12 +1264,14 @@ def buildWrappers(module):
func = nameFixup(name, classe, type, file)
info = (0, func, name, ret, args, file, mod)
function_classes[classe].append(info)
+ break
elif name[0:3] == "vir" and len(args) >= 2 and args[1][1] == type \
and file != "python_accessor" and not name in function_skip_index_one:
found = 1
func = nameFixup(name, classe, type, file)
info = (1, func, name, ret, args, file, mod)
function_classes[classe].append(info)
+ break
if found == 1:
continue
func = nameFixup(name, "None", file, file)
--
1.8.3.1
2
2
[libvirt] virDomain{Attach, Detach, Update}DeviceFlags filesystem support for qemu driver
by Jesse Cook 27 Nov '13
by Jesse Cook 27 Nov '13
27 Nov '13
It does not currently appear to be possible to attach/detach a filesystem
with kvm through the C API or virsh. Looking at
src/qemu/qemu_driver.c:qemuDomain{Attach,Detach,Update}Config,
VIR_DOMAIN_DEVICE_FS is not a case within the switch statement for
dev->type.
Is support for this planned for the near future or in progress? If not, how
much would have to be implemented outside these functions to add support
for attaching, detaching, and modifying filesystems? I would like to gauge
whether I should carve out time to add support, or work around it by using
disks in place of filesystems. Thanks!
--
Jesse J. Cook
Camber Corporation
Lead Software Developer
2
1
27 Nov '13
The 'out' returned from exec_cmds is not 'None' type if stderr occurs, it is
because utils pass 'subprocess.PIPE' to stdout to open this subprocess.
"Similarly, to get anything other than None in the result tuple, you need to
give stdout=PIPE and/or stderr=PIPE too."
(see http://docs.python.org/2/library/subprocess.html#module-subprocess)
Finally, make out equals to err when stderr happened.
---
utils/utils.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/utils/utils.py b/utils/utils.py
index 147c1ef..2248ce1 100644
--- a/utils/utils.py
+++ b/utils/utils.py
@@ -404,14 +404,12 @@ def exec_cmd(command, sudo=False, cwd=None, infile=None, outfile=None, shell=Fal
command = ["sudo"] + command
if infile == None:
infile = subprocess.PIPE
- if outfile == None:
- outfile = subprocess.PIPE
p = subprocess.Popen(command, shell=shell, close_fds=True, cwd=cwd,
stdin=infile, stdout=outfile, stderr=subprocess.PIPE)
(out, err) = p.communicate(data)
if out == None:
- # Prevent splitlines() from barfing later on
- out = ""
+ # Because stderr is PIPE, err will not be None, and can be splitlines.
+ out = err
return (p.returncode, out.splitlines())
def remote_exec_pexpect(hostname, username, password, cmd):
--
1.8.3.1
2
8
When looking for numad with AC_PATH_PROG, include /usr/sbin in
the search path.
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 4942e07..f494f46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1454,7 +1454,7 @@ AC_ARG_WITH([numad],
if test "$with_numad" != "no" ; then
fail=0
- AC_PATH_PROG([NUMAD], [numad], [], [/bin:/usr/bin])
+ AC_PATH_PROG([NUMAD], [numad], [], [/bin:/usr/bin:/usr/sbin])
if test "$with_numad" = "check"; then
test "$with_numactl" = "yes" || fail=1
--
1.8.0.1
2
2
[libvirt] [test-API][PATCH V2] Modify previous test cases by invoking api
by Jincheng Miao 27 Nov '13
by Jincheng Miao 27 Nov '13
27 Nov '13
* repos/domain/blkstats.py
* repos/domain/domain_blkinfo.py
Function blkstats and domain_blkinfo used virsh commands to test result,
that is not fit for testing api, so I replace commands with invoking api.
V1->V2:
Removed blockdev params for domain_blkinfo, this hard code disk device is
not convenient for users.
---
repos/domain/blkstats.py | 2 -
repos/domain/domain_blkinfo.py | 94 ++++++++++++++++++++++++------------------
2 files changed, 55 insertions(+), 41 deletions(-)
diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py
index 0254922..27c2a46 100644
--- a/repos/domain/blkstats.py
+++ b/repos/domain/blkstats.py
@@ -1,8 +1,6 @@
#!/usr/bin/evn python
# To test domain block device statistics
-import os
-import sys
import time
import libxml2
diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py
index b6051aa..81035ed 100644
--- a/repos/domain/domain_blkinfo.py
+++ b/repos/domain/domain_blkinfo.py
@@ -1,22 +1,17 @@
#!/usr/bin/env python
-# To test "virsh domblkinfo" command
+# To test domain's blockkinfo API
-import os
-import sys
-import re
import commands
-
+import libxml2
import libvirt
from libvirt import libvirtError
from src import sharedmod
-GET_DOMBLKINFO_MAC = "virsh domblkinfo %s %s | awk '{print $2}'"
GET_CAPACITY = "du -b %s | awk '{print $1}'"
GET_PHYSICAL_K = " du -B K %s | awk '{print $1}'"
-VIRSH_DOMBLKINFO = "virsh domblkinfo %s %s"
-required_params = ('guestname', 'blockdev',)
+required_params = ('guestname', )
optional_params = {}
def get_output(command, logger):
@@ -32,8 +27,8 @@ def check_domain_exists(conn, guestname, logger):
""" check if the domain exists, may or may not be active """
guest_names = []
ids = conn.listDomainsID()
- for id in ids:
- obj = conn.lookupByID(id)
+ for domain_id in ids:
+ obj = conn.lookupByID(domain_id)
guest_names.append(obj.name())
guest_names += conn.listDefinedDomains()
@@ -44,17 +39,27 @@ def check_domain_exists(conn, guestname, logger):
else:
return True
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
def check_block_data(blockdev, blkdata, logger):
""" check data about capacity,allocation,physical """
status, apparent_size = get_output(GET_CAPACITY % blockdev, logger)
if not status:
- if apparent_size == blkdata[0]:
- logger.info("the capacity of '%s' is %s, checking succeeded" % \
- (blockdev, apparent_size))
+ if apparent_size == str(blkdata[0]):
+ logger.info("the capacity of '%s' is %s, checking succeeded"
+ % (blockdev, apparent_size))
else:
- logger.error("apparent-size from 'du' is %s, \n\
- but from 'domblkinfo' is %s, checking failed" % \
- (apparent_size, blkdata[0]))
+ logger.error("apparent-size from 'du' is %s" % apparent_size)
+ logger.error("but from 'domain blockinfo' is %d, checking failed"
+ % blkdata[0])
return 1
else:
return 1
@@ -64,14 +69,15 @@ def check_block_data(blockdev, blkdata, logger):
block_size_b = int(block_size_k[:-1]) * 1024
# Temporarily, we only test the default case, assuming
# Allocation value is equal to Physical value
- if str(block_size_b) == blkdata[1] and str(block_size_b) == blkdata[2]:
- logger.info("the block size of '%s' is %s, same with \n\
- Allocation and Physical value, checking succeeded" % \
- (blockdev, block_size_b))
+ if block_size_b == blkdata[1] and block_size_b == blkdata[2]:
+ logger.info("the block size of '%s' is %s"
+ % (blockdev, block_size_b))
+ logger.info("Allocation and Physical value's checking succeeded")
else:
- logger.error("the block size from 'du' is %s, \n\
- the Allocation value is %s, Physical value is %s, \n\
- checking failed" % (block_size_b, blkdata[1], blkdata[2]))
+ logger.error("the block size from 'du' is %d" % block_size_b)
+ logger.error("the Allocation value is %d, Physical value is %d"
+ % (blkdata[1], blkdata[2]))
+ logger.error("checking failed")
return 1
return 0
@@ -79,14 +85,12 @@ def check_block_data(blockdev, blkdata, logger):
def domain_blkinfo(params):
""" using du command to check the data
- in the output of virsh domblkinfo
+ in the output of API blockinfo
"""
logger = params['logger']
guestname = params.get('guestname')
- blockdev = params.get('blockdev')
logger.info("the name of guest is %s" % guestname)
- logger.info("the block device is %s" % blockdev)
conn = sharedmod.libvirtobj['conn']
@@ -94,23 +98,35 @@ def domain_blkinfo(params):
logger.error("need a defined guest")
return 1
- logger.info("the output of virsh domblkinfo is:")
- status, output = get_output(VIRSH_DOMBLKINFO % (guestname, blockdev), logger)
- if not status:
- logger.info("\n" + output)
- else:
+ domobj = conn.lookupByName(guestname)
+
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/source/@file")
+ blockdev = vdevs[0].content
+ logger.info("the block device is %s" % blockdev)
+
+ if not check_guest_status(domobj):
+ logger.error("guest is not started.")
return 1
- status, data_str = get_output(GET_DOMBLKINFO_MAC % (guestname, blockdev), logger)
- if not status:
- blkdata = data_str.rstrip().split('\n')
- logger.info("capacity,allocation,physical list: %s" % blkdata)
- else:
+ try:
+ logger.info("the output of domain blockinfo is:")
+ block_info = domobj.blockInfo(blockdev, 0)
+ logger.info("Capacity : %d " % block_info[0])
+ logger.info("Allocation: %d " % block_info[1])
+ logger.info("Physical : %d " % block_info[2])
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
return 1
- if check_block_data(blockdev, blkdata, logger):
- logger.error("checking domblkinfo data FAILED")
+ if check_block_data(blockdev, block_info, logger):
+ logger.error("checking domain blockinfo data FAILED")
return 1
else:
- logger.info("checking domblkinfo data SUCCEEDED")
+ logger.info("checking domain blockinfo data SUCCEEDED")
+
return 0
--
1.8.3.1
1
0
26 Nov '13
Commit 348b4e2 introduced a potential problem (thankfully not
in any release): we are attempting to use virFileReadHeaderFD()
on a file that was opened with O_NONBLOCK. While this
shouldn't be a problem in practice (because O_NONBLOCK
typically doesn't affect regular or block files, and fifos and
sockets cannot be storage volumes), it's better to play it safe
to avoid races from opening an unexpected file type while also
avoiding problems with having to handle EAGAIN while read()ing.
Based on a report by Dan Berrange.
* src/storage/storage_backend.c
(virStorageBackendVolOpenCheckMode): Fix up fd after avoiding race.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/storage/storage_backend.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 57c1728..bde39d6 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1179,6 +1179,12 @@ virStorageBackendVolOpenCheckMode(const char *path, struct stat *sb,
return -2;
}
+ /* O_NONBLOCK should only matter during open() for fifos and
+ * sockets, which we already filtered; but using it prevents a
+ * TOCTTOU race. However, later on we will want to read() the
+ * header from this fd, and virFileRead* routines require a
+ * blocking fd, so fix it up after verifying we avoided a
+ * race. */
if ((fd = open(path, O_RDONLY|O_NONBLOCK|O_NOCTTY)) < 0) {
if ((errno == ENOENT || errno == ELOOP) &&
S_ISLNK(sb->st_mode)) {
@@ -1200,13 +1206,13 @@ virStorageBackendVolOpenCheckMode(const char *path, struct stat *sb,
return -1;
}
- if (S_ISREG(sb->st_mode))
+ if (S_ISREG(sb->st_mode)) {
mode = VIR_STORAGE_VOL_OPEN_REG;
- else if (S_ISCHR(sb->st_mode))
+ } else if (S_ISCHR(sb->st_mode)) {
mode = VIR_STORAGE_VOL_OPEN_CHAR;
- else if (S_ISBLK(sb->st_mode))
+ } else if (S_ISBLK(sb->st_mode)) {
mode = VIR_STORAGE_VOL_OPEN_BLOCK;
- else if (S_ISDIR(sb->st_mode)) {
+ } else if (S_ISDIR(sb->st_mode)) {
mode = VIR_STORAGE_VOL_OPEN_DIR;
if (STREQ(base, ".") ||
@@ -1215,6 +1221,17 @@ virStorageBackendVolOpenCheckMode(const char *path, struct stat *sb,
VIR_INFO("Skipping special dir '%s'", base);
return -2;
}
+ } else {
+ VIR_WARN("ignoring unexpected type for file '%s'", path);
+ VIR_FORCE_CLOSE(fd);
+ return -2;
+ }
+
+ if (virSetBlocking(fd, true) < 0) {
+ virReportSystemError(errno, _("unable to set blocking mode for '%s'"),
+ path);
+ VIR_FORCE_CLOSE(fd);
+ return -2;
}
if (!(mode & flags)) {
--
1.8.3.1
2
2
[libvirt] [libvirt-python] Call virGetLastError from mod rather than py wrapper
by Doug Goldstein 26 Nov '13
by Doug Goldstein 26 Nov '13
26 Nov '13
All other code always calls the methods from the mod rather than using
the python wrapper so this matches the state of all other callers.
---
libvirt-override.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-override.py b/libvirt-override.py
index ccfec48..87996f8 100644
--- a/libvirt-override.py
+++ b/libvirt-override.py
@@ -20,7 +20,7 @@ class libvirtError(Exception):
# Never call virConnGetLastError().
# virGetLastError() is now thread local
- err = virGetLastError()
+ err = libvirtmod.virGetLastError()
if err is None:
msg = defmsg
else:
--
1.8.3.2
2
1
26 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The method dispatchDomainEventBlockPullCallback which is
used internally to dispatch block pull events to the python
application code was missing the leading '_', to denote that
it was private. All other event callback helpers have a
leading '_'. No application should have been using this so
it is justifiable to rename it.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
libvirt-override-virConnect.py | 2 +-
libvirt-override.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index 4ba3d30..23fadfd 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -113,7 +113,7 @@
authScheme, subject, opaque)
return 0
- def dispatchDomainEventBlockPullCallback(self, dom, path, type, status, cbData):
+ def _dispatchDomainEventBlockPullCallback(self, dom, path, type, status, cbData):
"""Dispatches events to python user domain blockJob event callbacks
"""
try:
diff --git a/libvirt-override.c b/libvirt-override.c
index 4cc64b7..d3802de 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -5998,7 +5998,7 @@ libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSE
/* Call the Callback Dispatcher */
pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"dispatchDomainEventBlockPullCallback",
+ (char*)"_dispatchDomainEventBlockPullCallback",
(char*)"OsiiO",
pyobj_dom, path, type, status, pyobj_cbData);
--
1.8.3.1
2
1
[libvirt] [PATCH python] Don't include virDomainSnapshotRef in python API
by Daniel P. Berrange 26 Nov '13
by Daniel P. Berrange 26 Nov '13
26 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The reference counting API is for internal use only. Attempts
to use it from python application code will cause havoc.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/generator.py b/generator.py
index ea5b8a1..c769ed0 100755
--- a/generator.py
+++ b/generator.py
@@ -517,7 +517,8 @@ skip_function = (
"virNWFilterRef",
"virStoragePoolRef",
"virStorageVolRef",
- 'virStreamRef',
+ "virStreamRef",
+ "virDomainSnapshotRef",
# This functions shouldn't be called via the bindings (and even the docs
# contain an explicit warning to that effect). The equivalent should be
--
1.8.3.1
2
1
[libvirt] [PATCH v2 1/2] LXC: fix the problem that libvirt lxc fail to start on latest kernel
by Gao feng 26 Nov '13
by Gao feng 26 Nov '13
26 Nov '13
After kernel commit 5ff9d8a65ce80efb509ce4e8051394e9ed2cd942
vfs: Lock in place mounts from more privileged users,
unprivileged user has no rights to move the mounts that
inherited from parent mountns. we use this feature to move
the /stateDir/domain-name.{dev, devpts} to the /dev/ and
/dev/pts directroy of container. this commit breaks libvirt lxc.
this patch changes the behavior to bind these mounts when
user namespace is enabled and move these mounts when user
namespace is disabled.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 2bdf957..3d9b491 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -958,6 +958,7 @@ static int lxcContainerMountFSDev(virDomainDefPtr def,
{
int ret = -1;
char *path = NULL;
+ int flags = def->idmap.nuidmap ? MS_BIND : MS_MOVE;
VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir);
@@ -971,9 +972,10 @@ static int lxcContainerMountFSDev(virDomainDefPtr def,
goto cleanup;
}
- VIR_DEBUG("Trying to move %s to /dev", path);
+ VIR_DEBUG("Trying to %s %s to /dev", def->idmap.nuidmap ?
+ "bind" : "move", path);
- if (mount(path, "/dev", NULL, MS_MOVE, NULL) < 0) {
+ if (mount(path, "/dev", NULL, flags, NULL) < 0) {
virReportSystemError(errno,
_("Failed to mount %s on /dev"),
path);
@@ -992,6 +994,7 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
{
int ret;
char *path = NULL;
+ int flags = def->idmap.nuidmap ? MS_BIND : MS_MOVE;
VIR_DEBUG("Mount /dev/pts stateDir=%s", stateDir);
@@ -1007,10 +1010,10 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def,
goto cleanup;
}
- VIR_DEBUG("Trying to move %s to /dev/pts", path);
+ VIR_DEBUG("Trying to %s %s to /dev/pts", def->idmap.nuidmap ?
+ "bind" : "move", path);
- if ((ret = mount(path, "/dev/pts",
- NULL, MS_MOVE, NULL)) < 0) {
+ if ((ret = mount(path, "/dev/pts", NULL, flags, NULL)) < 0) {
virReportSystemError(errno,
_("Failed to mount %s on /dev/pts"),
path);
--
1.8.3.1
2
4
Re: [libvirt] [Qemu-devel] [PATCH] virtio-rng: correct the default limit rate
by Eric Blake 26 Nov '13
by Eric Blake 26 Nov '13
26 Nov '13
[adding libvirt]
On 11/26/2013 06:58 AM, Paolo Bonzini wrote:
> Il 26/11/2013 14:43, Amos Kong ha scritto:
>> /* Set a default rate limit of 2^47 bytes per minute or roughly 2TB/s. If
>> * you have an entropy source capable of generating more entropy than this
>> * and you can pass it through via virtio-rng, then hats off to you. Until
>> * then, this is unlimited for all practical purposes.
>> */
>>
>> But the current rate is (INT64_MAX) bytes per (1 << 16) ms, it's 128,000 TB/s
>
> You are changing:
>
> * max-bytes from 2^63 to 2^47
>
> * period from 65536 to 60000
>
> For a user, changing only period would have no effect, the limit rate
> would remain effectively infinite. Changing max-bytes would give a 7%
> higher rate after your patch.
>
> Not a big deal, and max-bytes is easier to explain after your patch
> (bytes/minute) than before (bytes/65536ms).
>
> Reviewed-by: Paolo Bonzini <pbonzini(a)redhat.com>
>
Hmm. Libvirt is already converting a user's rate of bytes/period into
the qemu parameters, defaulting to 1 second as its default period. Am I
correct that as long as libvirt specified both rate AND period, then
this change has no impact (and that the 7% change occurs if you specify
period while leaving max-bytes alone)? Or is this an ABI change where
libvirt will have to be taught to be smart enough to know whether it is
old qemu or new qemu to adjust how libvirt does its calculations when
converting the user's rate into qemu terms?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
3
3
26 Nov '13
Version 2:
Fixed the string formatting errors in v1.
Version 1:
The patch contains the fix for defect 1009880 reported at redhat bugzilla.
The root cause is, ever since the subcpusets(vcpu,emulator) were introduced, the paren cpuset cannot be modified to remove the nodes that are in use by the subcpusets.
The fix is to break the memory node modification into three steps as to assign new nodes into the parent first. Change the nodes in the child nodes. Then remove the old nodes on the parent node.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 129 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e8bc04d..2435b75 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8171,7 +8171,11 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
}
} else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) {
virBitmapPtr nodeset = NULL;
+ virBitmapPtr old_nodeset = NULL;
+ virBitmapPtr temp_nodeset = NULL;
char *nodeset_str = NULL;
+ char *old_nodeset_str = NULL;
+ char *temp_nodeset_str = NULL;
if (virBitmapParse(params[i].value.s,
0, &nodeset,
@@ -8181,6 +8185,10 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
}
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ size_t j;
+ virCgroupPtr cgroup_vcpu = NULL;
+ virCgroupPtr cgroup_emulator = NULL;
+
if (vm->def->numatune.memory.mode !=
VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -8200,7 +8208,128 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
continue;
}
+ if (virCgroupGetCpusetMems(priv->cgroup, &old_nodeset_str) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to get current system nodeset values"));
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ ret = -1;
+ continue;
+ }
+
+ if (virBitmapParse(old_nodeset_str, 0, &old_nodeset,
+ VIR_DOMAIN_CPUMASK_LEN) < 0) {
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ VIR_FREE(old_nodeset_str);
+ ret = -1;
+ continue;
+ }
+
+ if ((temp_nodeset = virBitmapNewCopy(old_nodeset)) == NULL) {
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ virBitmapFree(old_nodeset);
+ VIR_FREE(old_nodeset_str);
+ ret = -1;
+ continue;
+ }
+ virBitmapFree(old_nodeset);
+ VIR_FREE(old_nodeset_str);
+
+ for (j = 0; j < caps->host.nnumaCell; j++) {
+ bool result;
+ if (virBitmapGetBit(nodeset, j, &result) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to get cpuset bit values"));
+ ret = -1;
+ break;
+ }
+ if (result && (virBitmapSetBit(temp_nodeset, j) < 0)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to set temporary cpuset bit values"));
+ ret = -1;
+ break;
+ }
+ }
+
+ if (ret) {
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ virBitmapFree(temp_nodeset);
+ continue;
+ }
+
+ if (!(temp_nodeset_str = virBitmapFormat(temp_nodeset))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to format nodeset"));
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ virBitmapFree(temp_nodeset);
+ ret = -1;
+ continue;
+ }
+
+ if (virCgroupSetCpusetMems(priv->cgroup, temp_nodeset_str) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to set cpuset values"));
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ virBitmapFree(temp_nodeset);
+ VIR_FREE(temp_nodeset_str);
+ ret = -1;
+ continue;
+ }
+
+ virBitmapFree(temp_nodeset);
+ VIR_FREE(temp_nodeset_str);
+
+ for (j = 0; j < priv->nvcpupids; j++) {
+ if (virCgroupNewVcpu(priv->cgroup, j, false, &cgroup_vcpu) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to get cpuset values for vcpu%zu"), j);
+ ret = -1;
+ break;
+ }
+ if (virCgroupSetCpusetMems(cgroup_vcpu, nodeset_str) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to set cpuset values for vcpu%zu"), j);
+ virCgroupFree(&cgroup_vcpu);
+ ret = -1;
+ break;
+ }
+ virCgroupFree(&cgroup_vcpu);
+ }
+
+ if (ret) {
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ continue;
+ }
+
+ if (virCgroupNewEmulator(priv->cgroup, false, &cgroup_emulator) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to get cpuset values for emulator"));
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ ret = -1;
+ continue;
+ }
+
+ if (virCgroupSetCpusetMems(cgroup_emulator, nodeset_str) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to set cpuset values for emulator"));
+ virBitmapFree(nodeset);
+ VIR_FREE(nodeset_str);
+ virCgroupFree(&cgroup_emulator);
+ ret = -1;
+ continue;
+ }
+ virCgroupFree(&cgroup_emulator);
+
if (virCgroupSetCpusetMems(priv->cgroup, nodeset_str) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to set cpuset"));
virBitmapFree(nodeset);
VIR_FREE(nodeset_str);
ret = -1;
3
2
26 Nov '13
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
setup.py | 0
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 setup.py
diff --git a/setup.py b/setup.py
old mode 100644
new mode 100755
--
1.8.4.3
2
2
[[ TO libvir-list ]]
Hi, Daniel,
I'm going to share the thread to public list for further discussion.
Hope you
don't mind.
On 26/11/13 02:37, Daniel Erez wrote:
> Hi Osier,
>
> It seems there's a limitation in libvirt that allows up to six disks in a
> virtio-scsi controller. I.e. when sending more than six disks, libvirt
> automatically creates a new controller but of type virtual LSI Logic SCSI.
> Is this behavior a known issue?
For narrow SCSI bus, we allow 6 disks indeed.
For wide SCSI bus, we allow 15 disks (not including the controller
itself on unit 7).
I'm doubting if we have problem on detecting if it supports wide SCSI
bus though, since as far as I see from the user cases, it's always
narrow SCSI bus.
> Shouldn't libvirt allow up to 256 disks
> per controller or at least create a new controller of type virtio-scsi when needed?
The controller model for virtio-scsi controller is lsilogic, which we can't
change simply, since it might affect the existing guests.
There was the similar discussion in libvir-list before [1].
But auto generation for controller is quite old, which I'm also not quite
clear about. I'd like see another discussion to make it more clear whether
we should do some work for upper layer app (e.g. oVirt).
Basicly two points:
* Should we do some changes on the maximum units for a SCSI controller,
I.e. Should 7 (narrow bus) 16 (wide bus) be changed to other numbers?
I'm afraid the changes could affect existing guests though.
* Do we really want to put the burden on users, I.E, let them create the
controller explicitly. For use cases like one wants to add many
disks for
a guest, they need to know whether it's narrow SCSI bus or wide SCSI
bus first (which we don't expose outside), and then do the calculation
to know when to create a new SCSI controller.
@Daniel, am I correct on your problems? Please comments if it doesn't
cover all your thoughts.
[1] http://www.redhat.com/archives/libvir-list/2012-November/msg00537.html
Regards,
Osier
>
> [the issue as been discussed as part of: http://gerrit.ovirt.org/#/c/20630]
>
> Thanks,
> Daniel
>
>
> ----- Original Message -----
>> From: "Dave Allan" <dallan(a)redhat.com>
>> To: "Daniel Erez" <derez(a)redhat.com>
>> Cc: "Ayal Baron" <abaron(a)redhat.com>, "Osier Yang" <jyang(a)redhat.com>, "John Ferlan" <jferlan(a)redhat.com>
>> Sent: Monday, November 25, 2013 8:19:42 PM
>> Subject: Re: VirtIO-SCSI disks limitation
>>
>> Hi Daniel,
>>
>> Talk to Osier Yang and John Ferlan (cc'd).
>>
>> Dave
>>
>>
>> On Mon, Nov 25, 2013 at 12:48:45PM -0500, Daniel Erez wrote:
>>> Hi Dave,
>>>
>>> I'm an engineer at oVirt team and I'm working on VirtIO-SCSI integration.
>>> I would appreciate it if you could refer me to a point of contact at
>>> libvirt.
>>> In specific, I need to know if there's any hardcoded limitation for the
>>> number of disks per VirtIO-SCSI controller.
>>>
>>> Best Regards,
>>> Daniel
3
2
[libvirt] [PATCH v3] sasl: Fix authentication when using PLAIN mechanism
by Christophe Fergeau 26 Nov '13
by Christophe Fergeau 26 Nov '13
26 Nov '13
With some authentication mechanism (PLAIN for example), sasl_client_start()
can return SASL_OK, which translates to virNetSASLSessionClientStart()
returning VIR_NET_SASL_COMPLETE.
cyrus-sasl documentation is a bit vague as to what to do in such situation,
but upstream clarified this a bit in
http://asg.andrew.cmu.edu/archive/message.php?mailbox=archive.cyrus-sasl&ms…
When we got VIR_NET_SASL_COMPLETE after virNetSASLSessionClientStart() and
if the remote also tells us that authentication is complete, then we should
end the authentication procedure rather than forcing a call to
virNetSASLSessionClientStep(). Without this patch, when trying to use SASL
PLAIN, I get:
error :authentication failed : Failed to step SASL negotiation: -1
(SASL(-1): generic failure: Unable to find a callback: 32775)
This patch is based on a spice-gtk patch by Dietmar Maurer.
---
Change since v2:
- move the added test out of the for(;;) loop
src/remote/remote_driver.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index df7558b..f9fd915 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4121,10 +4121,18 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv,
VIR_DEBUG("Client step result complete: %d. Data %zu bytes %p",
complete, serverinlen, serverin);
+ /* Previous server call showed completion & sasl_client_start() told us
+ * we are locally complete too */
+ if (complete && err == VIR_NET_SASL_COMPLETE)
+ goto done;
+
/* Loop-the-loop...
- * Even if the server has completed, the client must *always* do at least one step
- * in this loop to verify the server isn't lying about something. Mutual auth */
+ * Even if the server has completed, the client must loop until sasl_client_start() or
+ * sasl_client_step() return SASL_OK to verify the server isn't lying
+ * about something. Mutual auth
+ * */
for (;;) {
+
restep:
if ((err = virNetSASLSessionClientStep(sasl,
serverin,
@@ -4195,6 +4203,7 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv,
priv->is_secure = 1;
}
+done:
VIR_DEBUG("SASL authentication complete");
virNetClientSetSASLSession(priv->client, sasl);
ret = 0;
--
1.8.4.2
2
2
Hey,
While running virsh through valgrind for some SASL tests, I triggered some
leaks/invalid reads, this patch series fixes these.
Christophe
3
7
2
1
26 Nov '13
These patches implements a separate module for hostdev passthrough so that it
could be shared by different drivers and can maintain a global state of a host
device. Plus, add passthrough to libxl driver, and change qemu driver and lxc
driver to use hostdev common library instead of their own hostdev APIs.
---
Changes to v5:
* For upgrade concern, check netconfig file in old stateDir xxx/qemu/ if it's
not found in new location xxx/hostdevmgr/, since if there is existing VM,
then after upgrade, NetConfigRestore should find the netconfig file from old
stateDir place.
* Rebase to new qemu_hostdev changes, e.g, prefer VFIO, and add CheckSupport.
* Put into separate patches for adding a pci backend type for xen and other
hostdev common library stuff
* Other fixes according to Daniel's comments.
v5 is here:
http://www.redhat.com/archives/libvir-list/2013-September/msg00745.html
Chunyan Liu (5):
Add a hostdev PCI backend type
Add hostdev passthrough common library
Add pci passthrough to libxl driver
Change qemu driver to use hostdev common library
Change lxc driver to use hostdev common library
docs/schemas/domaincommon.rng | 1 +
po/POTFILES.in | 3 +-
src/Makefile.am | 3 +-
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 20 +
src/libxl/libxl_conf.c | 63 ++
src/libxl/libxl_conf.h | 4 +
src/libxl/libxl_domain.c | 9 +
src/libxl/libxl_driver.c | 448 +++++++++++-
src/lxc/lxc_conf.h | 4 -
src/lxc/lxc_driver.c | 47 +-
src/lxc/lxc_hostdev.c | 413 ----------
src/lxc/lxc_hostdev.h | 43 --
src/lxc/lxc_process.c | 24 +-
src/qemu/qemu_command.c | 4 +-
src/qemu/qemu_conf.h | 9 +-
src/qemu/qemu_domain.c | 22 +
src/qemu/qemu_driver.c | 77 +--
src/qemu/qemu_hostdev.c | 1453 -----------------------------------
src/qemu/qemu_hostdev.h | 74 --
src/qemu/qemu_hotplug.c | 133 ++--
src/qemu/qemu_process.c | 40 +-
src/util/virhostdev.c | 1671 +++++++++++++++++++++++++++++++++++++++++
src/util/virhostdev.h | 129 ++++
src/util/virpci.c | 30 +-
src/util/virpci.h | 9 +-
src/util/virscsi.c | 28 +-
src/util/virscsi.h | 8 +-
src/util/virusb.c | 29 +-
src/util/virusb.h | 8 +-
31 files changed, 2607 insertions(+), 2203 deletions(-)
delete mode 100644 src/lxc/lxc_hostdev.c
delete mode 100644 src/lxc/lxc_hostdev.h
delete mode 100644 src/qemu/qemu_hostdev.c
delete mode 100644 src/qemu/qemu_hostdev.h
create mode 100644 src/util/virhostdev.c
create mode 100644 src/util/virhostdev.h
4
14
Hi All,
Will some one explain how is this tls libvirt server is implemented. For my
testing purpose I need to implement the similar TLS server in Java or
Python and this server is capable to receive all libvirt calls like
getCapabilities, hostname etc and return response as I'm configured.
Basically I need to simulate the libvirt TLS server. I tried creating many
TLS server but none of the my TLS server implemenation is capable to do
proper handshake with python libvirt client and do successful calls. Any
ideas or help will be appreciable.
Thanks In Advance,
Arun V
3
2
v3: https://www.redhat.com/archives/libvir-list/2013-November/msg00348.html
Depends on:
https://www.redhat.com/archives/libvir-list/2013-November/msg00955.html
Changes since then, addressing review feedback:
- rebase to other improvements in the meantime
- New patches 4-7
- pool changed to require <name>volume</name> to have no slash,
with subdirectory within a volume selected by <dir path=.../>
which must begin with slash
- documentation improved to match actual testing
- directories, symlinks are handled
- volume owner and timestamps are handled
- volume xml tests added, with several bugs in earlier version
fixed along the way
- compared gluster pool with a netfs pool to ensure both can
see the same level of detail from the same gluster storage
If you think it will help review, ask me to provide an interdiff
from v3 (although I have not done it yet).
Eric Blake (8):
storage: initial support for linking with libgfapi
storage: document gluster pool
storage: implement rudimentary glusterfs pool refresh
storage: add network-dir as new storage volume type
storage: improve directory support in gluster pool
storage: improve allocation stats reported on gluster files
storage: improve handling of symlinks in gluster
storage: probe qcow2 volumes in gluster pool
configure.ac | 21 ++
docs/formatstorage.html.in | 15 +-
docs/schemas/storagepool.rng | 26 +-
docs/storage.html.in | 91 +++++-
include/libvirt/libvirt.h.in | 2 +
libvirt.spec.in | 15 +
m4/virt-gluster.m4 | 28 ++
po/POTFILES.in | 1 +
src/Makefile.am | 10 +
src/conf/storage_conf.c | 28 +-
src/conf/storage_conf.h | 3 +-
src/qemu/qemu_command.c | 6 +-
src/qemu/qemu_conf.c | 4 +-
src/storage/storage_backend.c | 14 +-
src/storage/storage_backend.h | 6 +-
src/storage/storage_backend_fs.c | 5 +-
src/storage/storage_backend_gluster.c | 381 +++++++++++++++++++++++
src/storage/storage_backend_gluster.h | 29 ++
tests/storagepoolxml2xmlin/pool-gluster-sub.xml | 9 +
tests/storagepoolxml2xmlin/pool-gluster.xml | 8 +
tests/storagepoolxml2xmlout/pool-gluster-sub.xml | 12 +
tests/storagepoolxml2xmlout/pool-gluster.xml | 12 +
tests/storagepoolxml2xmltest.c | 2 +
tests/storagevolxml2xmlin/vol-gluster-dir.xml | 13 +
tests/storagevolxml2xmlout/vol-gluster-dir.xml | 18 ++
tests/storagevolxml2xmltest.c | 1 +
tools/virsh-volume.c | 5 +-
27 files changed, 740 insertions(+), 25 deletions(-)
create mode 100644 m4/virt-gluster.m4
create mode 100644 src/storage/storage_backend_gluster.c
create mode 100644 src/storage/storage_backend_gluster.h
create mode 100644 tests/storagepoolxml2xmlin/pool-gluster-sub.xml
create mode 100644 tests/storagepoolxml2xmlin/pool-gluster.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-gluster-sub.xml
create mode 100644 tests/storagepoolxml2xmlout/pool-gluster.xml
create mode 100644 tests/storagevolxml2xmlin/vol-gluster-dir.xml
create mode 100644 tests/storagevolxml2xmlout/vol-gluster-dir.xml
--
1.8.3.1
5
29
Add:
* repos/domain/blkstatsflags.py
* repos/domain/block_iotune.py
* repos/domain/block_peek.py
* repos/domain/block_resize.py
* repos/domain/domain_blkio.py
* cases/basic_blockjob.conf
Modify: replace virsh commands to calling api in test function
* repos/domain/blkstats.py
* repos/domain/domain_blkinfo.py
---
cases/basic_blockjob.conf | 87 ++++++++++++++++++++++
repos/domain/blkstats.py | 2 -
repos/domain/blkstatsflags.py | 63 ++++++++++++++++
repos/domain/block_iotune.py | 118 +++++++++++++++++++++++++++++
repos/domain/block_peek.py | 69 +++++++++++++++++
repos/domain/block_resize.py | 88 ++++++++++++++++++++++
repos/domain/domain_blkinfo.py | 87 ++++++++++++----------
repos/domain/domain_blkio.py | 165 +++++++++++++++++++++++++++++++++++++++++
8 files changed, 639 insertions(+), 40 deletions(-)
create mode 100644 cases/basic_blockjob.conf
create mode 100644 repos/domain/blkstatsflags.py
create mode 100644 repos/domain/block_iotune.py
create mode 100644 repos/domain/block_peek.py
create mode 100644 repos/domain/block_resize.py
create mode 100644 repos/domain/domain_blkio.py
diff --git a/cases/basic_blockjob.conf b/cases/basic_blockjob.conf
new file mode 100644
index 0000000..65af2c3
--- /dev/null
+++ b/cases/basic_blockjob.conf
@@ -0,0 +1,87 @@
+domain:install_linux_cdrom
+ guestname
+ $defaultname
+ guestos
+ $defaultos
+ guestarch
+ $defaultarch
+ vcpu
+ $defaultvcpu
+ memory
+ $defaultmem
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+ macaddr
+ 54:52:00:45:c3:8a
+
+domain:install_linux_check
+ guestname
+ $defaultname
+ virt_type
+ $defaulthv
+ hddriver
+ $defaulthd
+ nicdriver
+ $defaultnic
+
+domain:block_iotune
+ guestname
+ $defaultname
+ bytes_sec
+ 100000
+ iops_sec
+ 0
+
+domain:block_iotune
+ guestname
+ $defaultname
+ bytes_sec
+ 0
+ iops_sec
+ 1000
+
+domain:block_peek
+ guestname
+ $defaultname
+
+domain:block_peek
+ guestname
+ $defaultname
+
+domain:block_resize
+ guestname
+ $defaultname
+ diskpath
+ /var/lib/libvirt/images/libvirt-test-api
+ disksize
+ 1G
+
+domain:blkstats
+ guestname
+ $defaultname
+
+domain:blkstatsflags
+ guestname
+ $defaultname
+ flags
+ 0
+
+domain:domain_blkinfo
+ guestname
+ $defaultname
+ blockdev
+ /var/lib/libvirt/images/libvirt-test-api
+
+domain:domain_blkio
+ guestname
+ $defaultname
+ weight
+ 500
+
+domain:undefine
+ guestname
+ $defaultname
+
+options cleanup=enable
diff --git a/repos/domain/blkstats.py b/repos/domain/blkstats.py
index 0254922..27c2a46 100644
--- a/repos/domain/blkstats.py
+++ b/repos/domain/blkstats.py
@@ -1,8 +1,6 @@
#!/usr/bin/evn python
# To test domain block device statistics
-import os
-import sys
import time
import libxml2
diff --git a/repos/domain/blkstatsflags.py b/repos/domain/blkstatsflags.py
new file mode 100644
index 0000000..4c84a18
--- /dev/null
+++ b/repos/domain/blkstatsflags.py
@@ -0,0 +1,63 @@
+#!/usr/bin/evn python
+# To test domain block device statistics with flags
+
+import time
+import libxml2
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'flags')
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def check_blkstats():
+ """Check block device statistic result"""
+ pass
+
+def blkstatsflags(params):
+ """Domain block device statistic"""
+ logger = params['logger']
+ guestname = params['guestname']
+ flags = int(params['flags'])
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ devs = cont.xpathEval("/domain/devices/disk/target/@dev")
+
+ for dev in devs:
+ path = dev.content
+ blkstats = domobj.blockStatsFlags(path, flags)
+ # check_blkstats()
+ logger.debug(blkstats)
+ for entry in blkstats.keys():
+ logger.info("%s %s %s" %(path, entry, blkstats[entry]))
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
diff --git a/repos/domain/block_iotune.py b/repos/domain/block_iotune.py
new file mode 100644
index 0000000..f92eaf6
--- /dev/null
+++ b/repos/domain/block_iotune.py
@@ -0,0 +1,118 @@
+#!/usr/bin/evn python
+# To test domain block device iotune
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname', 'bytes_sec', 'iops_sec')
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def prepare_block_iotune(param, wbs, rbs, tbs, wis, ris, tis, logger):
+ """prepare the block iotune parameter
+ """
+ logger.info("write_bytes_sec : %s" % wbs)
+ param['write_bytes_sec'] = wbs
+ logger.info("read_bytes_sec : %s" % rbs)
+ param['read_bytes_sec'] = rbs
+ logger.info("total_bytes_sec : %s" % tbs)
+ param['total_bytes_sec'] = tbs
+ logger.info("write_iops_sec : %s" % wis)
+ param['write_iops_sec'] = wis
+ logger.info("read_iops_sec : %s" % ris)
+ param['read_iops_sec'] = ris
+ logger.info("total_iops_sec : %s\n" % tis)
+ param['total_iops_sec'] = tis
+ return 0
+
+def check_iotune(expected_param, result_param):
+ """check block iotune configuration
+ """
+ for k in expected_param.keys():
+ if expected_param[k] != result_param[k]:
+ return 1
+ return 0
+
+def block_iotune(params):
+ """Domain block device iotune"""
+ logger = params['logger']
+ guestname = params['guestname']
+ bytes_sec = int(params['bytes_sec'])
+ iops_sec = int(params['iops_sec'])
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/target/@dev")
+ vdev = vdevs[0].content
+
+ iotune_para = {'write_bytes_sec': 0L,
+ 'total_iops_sec': 0L,
+ 'read_iops_sec': 0L,
+ 'read_bytes_sec': 0L,
+ 'write_iops_sec': 0L,
+ 'total_bytes_sec': 0L
+ }
+
+ logger.info("prepare block iotune:")
+ prepare_block_iotune(iotune_para, bytes_sec, bytes_sec, 0,
+ iops_sec, iops_sec, 0, logger)
+
+ logger.info("start to set block iotune:")
+ domobj.setBlockIoTune(vdev, iotune_para, flag)
+
+ res = domobj.blockIoTune(vdev, flag)
+ ret = check_iotune(iotune_para, res)
+ if not ret:
+ logger.info("set pass")
+ else:
+ logger.error("fails to set")
+ return 1
+
+ logger.info("prepare block iotune:")
+ prepare_block_iotune(iotune_para, 0, 0, bytes_sec,
+ 0, 0, iops_sec, logger)
+
+ logger.info("start to set block iotune:")
+ domobj.setBlockIoTune(vdev, iotune_para, flag)
+
+ res = domobj.blockIoTune(vdev, flag)
+ ret = check_iotune(iotune_para, res)
+ if not ret:
+ logger.info("set pass")
+ else:
+ logger.error("fails to set")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
\ No newline at end of file
diff --git a/repos/domain/block_peek.py b/repos/domain/block_peek.py
new file mode 100644
index 0000000..f159f48
--- /dev/null
+++ b/repos/domain/block_peek.py
@@ -0,0 +1,69 @@
+#!/usr/bin/evn python
+# To test domain block device peek
+
+import time
+import libxml2
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+
+required_params = ('guestname',)
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def block_peek(params):
+ """domain block peek test function
+ """
+ logger = params['logger']
+ guestname = params['guestname']
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ vdevs = cont.xpathEval("/domain/devices/disk/target/@dev")
+ vdev = vdevs[0].content
+
+ logger.info("start to test block_peek.")
+ logger.info("get the MBR's last byte of domain %s %s is:"
+ % (guestname, vdev))
+
+ last_byte = domobj.blockPeek(vdev, 511, 1, flag)
+ logger.info(last_byte)
+
+ # compare with '\xaa'
+ if last_byte == '\xaa':
+ logger.info("Pass: the last byte is \\xaa")
+ else:
+ logger.error("Failed: the last byte is not \\xaa")
+ logger.error("please make sure the guest is bootable")
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
\ No newline at end of file
diff --git a/repos/domain/block_resize.py b/repos/domain/block_resize.py
new file mode 100644
index 0000000..1dc4b45
--- /dev/null
+++ b/repos/domain/block_resize.py
@@ -0,0 +1,88 @@
+#!/usr/bin/evn python
+# To test domain block device resize
+
+import time
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'diskpath', 'disksize',)
+optional_params = {}
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def block_resize(params):
+ """domain block resize test function
+ """
+ logger = params['logger']
+ guestname = params['guestname']
+ diskpath = params['diskpath']
+ disksize = params['disksize']
+ flag = 0
+
+ out = utils.get_capacity_suffix_size(disksize)
+ if len(out) == 0:
+ logger.error("disksize parse error: \'%s\'" % disksize)
+ logger.error("disksize should be a number with capacity suffix")
+ return 1
+
+ if out['suffix'] == 'K':
+ flag = 0
+ disksize = long(out['capacity'])
+ elif out['suffix'] == 'B':
+ flag = 1
+ disksize = long(out['capacity_byte'])
+ elif out['suffix'] == 'M':
+ flag = 0
+ disksize = long(out['capacity']) * 1024
+ elif out['suffix'] == 'G':
+ flag = 0
+ disksize = long(out['capacity']) * 1024 * 1024
+ else:
+ logger.error("disksize parse error: with a unsupported suffix \'%s\'"
+ % out['suffix'])
+ logger.error("the available disksize suffix of block_resize is: ")
+ logger.error("B, K, M, G, T")
+ return 1
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ try:
+ logger.info("resize domain disk to %s" % disksize)
+ domobj.blockResize(diskpath, disksize, flag)
+
+ # Currently, the units of disksize which get from blockInfo is byte.
+ block_info = domobj.blockInfo(diskpath, 0)
+
+ if block_info[0] == disksize * (1 + 1023 * (1 - flag)):
+ logger.info("domain disk resize success")
+ else:
+ logger.error("error: domain disk change into %s" % block_info[0])
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
+
\ No newline at end of file
diff --git a/repos/domain/domain_blkinfo.py b/repos/domain/domain_blkinfo.py
index b6051aa..4978c32 100644
--- a/repos/domain/domain_blkinfo.py
+++ b/repos/domain/domain_blkinfo.py
@@ -1,9 +1,6 @@
#!/usr/bin/env python
-# To test "virsh domblkinfo" command
+# To test domain's blockkinfo API
-import os
-import sys
-import re
import commands
import libvirt
@@ -11,10 +8,8 @@ from libvirt import libvirtError
from src import sharedmod
-GET_DOMBLKINFO_MAC = "virsh domblkinfo %s %s | awk '{print $2}'"
GET_CAPACITY = "du -b %s | awk '{print $1}'"
GET_PHYSICAL_K = " du -B K %s | awk '{print $1}'"
-VIRSH_DOMBLKINFO = "virsh domblkinfo %s %s"
required_params = ('guestname', 'blockdev',)
optional_params = {}
@@ -32,8 +27,8 @@ def check_domain_exists(conn, guestname, logger):
""" check if the domain exists, may or may not be active """
guest_names = []
ids = conn.listDomainsID()
- for id in ids:
- obj = conn.lookupByID(id)
+ for domain_id in ids:
+ obj = conn.lookupByID(domain_id)
guest_names.append(obj.name())
guest_names += conn.listDefinedDomains()
@@ -43,18 +38,28 @@ def check_domain_exists(conn, guestname, logger):
return False
else:
return True
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
def check_block_data(blockdev, blkdata, logger):
""" check data about capacity,allocation,physical """
status, apparent_size = get_output(GET_CAPACITY % blockdev, logger)
if not status:
- if apparent_size == blkdata[0]:
- logger.info("the capacity of '%s' is %s, checking succeeded" % \
- (blockdev, apparent_size))
+ if apparent_size == str(blkdata[0]):
+ logger.info("the capacity of '%s' is %s, checking succeeded"
+ % (blockdev, apparent_size))
else:
- logger.error("apparent-size from 'du' is %s, \n\
- but from 'domblkinfo' is %s, checking failed" % \
- (apparent_size, blkdata[0]))
+ logger.error("apparent-size from 'du' is %s" % apparent_size)
+ logger.error("but from 'domain blockinfo' is %d, checking failed"
+ % blkdata[0])
return 1
else:
return 1
@@ -64,14 +69,15 @@ def check_block_data(blockdev, blkdata, logger):
block_size_b = int(block_size_k[:-1]) * 1024
# Temporarily, we only test the default case, assuming
# Allocation value is equal to Physical value
- if str(block_size_b) == blkdata[1] and str(block_size_b) == blkdata[2]:
- logger.info("the block size of '%s' is %s, same with \n\
- Allocation and Physical value, checking succeeded" % \
- (blockdev, block_size_b))
+ if block_size_b == blkdata[1] and block_size_b == blkdata[2]:
+ logger.info("the block size of '%s' is %s"
+ % (blockdev, block_size_b))
+ logger.info("Allocation and Physical value's checking succeeded")
else:
- logger.error("the block size from 'du' is %s, \n\
- the Allocation value is %s, Physical value is %s, \n\
- checking failed" % (block_size_b, blkdata[1], blkdata[2]))
+ logger.error("the block size from 'du' is %d" % block_size_b)
+ logger.error("the Allocation value is %d, Physical value is %d"
+ % (blkdata[1], blkdata[2]))
+ logger.error("checking failed")
return 1
return 0
@@ -79,7 +85,7 @@ def check_block_data(blockdev, blkdata, logger):
def domain_blkinfo(params):
""" using du command to check the data
- in the output of virsh domblkinfo
+ in the output of API blockinfo
"""
logger = params['logger']
guestname = params.get('guestname')
@@ -93,24 +99,29 @@ def domain_blkinfo(params):
if not check_domain_exists(conn, guestname, logger):
logger.error("need a defined guest")
return 1
-
- logger.info("the output of virsh domblkinfo is:")
- status, output = get_output(VIRSH_DOMBLKINFO % (guestname, blockdev), logger)
- if not status:
- logger.info("\n" + output)
- else:
+
+ domobj = conn.lookupByName(guestname)
+
+ if not check_guest_status(domobj):
+ logger.error("guest is not started.")
return 1
-
- status, data_str = get_output(GET_DOMBLKINFO_MAC % (guestname, blockdev), logger)
- if not status:
- blkdata = data_str.rstrip().split('\n')
- logger.info("capacity,allocation,physical list: %s" % blkdata)
- else:
+
+ try:
+ logger.info("the output of domain blockinfo is:")
+ block_info = domobj.blockInfo(blockdev, 0)
+ logger.info("Capacity : %d " % block_info[0])
+ logger.info("Allocation: %d " % block_info[1])
+ logger.info("Physical : %d " % block_info[2])
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
return 1
-
- if check_block_data(blockdev, blkdata, logger):
- logger.error("checking domblkinfo data FAILED")
+
+ if check_block_data(blockdev, block_info, logger):
+ logger.error("checking domain blockinfo data FAILED")
return 1
else:
- logger.info("checking domblkinfo data SUCCEEDED")
+ logger.info("checking domain blockinfo data SUCCEEDED")
+
return 0
diff --git a/repos/domain/domain_blkio.py b/repos/domain/domain_blkio.py
new file mode 100644
index 0000000..2603113
--- /dev/null
+++ b/repos/domain/domain_blkio.py
@@ -0,0 +1,165 @@
+#!/usr/bin/evn python
+# To test domain blkio parameters
+
+import os
+import time
+import libxml2
+import libvirt
+import commands
+from libvirt import libvirtError
+
+from src import sharedmod
+
+CGROUP_PATH = "/cgroup"
+BLKIO_PATH1 = "%s/blkio/libvirt/qemu/%s"
+BLKIO_PATH2 = "/sys/fs%s/blkio/machine/%s.libvirt-qemu"
+GET_PARTITION = "df -P %s | tail -1 | awk {'print $1'}"
+
+required_params = ('guestname', 'weight',)
+optional_params = {}
+
+def get_output(command, logger):
+ """execute shell command
+ """
+ status, ret = commands.getstatusoutput(command)
+ if status:
+ logger.error("executing "+ "\"" + command + "\"" + " failed")
+ logger.error(ret)
+ return status, ret
+
+def get_device(domobj, logger):
+ """get the disk device which domain image stored in
+ """
+ xml = domobj.XMLDesc(0)
+ doc = libxml2.parseDoc(xml)
+ cont = doc.xpathNewContext()
+ devs = cont.xpathEval("/domain/devices/disk/source/@file")
+ image_file = devs[0].content
+
+ status, output = get_output(GET_PARTITION % image_file, logger)
+ if not status:
+ return output[:-1]
+ else:
+ logger.error("get device error: ")
+ logger.error(GET_PARTITION % image_file)
+ return ""
+
+def check_blkio_paras(domain_blkio_path, domainname, blkio_paras, logger):
+ """check blkio parameters according to cgroup filesystem
+ """
+ logger.info("checking blkio parameters from cgroup")
+ if 'weight' in blkio_paras:
+ expected_weight = blkio_paras['weight']
+ status, output = get_output("cat %s/blkio.weight"
+ % domain_blkio_path, logger)
+ if not status:
+ logger.info("%s/blkio.weight is \"%s\""
+ % (domain_blkio_path, output))
+ else:
+ return 1
+
+ if int(output) == expected_weight:
+ logger.info("the weight matches with cgroup blkio.weight")
+ return 0
+ else:
+ logger.error("the weight mismatches with cgroup blkio.weight")
+ return 1
+
+ if 'device_weight' in blkio_paras:
+ expected_device_weight = blkio_paras['device_weight']
+ status, output = get_output("cat %s/blkio.weight_device"
+ % domain_blkio_path, logger)
+ if not status:
+ logger.info("%s/blkio.weight_device is \"%s\""
+ % (domain_blkio_path, output))
+ else:
+ return 1
+
+ if output.split(' ')[1] == expected_device_weight.split(',')[1]:
+ logger.info("the device_weight matches with cgroup \
+ blkio.weight_device")
+ return 0
+ else:
+ logger.error("the device_weight mismatches with cgroup \
+ blkio.weight_device")
+ return 1
+
+ return 0
+
+def check_guest_status(domobj):
+ """Check guest current status"""
+ state = domobj.info()[0]
+ if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+ state == libvirt.VIR_DOMAIN_SHUTDOWN:
+ # add check function
+ return False
+ else:
+ return True
+
+def domain_blkio(params):
+ """domain blkio parameters test function"""
+ logger = params['logger']
+ guestname = params['guestname']
+ expected_weight = params['weight']
+ flag = 0
+
+ conn = sharedmod.libvirtobj['conn']
+
+ domobj = conn.lookupByName(guestname)
+
+ # Check domain block status
+ if check_guest_status(domobj):
+ pass
+ else:
+ domobj.create()
+ time.sleep(90)
+
+ if os.path.exists(CGROUP_PATH):
+ blkio_path = BLKIO_PATH1 % (CGROUP_PATH, guestname)
+ else:
+ blkio_path = BLKIO_PATH2 % (CGROUP_PATH, guestname)
+
+
+ try:
+ blkio_paras = domobj.blkioParameters(flag)
+
+
+ logger.info("the blkio weight of %s is: %d"
+ % (guestname, blkio_paras['weight']))
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ logger.info("start to set param weight to %s" % expected_weight)
+ blkio_paras = {'weight':int(expected_weight)}
+ status = domobj.setBlkioParameters(blkio_paras, flag)
+ if status != 0:
+ return 1
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ device = get_device(domobj, logger)
+ device_weight = "%s,%s" % (device, expected_weight)
+ logger.info("start to set param device_weight to %s"
+ % device_weight)
+ blkio_paras = {'device_weight':device_weight}
+ status = domobj.setBlkioParameters(blkio_paras, flag)
+ if status != 0:
+ return 1
+
+ status = check_blkio_paras(blkio_path, guestname, blkio_paras,
+ logger)
+ if status != 0:
+ return 1
+
+ except libvirtError, e:
+ logger.error("API error message: %s, error code is %s"
+ % (e.message, e.get_error_code()))
+ return 1
+
+ return 0
--
1.8.3.1
2
1
25 Nov '13
This series has to be applied on top of the refactoring series sent earlier today.
First 3 patches are additional fixes that should be good to be commited. The rest is work
in progress state to gather possible comments.
Peter Krempa (6):
qemu: snapshot: Touch up error message
qemu: snapshot: Add functions similar to disk source pool translation
qemu: snapshots: Declare supported and unsupported snapshot configs
RFC: snapshot: Add support for specifying snapshot disk backing type
RFC: conf: snapshot: Parse more snapshot information
RFC: qemu: snapshot: Add support for external active snapshots on
gluster
src/conf/snapshot_conf.c | 21 ++-
src/conf/snapshot_conf.h | 15 +-
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_command.h | 9 +
src/qemu/qemu_conf.c | 23 +++
src/qemu/qemu_conf.h | 6 +
src/qemu/qemu_driver.c | 426 ++++++++++++++++++++++++++++++++++++++++-------
7 files changed, 434 insertions(+), 68 deletions(-)
--
1.8.4.3
1
6
[libvirt] [PATCH 00/22] Misc refactors and cleanups leading to gluster snapshot support
by Peter Krempa 25 Nov '13
by Peter Krempa 25 Nov '13
25 Nov '13
Peter Krempa (22):
conf: Implement virStorageVolType enum helper functions
test: Implement fake storage pool driver in qemuxml2argv test
qemuxml2argv: Add test to verify correct usage of disk type="volume"
qemuxml2argv: Add test for disk type='volume' with iSCSI pools
qemu: Refactor qemuTranslatePool source
qemu: Split out formatting of network disk source URI
qemu: Simplify call pattern of qemuBuildDriveURIString
qemu: Use qemuBuildNetworkDriveURI to handle http/ftp and friends
qemu: Migrate sheepdog source generation into common function
qemu: Split out NBD command generation
qemu: Unify formatting of RBD sources
qemu: Refactor disk source string formatting
conf: Support disk source formatting without needing a
virDomainDiskDefPtr
conf: Clean up virDomainDiskSourceDefFormatInternal
conf: Split out seclabel formating code for disk source
conf: Export disk source formatter and parser
snapshot: conf: Use common parsing and formatting functions for source
snapshot: conf: Fix NULL dereference when <driver> element is empty
conf: Add functions to copy and free network disk source definitions
qemu: snapshot: Detect internal snapshots also for sheepdog and RBD
conf: Add helper do clear disk source authentication struct
qemu: Clear old translated pool source
src/conf/domain_conf.c | 261 ++++++---
src/conf/domain_conf.h | 25 +
src/conf/snapshot_conf.c | 56 +-
src/conf/snapshot_conf.h | 1 +
src/conf/storage_conf.c | 4 +
src/conf/storage_conf.h | 2 +
src/libvirt_private.syms | 6 +
src/qemu/qemu_command.c | 650 +++++++++++----------
src/qemu/qemu_command.h | 6 +
src/qemu/qemu_conf.c | 129 ++--
src/qemu/qemu_conf.h | 2 +
src/qemu/qemu_driver.c | 3 +-
.../qemuxml2argv-disk-source-pool-mode.args | 10 +
.../qemuxml2argv-disk-source-pool-mode.xml | 4 +-
.../qemuxml2argv-disk-source-pool.args | 8 +
.../qemuxml2argv-disk-source-pool.xml | 2 +-
tests/qemuxml2argvtest.c | 166 ++++++
17 files changed, 874 insertions(+), 461 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.args
--
1.8.4.3
2
23
[libvirt] [PATCH libvirt-python] Update README file contents and add HACKING file
by Daniel P. Berrange 25 Nov '13
by Daniel P. Berrange 25 Nov '13
25 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The previous README file from the python code is more like a
HACKING file. Rename it and update the content. Then add a
basic README file
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
HACKING | 37 +++++++++++++++++++++++++++++++++++++
README | 41 +++++++++++++++++++++--------------------
2 files changed, 58 insertions(+), 20 deletions(-)
create mode 100644 HACKING
diff --git a/HACKING b/HACKING
new file mode 100644
index 0000000..b0f037f
--- /dev/null
+++ b/HACKING
@@ -0,0 +1,37 @@
+ libvirt Python Bindings Hacking
+ ===============================
+
+Most of the libvirt python binding code is automatically generated
+using the script generator.py, and the API description that the
+libvirt library installs into /usr/share (or wherever the following
+command says.
+
+ $ pkg-config --variable libvirt_api libvirt
+ /usr/share/libvirt/api/libvirt-api.xml
+
+
+Some of the API descriptions in the primary XML files are not directlry
+usable by the code generator. Thus there are overrides in
+
+ - libvirt-override-api.xml
+ - libvirt-qemu-override-api.xml
+ - libvirt-lxc-override-api.xml
+
+For stuff which the genrator can't cope with at all there are some
+hand written source files
+
+ - libvirt-override.c - low level binding to libvirt.so
+ - libvirt-qemu-override.c - low level binding to libvirt-qemu.so
+ - libvirt-lxc-override.c - low level binding to libvirt-lxc.so
+
+ - libvirt-override.py - high level overrides in the global namespace
+ - libvirt-override-virConnect.py - high level overrides in
+ the virConnect class
+ - libvirt-override-virDomain.py - high level overrides in
+ the virDomain class
+ - libvirt-override-virDomainSnapshot.py - high level overrides in
+ the virDomainSnapshot class
+ - libvirt-override-virStoragePool.py - high level overrides in
+ the virStoragePool class
+ - libvirt-override-virStream.py - high level overrides in
+ the virStream class
diff --git a/README b/README
index 02d4cc4..cadd2e4 100644
--- a/README
+++ b/README
@@ -1,27 +1,28 @@
- libvirt Python Bindings README
- ==============================
+ Libvirt Python Binding README
+ =============================
-Most of the libvirt python binding code is automatically generated
-using the script generator.py, and the API description from
-docs/libvirt-api.xml
+This package provides a python binding to the libvirt.so,
+libvirt-qemu.so and libvirt-lxc.so library APIs.
+It is written to build against any version of libvirt that
+is 0.9.11 or newer.
-Manually written files:
+This code is distributed under the terms of the LGPL version
+2 or later.
- - libvirt-override.c: methods where the C binding needs to be hand crafted
- - libvirt-override.py: global methods where the C and python bindings have different args
- - libvirt-override-api.xml: methods where the auto-extracted API docs are not
- suitable for python auto-generator. Overriding this if the method is going
- into libvirt-override.c, but we still want auto-generated libvirt-override.py
- - libvirt-override-virConnect.py: virConnect class methods
- - typewrappers.h,.c: Python object wrappers for each libvirt C object
+The module can be built by following the normal python module
+build processs
+ python setup.py build
+ sudo python setup.py install
-Auto-generated files:
+or to install as non-root
- - libvirt.py: The main python binding. Comprises auto-generated code, along
- with contents from libvirt-override.py and libvirt-override-virConnect.py
- - libvirt.c, libvirt.h: The C glue layer for the python binding. Comprises
- auto-generated code, along with libvirt-override.c
- - libvirt-export.c: List of auto-generated C methods, included into
- the libvirt-override.c method table
+ python setup.py build
+ python setup.py install --user
+
+
+Patches for this code should be sent to the main libvirt
+development mailing list
+
+ http://libvirt.org/contact.html#email
--
1.8.3.1
2
1
I got annoyed at having to use both 'virsh vol-list $pool --details'
AND 'virsh vol-dumpxml $vol $pool' to learn if I had populated
the volume correctly. Since two-thirds of the data present in
virStorageVolGetInfo() already appears in virStorageVolGetXMLDesc(),
this just adds the remaining piece of information, as:
<volume type='...'>
...
</volume>
* docs/formatstorage.html.in: Document new <volume type=...>.
* docs/schemas/storagevol.rng (vol): Add it to RelaxNG.
* src/conf/storage_conf.h (virStorageVolTypeToString): Declare.
* src/conf/storage_conf.c (virStorageVolTargetDefFormat): Output
the metatype.
(virStorageVolDefParseXML): Parse it, for unit tests.
* tests/storagevolxml2xmlout/vol-*.xml: Update tests to match.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
v1: https://www.redhat.com/archives/libvir-list/2013-November/msg00955.html
Since then, delay 'network-dir' until later in gluster series,
change XML to <volume type='file'> instead of <volume><type>file</type>,
and use 1.2.0 instead of 1.1.5
docs/formatstorage.html.in | 10 +++++++---
docs/schemas/storagevol.rng | 10 ++++++++++
src/conf/storage_conf.c | 19 ++++++++++++++++++-
src/conf/storage_conf.h | 1 +
tests/storagevolxml2xmlin/vol-logical-backing.xml | 2 +-
tests/storagevolxml2xmlin/vol-logical.xml | 2 +-
tests/storagevolxml2xmlin/vol-partition.xml | 2 +-
tests/storagevolxml2xmlin/vol-sheepdog.xml | 2 +-
tests/storagevolxml2xmlout/vol-file-backing.xml | 2 +-
tests/storagevolxml2xmlout/vol-file-naming.xml | 2 +-
tests/storagevolxml2xmlout/vol-file.xml | 2 +-
tests/storagevolxml2xmlout/vol-logical-backing.xml | 2 +-
tests/storagevolxml2xmlout/vol-logical.xml | 2 +-
tests/storagevolxml2xmlout/vol-partition.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-1.1.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-lazy.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml | 2 +-
tests/storagevolxml2xmlout/vol-qcow2.xml | 2 +-
tests/storagevolxml2xmlout/vol-sheepdog.xml | 2 +-
20 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 90eeaa3..c90d7b1 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -283,14 +283,18 @@
<h2><a name="StorageVol">Storage volume XML</a></h2>
<p>
- A storage volume will be either a file or a device node.
- The storage volume XML format is available <span class="since">since 0.4.1</span>
+ A storage volume will generally be either a file or a device
+ node; <span class="since">since 1.2.0</span>, an optional
+ output-only attribute <code>type</code> lists the actual type
+ (file, block, dir, or network), which is also available
+ from <code>virStorageVolGetInfo()</code>. The storage volume
+ XML format is available <span class="since">since 0.4.1</span>
</p>
<h3><a name="StorageVolFirst">General metadata</a></h3>
<pre>
- <volume>
+ <volume type='file'>
<name>sparse.img</name>
<key>/var/lib/xen/images/sparse.img</key>
<allocation>0</allocation>
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index e79bc35..f8081d9 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -13,6 +13,16 @@
<define name='vol'>
<element name='volume'>
+ <optional>
+ <attribute name='type'>
+ <choice>
+ <value>file</value>
+ <value>block</value>
+ <value>dir</value>
+ <value>network</value>
+ </choice>
+ </attribute>
+ </optional>
<interleave>
<element name='name'>
<ref name='volName'/>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8b378c2..0cd80c3 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -51,6 +51,10 @@
#define DEFAULT_POOL_PERM_MODE 0755
#define DEFAULT_VOL_PERM_MODE 0600
+VIR_ENUM_IMPL(virStorageVol,
+ VIR_STORAGE_VOL_LAST,
+ "file", "block", "dir", "network")
+
VIR_ENUM_IMPL(virStoragePool,
VIR_STORAGE_POOL_LAST,
"dir", "fs", "netfs",
@@ -1253,6 +1257,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
{
virStorageVolDefPtr ret;
virStorageVolOptionsPtr options;
+ char *type = NULL;
char *allocation = NULL;
char *capacity = NULL;
char *unit = NULL;
@@ -1278,6 +1283,16 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
/* Normally generated by pool refresh, but useful for unit tests */
ret->key = virXPathString("string(./key)", ctxt);
+ /* Technically overridden by pool refresh, but useful for unit tests */
+ type = virXPathString("string(./@type)", ctxt);
+ if (type) {
+ if ((ret->type = virStorageVolTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown volume type '%s'"), type);
+ goto error;
+ }
+ }
+
capacity = virXPathString("string(./capacity)", ctxt);
unit = virXPathString("string(./capacity/@unit)", ctxt);
if (capacity == NULL) {
@@ -1394,6 +1409,7 @@ cleanup:
VIR_FREE(allocation);
VIR_FREE(capacity);
VIR_FREE(unit);
+ VIR_FREE(type);
return ret;
error:
@@ -1563,7 +1579,8 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
if (options == NULL)
return NULL;
- virBufferAddLit(&buf, "<volume>\n");
+ virBufferAsprintf(&buf, "<volume type='%s'>\n",
+ virStorageVolTypeToString(def->type));
virBufferEscapeString(&buf, " <name>%s</name>\n", def->name);
virBufferEscapeString(&buf, " <key>%s</key>\n", def->key);
virBufferAddLit(&buf, " <source>\n");
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index f062bd8..c4dd403 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -116,6 +116,7 @@ struct _virStorageVolDefList {
virStorageVolDefPtr *objs;
};
+VIR_ENUM_DECL(virStorageVol)
enum virStoragePoolType {
VIR_STORAGE_POOL_DIR, /* Local directory */
diff --git a/tests/storagevolxml2xmlin/vol-logical-backing.xml b/tests/storagevolxml2xmlin/vol-logical-backing.xml
index b4141a5..38ff8c5 100644
--- a/tests/storagevolxml2xmlin/vol-logical-backing.xml
+++ b/tests/storagevolxml2xmlin/vol-logical-backing.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='block'>
<name>Swap</name>
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
diff --git a/tests/storagevolxml2xmlin/vol-logical.xml b/tests/storagevolxml2xmlin/vol-logical.xml
index cd4d3f7..46a607a 100644
--- a/tests/storagevolxml2xmlin/vol-logical.xml
+++ b/tests/storagevolxml2xmlin/vol-logical.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='block'>
<name>Swap</name>
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
diff --git a/tests/storagevolxml2xmlin/vol-partition.xml b/tests/storagevolxml2xmlin/vol-partition.xml
index 6990bb5..d810fff 100644
--- a/tests/storagevolxml2xmlin/vol-partition.xml
+++ b/tests/storagevolxml2xmlin/vol-partition.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='block'>
<name>sda1</name>
<key>/dev/sda1</key>
<source>
diff --git a/tests/storagevolxml2xmlin/vol-sheepdog.xml b/tests/storagevolxml2xmlin/vol-sheepdog.xml
index 49e221c..d6e920b 100644
--- a/tests/storagevolxml2xmlin/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlin/vol-sheepdog.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='network'>
<name>test2</name>
<source>
</source>
diff --git a/tests/storagevolxml2xmlout/vol-file-backing.xml b/tests/storagevolxml2xmlout/vol-file-backing.xml
index 8d2fb57..cd33bee 100644
--- a/tests/storagevolxml2xmlout/vol-file-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-file-backing.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name>sparse.img</name>
<key>/var/lib/libvirt/images/sparse.img</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-file-naming.xml b/tests/storagevolxml2xmlout/vol-file-naming.xml
index 7022b02..e515502 100644
--- a/tests/storagevolxml2xmlout/vol-file-naming.xml
+++ b/tests/storagevolxml2xmlout/vol-file-naming.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name><sparse>.img</name>
<source>
</source>
diff --git a/tests/storagevolxml2xmlout/vol-file.xml b/tests/storagevolxml2xmlout/vol-file.xml
index b97dd50..2923188 100644
--- a/tests/storagevolxml2xmlout/vol-file.xml
+++ b/tests/storagevolxml2xmlout/vol-file.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name>sparse.img</name>
<source>
</source>
diff --git a/tests/storagevolxml2xmlout/vol-logical-backing.xml b/tests/storagevolxml2xmlout/vol-logical-backing.xml
index bf34b08..07fe277 100644
--- a/tests/storagevolxml2xmlout/vol-logical-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-logical-backing.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='block'>
<name>Swap</name>
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-logical.xml b/tests/storagevolxml2xmlout/vol-logical.xml
index e9b4e4b..0df5cc0 100644
--- a/tests/storagevolxml2xmlout/vol-logical.xml
+++ b/tests/storagevolxml2xmlout/vol-logical.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='block'>
<name>Swap</name>
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-partition.xml b/tests/storagevolxml2xmlout/vol-partition.xml
index 9be1cf1..147899e 100644
--- a/tests/storagevolxml2xmlout/vol-partition.xml
+++ b/tests/storagevolxml2xmlout/vol-partition.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='block'>
<name>sda1</name>
<key>/dev/sda1</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
index fd3d606..1f799da 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name>OtherDemo.img</name>
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
index 99fb5ac..14f805f 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name>OtherDemo.img</name>
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
index 3708ea7..68a9756 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name>OtherDemo.img</name>
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
index f6a2e21..075dc69 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name>OtherDemo.img</name>
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2.xml b/tests/storagevolxml2xmlout/vol-qcow2.xml
index b9adcb4..31dc578 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='file'>
<name>OtherDemo.img</name>
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
diff --git a/tests/storagevolxml2xmlout/vol-sheepdog.xml b/tests/storagevolxml2xmlout/vol-sheepdog.xml
index bd5d6d8..e08e36c 100644
--- a/tests/storagevolxml2xmlout/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlout/vol-sheepdog.xml
@@ -1,4 +1,4 @@
-<volume>
+<volume type='network'>
<name>test2</name>
<source>
</source>
--
1.8.3.1
3
3
25 Nov '13
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The 'docs/examples' code was long ago removed and now the
python code was gone too, the custom 'tests' makefile target
serves no purpopse
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
Makefile.am | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 957aa9f..d7ddd9d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,9 +71,6 @@ rpm: clean
check-local: all tests
-tests:
- @(cd docs/examples ; $(MAKE) MAKEFLAGS+=--silent tests)
-
cov: clean-cov
mkdir $(top_builddir)/coverage
$(LCOV) -c -o $(top_builddir)/coverage/libvirt.info.tmp \
--
1.8.3.1
2
1
I got annoyed at having to use both 'virsh vol-list $pool --details'
AND 'virsh vol-dumpxml $vol $pool' to learn if I had populated
the volume correctly. Since two-thirds of the data present in
virStorageVolGetInfo() already appears in virStorageVolGetXMLDesc(),
this just adds the remaining piece of information.
* docs/formatstorage.html.in: Document new <target type=...>.
* docs/schemas/storagevol.rng (target, backingStore): Add it to
RelaxNG.
* src/conf/storage_conf.h (virStorageVolTypeToString): Declare.
* src/conf/storage_conf.c (virStorageVolTargetDefFormat): Output
the metatype.
* tests/storagevolxml2xmlout/vol-*.xml: Update tests to match.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Depends on:
https://www.redhat.com/archives/libvir-list/2013-November/msg00948.html
docs/formatstorage.html.in | 5 +++++
docs/schemas/storagevol.rng | 15 +++++++++++++++
src/conf/storage_conf.c | 18 ++++++++++++++++++
src/conf/storage_conf.h | 1 +
tests/storagevolxml2xmlin/vol-logical-backing.xml | 1 +
tests/storagevolxml2xmlin/vol-logical.xml | 1 +
tests/storagevolxml2xmlin/vol-partition.xml | 1 +
tests/storagevolxml2xmlin/vol-sheepdog.xml | 1 +
tests/storagevolxml2xmlout/vol-file-backing.xml | 1 +
tests/storagevolxml2xmlout/vol-file-naming.xml | 1 +
tests/storagevolxml2xmlout/vol-file.xml | 1 +
tests/storagevolxml2xmlout/vol-logical-backing.xml | 1 +
tests/storagevolxml2xmlout/vol-logical.xml | 1 +
tests/storagevolxml2xmlout/vol-partition.xml | 1 +
tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml | 1 +
tests/storagevolxml2xmlout/vol-qcow2-1.1.xml | 1 +
tests/storagevolxml2xmlout/vol-qcow2-lazy.xml | 1 +
tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml | 1 +
tests/storagevolxml2xmlout/vol-qcow2.xml | 1 +
tests/storagevolxml2xmlout/vol-sheepdog.xml | 1 +
20 files changed, 55 insertions(+)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 90eeaa3..5f277b4 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -293,6 +293,7 @@
<volume>
<name>sparse.img</name>
<key>/var/lib/xen/images/sparse.img</key>
+ <type>file</type>
<allocation>0</allocation>
<capacity unit="T">1</capacity>
...</pre>
@@ -305,6 +306,10 @@
<dd>Providing an identifier for the volume which is globally unique.
This cannot be set when creating a volume: it is always generated.
<span class="since">Since 0.4.1</span></dd>
+ <dt><code>type</code></dt>
+ <dd>Output-only; provides the volume type that is also available
+ from <code>virStorageVolGetInfo()</code>. <span class="since">Since
+ 1.1.5</span></dd>
<dt><code>allocation</code></dt>
<dd>Providing the total storage allocation for the volume. This
may be smaller than the logical capacity if the volume is sparsely
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index e79bc35..96572c5 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -25,6 +25,9 @@
<optional>
<ref name='source'/>
</optional>
+ <optional>
+ <ref name='voltype'/>
+ </optional>
<ref name='sizing'/>
<ref name='target'/>
<optional>
@@ -34,6 +37,18 @@
</element>
</define>
+ <define name='voltype'>
+ <element name='type'>
+ <choice>
+ <value>file</value>
+ <value>block</value>
+ <value>dir</value>
+ <value>network</value>
+ <value>network-dir</value>
+ </choice>
+ </element>
+ </define>
+
<define name='sizing'>
<interleave>
<optional>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8b378c2..0d2932b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -51,6 +51,10 @@
#define DEFAULT_POOL_PERM_MODE 0755
#define DEFAULT_VOL_PERM_MODE 0600
+VIR_ENUM_IMPL(virStorageVol,
+ VIR_STORAGE_VOL_LAST,
+ "file", "block", "dir", "network")
+
VIR_ENUM_IMPL(virStoragePool,
VIR_STORAGE_POOL_LAST,
"dir", "fs", "netfs",
@@ -1253,6 +1257,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
{
virStorageVolDefPtr ret;
virStorageVolOptionsPtr options;
+ char *type = NULL;
char *allocation = NULL;
char *capacity = NULL;
char *unit = NULL;
@@ -1278,6 +1283,16 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
/* Normally generated by pool refresh, but useful for unit tests */
ret->key = virXPathString("string(./key)", ctxt);
+ /* Technically overridden by pool refresh, but useful for unit tests */
+ type = virXPathString("string(./type)", ctxt);
+ if (type) {
+ if ((ret->type = virStorageVolTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("unknown volume type '%s'"), type);
+ goto error;
+ }
+ }
+
capacity = virXPathString("string(./capacity)", ctxt);
unit = virXPathString("string(./capacity/@unit)", ctxt);
if (capacity == NULL) {
@@ -1394,6 +1409,7 @@ cleanup:
VIR_FREE(allocation);
VIR_FREE(capacity);
VIR_FREE(unit);
+ VIR_FREE(type);
return ret;
error:
@@ -1592,6 +1608,8 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
}
virBufferAddLit(&buf, " </source>\n");
+ virBufferAsprintf(&buf, " <type>%s</type>\n",
+ virStorageVolTypeToString(def->type));
virBufferAsprintf(&buf, " <capacity unit='bytes'>%llu</capacity>\n",
def->capacity);
virBufferAsprintf(&buf, " <allocation unit='bytes'>%llu</allocation>\n",
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index f062bd8..c4dd403 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -116,6 +116,7 @@ struct _virStorageVolDefList {
virStorageVolDefPtr *objs;
};
+VIR_ENUM_DECL(virStorageVol)
enum virStoragePoolType {
VIR_STORAGE_POOL_DIR, /* Local directory */
diff --git a/tests/storagevolxml2xmlin/vol-logical-backing.xml b/tests/storagevolxml2xmlin/vol-logical-backing.xml
index b4141a5..d1a7b61 100644
--- a/tests/storagevolxml2xmlin/vol-logical-backing.xml
+++ b/tests/storagevolxml2xmlin/vol-logical-backing.xml
@@ -6,6 +6,7 @@
<extent start='31440502784' end='33520877568'/>
</device>
</source>
+ <type>block</type>
<capacity>2080374784</capacity>
<allocation>2080374784</allocation>
<target>
diff --git a/tests/storagevolxml2xmlin/vol-logical.xml b/tests/storagevolxml2xmlin/vol-logical.xml
index cd4d3f7..f98ff76 100644
--- a/tests/storagevolxml2xmlin/vol-logical.xml
+++ b/tests/storagevolxml2xmlin/vol-logical.xml
@@ -6,6 +6,7 @@
<extent start='31440502784' end='33520877568'/>
</device>
</source>
+ <type>block</type>
<capacity>2080374784</capacity>
<allocation>2080374784</allocation>
<target>
diff --git a/tests/storagevolxml2xmlin/vol-partition.xml b/tests/storagevolxml2xmlin/vol-partition.xml
index 6990bb5..d699635 100644
--- a/tests/storagevolxml2xmlin/vol-partition.xml
+++ b/tests/storagevolxml2xmlin/vol-partition.xml
@@ -6,6 +6,7 @@
<extent start='32256' end='106928640'/>
</device>
</source>
+ <type>block</type>
<capacity>106896384</capacity>
<allocation>106896384</allocation>
<target>
diff --git a/tests/storagevolxml2xmlin/vol-sheepdog.xml b/tests/storagevolxml2xmlin/vol-sheepdog.xml
index 49e221c..64884b2 100644
--- a/tests/storagevolxml2xmlin/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlin/vol-sheepdog.xml
@@ -2,6 +2,7 @@
<name>test2</name>
<source>
</source>
+ <type>network</type>
<capacity unit='bytes'>1024</capacity>
<allocation unit='bytes'>0</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-file-backing.xml b/tests/storagevolxml2xmlout/vol-file-backing.xml
index 8d2fb57..ca0598d 100644
--- a/tests/storagevolxml2xmlout/vol-file-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-file-backing.xml
@@ -3,6 +3,7 @@
<key>/var/lib/libvirt/images/sparse.img</key>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>10000000000</capacity>
<allocation unit='bytes'>0</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-file-naming.xml b/tests/storagevolxml2xmlout/vol-file-naming.xml
index 7022b02..4ca40ba 100644
--- a/tests/storagevolxml2xmlout/vol-file-naming.xml
+++ b/tests/storagevolxml2xmlout/vol-file-naming.xml
@@ -2,6 +2,7 @@
<name><sparse>.img</name>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>1099511627776</capacity>
<allocation unit='bytes'>0</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-file.xml b/tests/storagevolxml2xmlout/vol-file.xml
index b97dd50..05ffa49 100644
--- a/tests/storagevolxml2xmlout/vol-file.xml
+++ b/tests/storagevolxml2xmlout/vol-file.xml
@@ -2,6 +2,7 @@
<name>sparse.img</name>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>1099511627776</capacity>
<allocation unit='bytes'>0</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-logical-backing.xml b/tests/storagevolxml2xmlout/vol-logical-backing.xml
index bf34b08..5f52ee6 100644
--- a/tests/storagevolxml2xmlout/vol-logical-backing.xml
+++ b/tests/storagevolxml2xmlout/vol-logical-backing.xml
@@ -3,6 +3,7 @@
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
</source>
+ <type>block</type>
<capacity unit='bytes'>2080374784</capacity>
<allocation unit='bytes'>2080374784</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-logical.xml b/tests/storagevolxml2xmlout/vol-logical.xml
index e9b4e4b..f8ed510 100644
--- a/tests/storagevolxml2xmlout/vol-logical.xml
+++ b/tests/storagevolxml2xmlout/vol-logical.xml
@@ -3,6 +3,7 @@
<key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key>
<source>
</source>
+ <type>block</type>
<capacity unit='bytes'>2080374784</capacity>
<allocation unit='bytes'>2080374784</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-partition.xml b/tests/storagevolxml2xmlout/vol-partition.xml
index 9be1cf1..712b7b0 100644
--- a/tests/storagevolxml2xmlout/vol-partition.xml
+++ b/tests/storagevolxml2xmlout/vol-partition.xml
@@ -3,6 +3,7 @@
<key>/dev/sda1</key>
<source>
</source>
+ <type>block</type>
<capacity unit='bytes'>106896384</capacity>
<allocation unit='bytes'>106896384</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
index fd3d606..3447689 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml
@@ -3,6 +3,7 @@
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>5368709120</capacity>
<allocation unit='bytes'>294912</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
index 99fb5ac..4157628 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-1.1.xml
@@ -3,6 +3,7 @@
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>5368709120</capacity>
<allocation unit='bytes'>294912</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
index 3708ea7..7b29c02 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-lazy.xml
@@ -3,6 +3,7 @@
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>5368709120</capacity>
<allocation unit='bytes'>294912</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
index f6a2e21..ebf79ed 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2-nobacking.xml
@@ -3,6 +3,7 @@
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>5368709120</capacity>
<allocation unit='bytes'>294912</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-qcow2.xml b/tests/storagevolxml2xmlout/vol-qcow2.xml
index b9adcb4..75f0dcf 100644
--- a/tests/storagevolxml2xmlout/vol-qcow2.xml
+++ b/tests/storagevolxml2xmlout/vol-qcow2.xml
@@ -3,6 +3,7 @@
<key>/var/lib/libvirt/images/OtherDemo.img</key>
<source>
</source>
+ <type>file</type>
<capacity unit='bytes'>5368709120</capacity>
<allocation unit='bytes'>294912</allocation>
<target>
diff --git a/tests/storagevolxml2xmlout/vol-sheepdog.xml b/tests/storagevolxml2xmlout/vol-sheepdog.xml
index bd5d6d8..182c841 100644
--- a/tests/storagevolxml2xmlout/vol-sheepdog.xml
+++ b/tests/storagevolxml2xmlout/vol-sheepdog.xml
@@ -2,6 +2,7 @@
<name>test2</name>
<source>
</source>
+ <type>network</type>
<capacity unit='bytes'>1024</capacity>
<allocation unit='bytes'>0</allocation>
<target>
--
1.8.3.1
3
4
[libvirt] [PATCH] spec: Don't save/restore running VMs on libvirt-client update
by Jiri Denemark 25 Nov '13
by Jiri Denemark 25 Nov '13
25 Nov '13
The previous attempt (commit d65e0e1) removed just one of two
libvirt-guests restarts that happened on libvirt-client update. Let's
remove the last one too :-)
https://bugzilla.redhat.com/show_bug.cgi?id=962225
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
libvirt.spec.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index bbce8b5..d11b11f 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1706,7 +1706,7 @@ fi
/sbin/ldconfig
%if %{with_systemd}
%if %{with_systemd_macros}
- %systemd_postun_with_restart libvirt-guests.service
+ %systemd_postun libvirt-guests.service
%endif
%triggerun client -- libvirt < 0.9.4
%{_bindir}/systemd-sysv-convert --save libvirt-guests >/dev/null 2>&1 ||:
--
1.8.4.4
2
2
No other hits for:
git grep '1\.1\.5'
* libvirt-utils.h: Fix comment.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the trivial rule (and as a test that the new
python repo is set up correctly).
libvirt-utils.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-utils.h b/libvirt-utils.h
index 0517f9c..f55be7b 100644
--- a/libvirt-utils.h
+++ b/libvirt-utils.h
@@ -29,7 +29,7 @@
# endif
/**
- * libvirt.h provides this as of version 1.1.5, but we want to be able
+ * libvirt.h provides this as of version 1.2.0, but we want to be able
* to support older versions of libvirt so copy and paste the macro from
* libvirt.h
*/
--
1.8.3.1
1
0
[libvirt] [PATCH v4] virsh domxml-from-native to treat SCSI as the bus type for pseries by default
by Shivaprasad G Bhat 25 Nov '13
by Shivaprasad G Bhat 25 Nov '13
25 Nov '13
The bus type IDE being enum Zero, the bus type on pseries system appears as IDE for all the -hda/-cdrom and for disk drives with if="none" type. Pseries platform needs this to appear as SCSI instead of IDE. The ide being not supported, the explicit requests for ide devices will return an error.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_command.c | 25 +++++++++++--
tests/qemuargv2xmltest.c | 1 +
.../qemuxml2argv-pseries-disk.args | 5 +++
.../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 40 ++++++++++++++++++++
4 files changed, 67 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8dc7e43..01fe45b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10032,6 +10032,7 @@ error:
static virDomainDiskDefPtr
qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
const char *val,
+ virDomainDefPtr dom,
int nvirtiodisk,
bool old_style_ceph_args)
{
@@ -10055,7 +10056,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
if (VIR_ALLOC(def) < 0)
goto cleanup;
- def->bus = VIR_DOMAIN_DISK_BUS_IDE;
+ if (((dom->os.arch == VIR_ARCH_PPC64) &&
+ dom->os.machine && STREQ(dom->os.machine, "pseries")))
+ def->bus = VIR_DOMAIN_DISK_BUS_SCSI;
+ else
+ def->bus = VIR_DOMAIN_DISK_BUS_IDE;
def->device = VIR_DOMAIN_DISK_DEVICE_DISK;
def->type = VIR_DOMAIN_DISK_TYPE_FILE;
@@ -10140,9 +10145,15 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
def->type = VIR_DOMAIN_DISK_TYPE_FILE;
}
} else if (STREQ(keywords[i], "if")) {
- if (STREQ(values[i], "ide"))
+ if (STREQ(values[i], "ide")) {
def->bus = VIR_DOMAIN_DISK_BUS_IDE;
- else if (STREQ(values[i], "scsi"))
+ if (((dom->os.arch == VIR_ARCH_PPC64) &&
+ dom->os.machine && STREQ(dom->os.machine, "pseries"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("pseries systems do not support ide devices '%s'"), val);
+ goto error;
+ }
+ } else if (STREQ(values[i], "scsi"))
def->bus = VIR_DOMAIN_DISK_BUS_SCSI;
else if (STREQ(values[i], "virtio"))
def->bus = VIR_DOMAIN_DISK_BUS_VIRTIO;
@@ -11368,6 +11379,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
if (STREQ(arg, "-cdrom")) {
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
+ if (((def->os.arch == VIR_ARCH_PPC64) &&
+ def->os.machine && STREQ(def->os.machine, "pseries")))
+ disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
if (VIR_STRDUP(disk->dst, "hdc") < 0)
goto error;
disk->readonly = true;
@@ -11381,6 +11395,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
else
disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
+ if (((def->os.arch == VIR_ARCH_PPC64) &&
+ def->os.machine && STREQ(def->os.machine, "pseries")))
+ disk->bus = VIR_DOMAIN_DISK_BUS_SCSI;
}
if (VIR_STRDUP(disk->dst, arg + 1) < 0)
goto error;
@@ -11672,7 +11689,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
}
} else if (STREQ(arg, "-drive")) {
WANT_VALUE();
- if (!(disk = qemuParseCommandLineDisk(xmlopt, val,
+ if (!(disk = qemuParseCommandLineDisk(xmlopt, val, def,
nvirtiodisk,
ceph_args != NULL)))
goto error;
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 6dd8bb0..0bf4c37 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -249,6 +249,7 @@ mymain(void)
DO_TEST("hyperv");
DO_TEST("pseries-nvram");
+ DO_TEST("pseries-disk");
DO_TEST("nosharepages");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args
new file mode 100644
index 0000000..5fc0938
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 \
+-S -M pseries -m 512 -smp 1 \
+-no-acpi -boot c -usb \
+-boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
new file mode 100644
index 0000000..dbbd6aa
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml
@@ -0,0 +1,40 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>87eedafe-eedc-4336-8130-ed9fe5dc90c8</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='scsi'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='0' target='0' unit='2'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='scsi' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='sdl'/>
+ <video>
+ <model type='cirrus' vram='9216' heads='1'/>
+ </video>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
2
1
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The python binding now lives in
http://libvirt.org/git/libvirt-python.git
that repo also provides an RPM which is upgrade compatible
with the old libvirt-python sub-RPM.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
.gitignore | 11 -
Makefile.am | 7 +-
autobuild.sh | 6 +-
cfg.mk | 7 +-
configure.ac | 86 -
examples/domain-events/events-python/event-test.py | 591 --
examples/python/Makefile.am | 21 -
examples/python/README | 33 -
examples/python/consolecallback.py | 88 -
examples/python/dominfo.py | 80 -
examples/python/domrestore.py | 36 -
examples/python/domsave.py | 40 -
examples/python/domstart.py | 50 -
examples/python/esxlist.py | 155 -
examples/python/topology.py | 45 -
libvirt.spec.in | 36 +-
m4/virt-compile-warnings.m4 | 8 -
mingw-libvirt.spec.in | 1 -
python/Makefile.am | 173 -
python/README | 27 -
python/generator.py | 1976 ------
python/libvirt-lxc-override-api.xml | 19 -
python/libvirt-lxc-override.c | 142 -
python/libvirt-override-api.xml | 613 --
python/libvirt-override-virConnect.py | 351 -
python/libvirt-override-virDomain.py | 49 -
python/libvirt-override-virDomainSnapshot.py | 19 -
python/libvirt-override-virStoragePool.py | 11 -
python/libvirt-override-virStream.py | 125 -
python/libvirt-override.c | 7379 --------------------
python/libvirt-override.py | 209 -
python/libvirt-qemu-override-api.xml | 20 -
python/libvirt-qemu-override.c | 154 -
python/sanitytest.py | 36 -
python/typewrappers.c | 524 --
python/typewrappers.h | 239 -
run.in | 9 -
37 files changed, 7 insertions(+), 13369 deletions(-)
delete mode 100644 examples/domain-events/events-python/event-test.py
delete mode 100644 examples/python/Makefile.am
delete mode 100644 examples/python/README
delete mode 100644 examples/python/consolecallback.py
delete mode 100755 examples/python/dominfo.py
delete mode 100755 examples/python/domrestore.py
delete mode 100755 examples/python/domsave.py
delete mode 100755 examples/python/domstart.py
delete mode 100755 examples/python/esxlist.py
delete mode 100755 examples/python/topology.py
delete mode 100644 python/Makefile.am
delete mode 100644 python/README
delete mode 100755 python/generator.py
delete mode 100644 python/libvirt-lxc-override-api.xml
delete mode 100644 python/libvirt-lxc-override.c
delete mode 100644 python/libvirt-override-api.xml
delete mode 100644 python/libvirt-override-virConnect.py
delete mode 100644 python/libvirt-override-virDomain.py
delete mode 100644 python/libvirt-override-virDomainSnapshot.py
delete mode 100644 python/libvirt-override-virStoragePool.py
delete mode 100644 python/libvirt-override-virStream.py
delete mode 100644 python/libvirt-override.c
delete mode 100644 python/libvirt-override.py
delete mode 100644 python/libvirt-qemu-override-api.xml
delete mode 100644 python/libvirt-qemu-override.c
delete mode 100644 python/sanitytest.py
delete mode 100644 python/typewrappers.c
delete mode 100644 python/typewrappers.h
diff --git a/.gitignore b/.gitignore
index 6b024e7..faabd33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -91,17 +91,6 @@
/mkinstalldirs
/po/*
/proxy/
-/python/generated.stamp
-/python/generator.py.stamp
-/python/libvirt-export.c
-/python/libvirt-lxc-export.c
-/python/libvirt-lxc.[ch]
-/python/libvirt-qemu-export.c
-/python/libvirt-qemu.[ch]
-/python/libvirt.[ch]
-/python/libvirt.py
-/python/libvirt_lxc.py
-/python/libvirt_qemu.py
/run
/sc_*
/src/.*.stamp
diff --git a/Makefile.am b/Makefile.am
index 192a378..957aa9f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,8 +20,8 @@ LCOV = lcov
GENHTML = genhtml
SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
- python tests po examples/domain-events/events-c examples/hellolibvirt \
- examples/dominfo examples/domsuspend examples/python examples/apparmor \
+ tests po examples/domain-events/events-c examples/hellolibvirt \
+ examples/dominfo examples/domsuspend examples/apparmor \
examples/xml/nwfilter examples/openauth examples/systemtap
ACLOCAL_AMFLAGS = -I m4
@@ -40,7 +40,6 @@ EXTRA_DIST = \
Makefile.nonreentrant \
autogen.sh \
cfg.mk \
- examples/domain-events/events-python \
run.in \
AUTHORS.in \
$(XML_EXAMPLES)
@@ -74,8 +73,6 @@ check-local: all tests
tests:
@(cd docs/examples ; $(MAKE) MAKEFLAGS+=--silent tests)
- @(if [ "$(pythondir)" != "" ] ; then cd python ; \
- $(MAKE) MAKEFLAGS+=--silent tests ; fi)
cov: clean-cov
mkdir $(top_builddir)/coverage
diff --git a/autobuild.sh b/autobuild.sh
index 3109b49..f682b51 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -86,8 +86,7 @@ if test -x /usr/bin/i686-w64-mingw32-gcc ; then
--prefix="$AUTOBUILD_INSTALL_ROOT/i686-w64-mingw32/sys-root/mingw" \
--enable-expensive-tests \
--enable-werror \
- --without-libvirtd \
- --without-python
+ --without-libvirtd
make
make install
@@ -107,8 +106,7 @@ if test -x /usr/bin/x86_64-w64-mingw32-gcc ; then
--prefix="$AUTOBUILD_INSTALL_ROOT/x86_64-w64-mingw32/sys-root/mingw" \
--enable-expensive-tests \
--enable-werror \
- --without-libvirtd \
- --without-python
+ --without-libvirtd
make
make install
diff --git a/cfg.mk b/cfg.mk
index befd231..bd3dd48 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -958,14 +958,11 @@ exclude_file_name_regexp--sc_prohibit_VIR_ERR_NO_MEMORY = \
exclude_file_name_regexp--sc_prohibit_access_xok = ^src/util/virutil\.c$$
-exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
- ^python/(libvirt-(lxc-|qemu-)?override|typewrappers)\.c$$
-
exclude_file_name_regexp--sc_prohibit_asprintf = \
^(bootstrap.conf$$|src/util/virstring\.[ch]$$|examples/domain-events/events-c/event-test\.c$$|tests/vircgroupmock\.c$$)
exclude_file_name_regexp--sc_prohibit_strdup = \
- ^(docs/|examples/|python/|src/util/virstring\.c|tests/virnetserverclientmock.c$$)
+ ^(docs/|examples/|src/util/virstring\.c|tests/virnetserverclientmock.c$$)
exclude_file_name_regexp--sc_prohibit_close = \
(\.p[yl]$$|^docs/|^(src/util/virfile\.c|src/libvirt\.c|tests/vir(cgroup|pci)mock\.c)$$)
@@ -1033,7 +1030,7 @@ exclude_file_name_regexp--sc_prohibit_include_public_headers_quote = \
^src/internal\.h$$
exclude_file_name_regexp--sc_prohibit_include_public_headers_brackets = \
- ^(python/|tools/|examples/|include/libvirt/(virterror|libvirt-(qemu|lxc))\.h$$)
+ ^(tools/|examples/|include/libvirt/(virterror|libvirt-(qemu|lxc))\.h$$)
exclude_file_name_regexp--sc_prohibit_int_ijk = \
^(src/remote_protocol-structs|src/remote/remote_protocol.x|cfg.mk|include/)$
diff --git a/configure.ac b/configure.ac
index 6003871..044cf37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2012,83 +2012,6 @@ fi
AM_CONDITIONAL([WITH_HYPERV], [test "$with_hyperv" = "yes"])
-dnl
-dnl check for python
-dnl
-
-AC_ARG_WITH([python],
- [AS_HELP_STRING([--with-python],
- [Build python bindings @<:@default=yes@:>@])],
- [],[with_python=yes])
-
-if test "$enable_shared:$with_python" = no:yes; then
- AC_MSG_WARN([Disabling shared libraries is incompatible with building Python extensions.])
- AC_MSG_WARN([Ignoring --with-python.])
- with_python=no
-fi
-
-PYTHON_VERSION=
-PYTHON_INCLUDES=
-if test "$with_python" != "no" ; then
- if test -x "$with_python/bin/python"
- then
- AC_MSG_NOTICE(Found python in $with_python/bin/python)
- PYTHON="$with_python/bin/python"
- with_python=yes
- else
- if test -x "$with_python"
- then
- AC_MSG_NOTICE(Found python in $with_python)
- PYTHON="$with_python"
- with_python=yes
- else
- if test -x "$PYTHON"
- then
- AC_MSG_NOTICE(Found python in environment PYTHON=$PYTHON)
- with_python=yes
- fi
- fi
- fi
-
- if test "$with_python" = "yes" ; then
- AM_PATH_PYTHON(,, [:])
-
- if test "$PYTHON" != : ; then
- PYTHON_CONFIG="$PYTHON-config"
-
- if test -x "$PYTHON_CONFIG"
- then
- PYTHON_INCLUDES=`$PYTHON_CONFIG --includes`
- else
- if test -r $PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION/Python.h
- then
- PYTHON_INCLUDES=-I$PYTHON_EXEC_PREFIX/include/python$PYTHON_VERSION
- else
- if test -r $prefix/include/python$PYTHON_VERSION/Python.h
- then
- PYTHON_INCLUDES=-I$prefix/include/python$PYTHON_VERSION
- else
- if test -r /usr/include/python$PYTHON_VERSION/Python.h
- then
- PYTHON_INCLUDES=-I/usr/include/python$PYTHON_VERSION
- else
- AC_MSG_ERROR([You must install python-devel to build Python bindings])
- fi
- fi
- fi
- fi
- else
- AC_MSG_ERROR([You must install python to build Python bindings])
- fi
- else
- AC_MSG_NOTICE([Could not find python in $with_python, disabling bindings])
- with_python=no
- fi
-fi
-AM_CONDITIONAL([WITH_PYTHON], [test "$with_python" = "yes"])
-AC_SUBST([PYTHON_VERSION])
-AC_SUBST([PYTHON_INCLUDES])
-
dnl Allow perl overrides
AC_PATH_PROG([PERL], [perl])
@@ -2227,7 +2150,6 @@ dnl Copied from libxml2 configure.in, but I removed mingw changes
dnl for now since I'm not supporting mingw at present. - RWMJ
CYGWIN_EXTRA_LDFLAGS=
CYGWIN_EXTRA_LIBADD=
-CYGWIN_EXTRA_PYTHON_LIBADD=
MINGW_EXTRA_LDFLAGS=
WIN32_EXTRA_CFLAGS=
dnl libvirt.syms is generated in builddir, but libvirt_qemu.syms is in git;
@@ -2241,10 +2163,6 @@ case "$host" in
CYGWIN_EXTRA_LDFLAGS="-no-undefined"
CYGWIN_EXTRA_LIBADD="${INTLLIBS}"
MSCOM_LIBS="-lole32 -loleaut32"
-
- if test "x$PYTHON_VERSION" != "x"; then
- CYGWIN_EXTRA_PYTHON_LIBADD="-L/usr/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}"
- fi
;;
*-*-mingw*)
MINGW_EXTRA_LDFLAGS="-no-undefined"
@@ -2279,7 +2197,6 @@ case "$host" in
esac
AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
AC_SUBST([CYGWIN_EXTRA_LIBADD])
-AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
AC_SUBST([MINGW_EXTRA_LDFLAGS])
AC_SUBST([WIN32_EXTRA_CFLAGS])
AC_SUBST([LIBVIRT_SYMBOL_FILE])
@@ -2613,7 +2530,6 @@ AC_CONFIG_FILES([\
libvirt.pc libvirt.spec mingw-libvirt.spec \
po/Makefile.in \
include/libvirt/Makefile include/libvirt/libvirt.h \
- python/Makefile \
daemon/Makefile \
tools/Makefile \
tests/Makefile \
@@ -2622,7 +2538,6 @@ AC_CONFIG_FILES([\
examples/domsuspend/Makefile \
examples/dominfo/Makefile \
examples/openauth/Makefile \
- examples/python/Makefile \
examples/hellolibvirt/Makefile \
examples/systemtap/Makefile \
examples/xml/nwfilter/Makefile])
@@ -2778,7 +2693,6 @@ AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Debug: $enable_debug])
AC_MSG_NOTICE([ Use -Werror: $set_werror])
AC_MSG_NOTICE([ Warning Flags: $WARN_CFLAGS])
-AC_MSG_NOTICE([ Python: $with_python])
AC_MSG_NOTICE([ DTrace: $with_dtrace])
AC_MSG_NOTICE([ numad: $with_numad])
AC_MSG_NOTICE([ XML Catalog: $XML_CATALOG_FILE])
diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
deleted file mode 100644
index 84f5259..0000000
--- a/examples/domain-events/events-python/event-test.py
+++ /dev/null
@@ -1,591 +0,0 @@
-#!/usr/bin/python -u
-#
-#
-#
-#################################################################################
-# Start off by implementing a general purpose event loop for anyones use
-#################################################################################
-
-import sys
-import getopt
-import os
-import libvirt
-import select
-import errno
-import time
-import threading
-
-# For the sake of demonstration, this example program includes
-# an implementation of a pure python event loop. Most applications
-# would be better off just using the default libvirt event loop
-# APIs, instead of implementing this in python. The exception is
-# where an application wants to integrate with an existing 3rd
-# party event loop impl
-#
-# Change this to 'False' to make the demo use the native
-# libvirt event loop impl
-use_pure_python_event_loop = True
-
-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 virEventLoopPure:
- # This class contains the data we need to track for a
- # single file handle
- class virEventLoopPureHandle:
- 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 virEventLoopPureTimer:
- 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.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 virEventLoopPureHandle 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 virEventLoopPureHandle 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
- # calcuates 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 schedular timeslices, if
- # we ask for a sleep of 500ms in order to satisfy a timer, we
- # may return up to 1 schedular 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
- 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), e:
- if e.args[0] != errno.EINTR:
- raise
- finally:
- self.runningPoll = False
-
-
- # Actually 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')
-
-
- # 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.virEventLoopPureHandle(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.virEventLoopPureTimer(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:
- self.poll.unregister(h.get_fd())
- debug("Remove handle %d fd %d" % (handleID, h.get_fd()))
- 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)
- debug("Remove timer %d" % timerID)
- 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 = virEventLoopPure()
-
-# 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 'virEventLoopPure' 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 virEventLoopPureRegister():
- libvirt.virEventRegisterImpl(virEventAddHandleImpl,
- virEventUpdateHandleImpl,
- virEventRemoveHandleImpl,
- virEventAddTimerImpl,
- virEventUpdateTimerImpl,
- virEventRemoveTimerImpl)
-
-# Directly run the event loop in the current thread
-def virEventLoopPureRun():
- global eventLoop
- eventLoop.run_loop()
-
-def virEventLoopNativeRun():
- while True:
- libvirt.virEventRunDefaultImpl()
-
-# Spawn a background thread to run the event loop
-def virEventLoopPureStart():
- global eventLoopThread
- virEventLoopPureRegister()
- eventLoopThread = threading.Thread(target=virEventLoopPureRun, 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 eventToString(event):
- eventStrings = ( "Defined",
- "Undefined",
- "Started",
- "Suspended",
- "Resumed",
- "Stopped",
- "Shutdown",
- "PMSuspended",
- "Crashed" )
- return eventStrings[event]
-
-def detailToString(event, detail):
- eventStrings = (
- ( "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", ),
- ( "Memory", "Disk" ),
- ( "Panicked", )
- )
- return eventStrings[event][detail]
-
-def myDomainEventCallback1 (conn, dom, event, detail, opaque):
- print "myDomainEventCallback1 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
- eventToString(event),
- detailToString(event, detail))
-
-def myDomainEventCallback2 (conn, dom, event, detail, opaque):
- print "myDomainEventCallback2 EVENT: Domain %s(%s) %s %s" % (dom.name(), dom.ID(),
- eventToString(event),
- detailToString(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 myDomainEventGraphicsCallback(conn, dom, phase, localAddr, remoteAddr, authScheme, subject, opaque):
- print "myDomainEventGraphicsCallback: Domain %s(%s) %d %s" % (dom.name(), dom.ID(), phase, authScheme)
-
-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)
-
-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(out=sys.stderr):
- print >>out, "usage: "+os.path.basename(sys.argv[0])+" [-hdl] [uri]"
- print >>out, " uri will default to qemu:///system"
- print >>out, " --help, -h Print this help message"
- print >>out, " --debug, -d Print debug output"
- print >>out, " --loop, -l Toggle event-loop-implementation"
-
-def main():
- try:
- opts, args = getopt.getopt(sys.argv[1:], "hdl", ["help", "debug", "loop"])
- except getopt.GetoptError, 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.stdout)
- sys.exit()
- if o in ("-d", "--debug"):
- global do_debug
- do_debug = True
- if o in ("-l", "--loop"):
- global use_pure_python_event_loop
- use_pure_python_event_loop ^= True
-
- if len(args) >= 1:
- uri = args[0]
- else:
- uri = "qemu:///system"
-
- print "Using uri:" + uri
-
- # Run a background thread with the event loop
- if use_pure_python_event_loop:
- virEventLoopPureStart()
- else:
- virEventLoopNativeStart()
-
- vc = libvirt.openReadOnly(uri)
-
- # Close connection on exit (to test cleanup paths)
- old_exitfunc = getattr(sys, 'exitfunc', None)
- def exit():
- print "Closing " + str(vc)
- vc.close()
- if (old_exitfunc): old_exitfunc()
- sys.exitfunc = exit
-
- vc.registerCloseCallback(myConnectionCloseCallback, None)
-
- #Add 2 callbacks to prove this works with more than just one
- vc.domainEventRegister(myDomainEventCallback1,None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, myDomainEventCallback2, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_REBOOT, myDomainEventRebootCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_RTC_CHANGE, myDomainEventRTCChangeCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR, myDomainEventIOErrorCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_WATCHDOG, myDomainEventWatchdogCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_GRAPHICS, myDomainEventGraphicsCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DISK_CHANGE, myDomainEventDiskChangeCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_TRAY_CHANGE, myDomainEventTrayChangeCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMWAKEUP, myDomainEventPMWakeupCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMSUSPEND, myDomainEventPMSuspendCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE, myDomainEventBalloonChangeCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK, myDomainEventPMSuspendDiskCallback, None)
- vc.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED, myDomainEventDeviceRemovedCallback, 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.
- while run:
- time.sleep(1)
-
-
-if __name__ == "__main__":
- main()
diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am
deleted file mode 100644
index 7823c20..0000000
--- a/examples/python/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-## Copyright (C) 2005-2013 Red Hat, Inc.
-##
-## 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, see
-## <http://www.gnu.org/licenses/>.
-
-EXTRA_DIST= \
- README \
- consolecallback.py \
- topology.py \
- dominfo.py domrestore.py domsave.py domstart.py esxlist.py
diff --git a/examples/python/README b/examples/python/README
deleted file mode 100644
index f4db76c..0000000
--- a/examples/python/README
+++ /dev/null
@@ -1,33 +0,0 @@
-Some simple examples on how to use the Python API for libvirt
-
-The examples are:
-
-dominfo.py - print information about a running domU based on the results of
- virDomainGetInfo and virDomainGetXMLDesc
-domstart.py - create a domU from an XML description if the domU isn't
- running yet
-domsave.py - save all running domU's into a directory
-domrestore.py - restore domU's from their saved files in a directory
-esxlist.py - list active domains of an VMware ESX host and print some info.
- also demonstrates how to use the libvirt.openAuth() method
-
-The XML files in this directory are examples of the XML format that libvirt
-expects, and will have to be adapted for your setup. They are only needed
-for domstart.py
-
-
-Some additional notes for the esxlist.py example:
-
-You may see remote errors complaining about missing certificates:
-
- Cannot access CA certificate '/usr/local/etc/pki/CA/cacert.pem': No such file
- or directory
-
-This is expected, libvirt tries to find network and storage drivers for ESX,
-but those are not implemented yet (November 2009). While searching for this
-drivers, libvirt may try to start a local libvirtd instance, but fails because
-of the missing certificates. It'll warn about that:
-
- Failed to find the network: Is the daemon running?
-
-This is also expected and can be ignored.
diff --git a/examples/python/consolecallback.py b/examples/python/consolecallback.py
deleted file mode 100644
index d8e33a9..0000000
--- a/examples/python/consolecallback.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/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()
diff --git a/examples/python/dominfo.py b/examples/python/dominfo.py
deleted file mode 100755
index bfa3ca3..0000000
--- a/examples/python/dominfo.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/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")
diff --git a/examples/python/domrestore.py b/examples/python/domrestore.py
deleted file mode 100755
index fffc90f..0000000
--- a/examples/python/domrestore.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/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,
- sys.stdout.flush()
- ret = conn.restore(file)
- if ret == 0:
- print "done"
- else:
- print "error %d" % ret
diff --git a/examples/python/domsave.py b/examples/python/domsave.py
deleted file mode 100755
index bac4536..0000000
--- a/examples/python/domsave.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/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),
- sys.stdout.flush()
- path = os.path.join(dir, dom.name())
- ret = dom.save(path)
- if ret == 0:
- print "done"
- else:
- print "error %d" % ret
-
-#pdb.set_trace()
diff --git a/examples/python/domstart.py b/examples/python/domstart.py
deleted file mode 100755
index b14fad1..0000000
--- a/examples/python/domstart.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/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,
- sys.stdout.flush()
- dom = conn.createLinux(xmldesc, 0)
- if dom is None:
- print "failed"
- sys.exit(1)
- else:
- print "done"
diff --git a/examples/python/esxlist.py b/examples/python/esxlist.py
deleted file mode 100755
index c55424f..0000000
--- a/examples/python/esxlist.py
+++ /dev/null
@@ -1,155 +0,0 @@
-#!/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")
diff --git a/examples/python/topology.py b/examples/python/topology.py
deleted file mode 100755
index 62effe3..0000000
--- a/examples/python/topology.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-# Parse topology information from the capabilities XML and use
-# them to calculate host topology
-#
-# Authors:
-# Amador Pahim <apahim(a)redhat.com>
-# Peter Krempa <pkrempa(a)redhat.com>
-
-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
diff --git a/libvirt.spec.in b/libvirt.spec.in
index bbce8b5..5bc53a0 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -126,7 +126,6 @@
%define with_libssh2 0%{!?_without_libssh2:0}
# Non-server/HV driver defaults which are always enabled
-%define with_python 0%{!?_without_python:1}
%define with_sasl 0%{!?_without_sasl:1}
@@ -425,7 +424,6 @@ BuildRequires: gettext-devel
BuildRequires: libtool
BuildRequires: /usr/bin/pod2man
%endif
-BuildRequires: python-devel
%if %{with_systemd}
BuildRequires: systemd-units
%endif
@@ -1145,19 +1143,6 @@ Includes the Sanlock lock manager plugin for the QEMU
driver
%endif
-%if %{with_python}
-%package python
-Summary: Python bindings for the libvirt library
-Group: Development/Libraries
-Requires: %{name}-client = %{version}-%{release}
-
-%description python
-The libvirt-python package contains a module that permits applications
-written in the Python programming language to use the interface
-supplied by the libvirt library to use the virtualization capabilities
-of recent versions of Linux (and other OSes).
-%endif
-
%prep
%setup -q
@@ -1222,10 +1207,6 @@ of recent versions of Linux (and other OSes).
%define _without_polkit --without-polkit
%endif
-%if ! %{with_python}
- %define _without_python --without-python
-%endif
-
%if ! %{with_libvirtd}
%define _without_libvirtd --without-libvirtd
%endif
@@ -1378,7 +1359,6 @@ of recent versions of Linux (and other OSes).
%{?_without_sasl} \
%{?_without_avahi} \
%{?_without_polkit} \
- %{?_without_python} \
%{?_without_libvirtd} \
%{?_without_uml} \
%{?_without_phyp} \
@@ -1432,14 +1412,12 @@ rm -fr %{buildroot}
# on RHEL 5, thus we need to expand it here.
make install DESTDIR=%{?buildroot} SYSTEMD_UNIT_DIR=%{_unitdir}
-for i in domain-events/events-c dominfo domsuspend hellolibvirt openauth python xml/nwfilter systemtap
+for i in domain-events/events-c dominfo domsuspend hellolibvirt openauth xml/nwfilter systemtap
do
(cd examples/$i ; make clean ; rm -rf .deps .libs Makefile Makefile.in)
done
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
-rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la
-rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/libvirt/lock-driver/*.a
%if %{with_driver_modules}
@@ -2105,18 +2083,6 @@ exit 0
%doc examples/xml
%doc examples/systemtap
-%if %{with_python}
-%files python
-%defattr(-, root, root)
-
-%{_libdir}/python*/site-packages/libvirt.py*
-%{_libdir}/python*/site-packages/libvirt_qemu.py*
-%{_libdir}/python*/site-packages/libvirt_lxc.py*
-%{_libdir}/python*/site-packages/libvirtmod*
-%doc examples/python
-%doc examples/domain-events/events-python
-%endif
-
%changelog
* Mon Nov 4 2013 Daniel Veillard <veillard(a)redhat.com> - 1.1.4-1
- Add support for AArch64 architecture
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index 8f905cc..1547e03 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -217,14 +217,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
#endif
])
- dnl Needed to keep compile quiet on python 2.4
- save_WARN_CFLAGS=$WARN_CFLAGS
- WARN_CFLAGS=
- gl_WARN_ADD([-Wno-redundant-decls])
- WARN_PYTHON_CFLAGS=$WARN_CFLAGS
- AC_SUBST(WARN_PYTHON_CFLAGS)
- WARN_CFLAGS=$save_WARN_CFLAGS
-
if test "$gl_cv_warn_c__Wlogical_op" = yes &&
test "$lv_cv_gcc_wlogical_op_broken" = yes; then
AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP], 1,
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
index e13407e..1734a48 100644
--- a/mingw-libvirt.spec.in
+++ b/mingw-libvirt.spec.in
@@ -146,7 +146,6 @@ autoreconf -if
--without-sasl \
--without-avahi \
--without-polkit \
- --without-python \
--without-libvirtd \
--without-uml \
%{?_without_phyp} \
diff --git a/python/Makefile.am b/python/Makefile.am
deleted file mode 100644
index c9c2a8b..0000000
--- a/python/Makefile.am
+++ /dev/null
@@ -1,173 +0,0 @@
-# Makefile for libvirt python library
-
-## Copyright (C) 2005-2013 Red Hat, Inc.
-##
-## 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, see
-## <http://www.gnu.org/licenses/>.
-
-INCLUDES = \
- $(PYTHON_INCLUDES) \
- -I$(top_builddir)/gnulib/lib \
- -I$(top_srcdir)/gnulib/lib \
- -I$(top_srcdir) \
- -I$(top_builddir)/src \
- -I$(top_srcdir)/src \
- -I$(top_srcdir)/src/util \
- -I$(top_builddir)/include \
- -I$(top_srcdir)/include \
- $(GETTEXT_CPPFLAGS)
-
-AM_CFLAGS = $(WARN_CFLAGS)
-AM_LDFLAGS = \
- $(RELRO_LDFLAGS) \
- $(NO_INDIRECT_LDFLAGS) \
- $(NULL)
-
-CLASSES_EXTRA = \
- libvirt-override-virConnect.py \
- libvirt-override-virDomain.py \
- libvirt-override-virDomainSnapshot.py \
- libvirt-override-virStoragePool.py \
- libvirt-override-virStream.py
-
-EXTRA_DIST = \
- generator.py \
- typewrappers.c \
- typewrappers.h \
- libvirt-override.c \
- libvirt-override.py \
- libvirt-override-api.xml \
- libvirt-lxc-override.c \
- libvirt-lxc-override-api.xml \
- libvirt-qemu-override.c \
- libvirt-qemu-override-api.xml \
- sanitytest.py \
- $(CLASSES_EXTRA) \
- $(DOCS)
-
-if WITH_PYTHON
-mylibs = \
- $(top_builddir)/src/libvirt.la \
- $(top_builddir)/gnulib/lib/libgnu.la
-myqemulibs = \
- $(top_builddir)/src/libvirt-qemu.la \
- $(top_builddir)/gnulib/lib/libgnu.la
-mylxclibs = \
- $(top_builddir)/src/libvirt-lxc.la \
- $(top_builddir)/gnulib/lib/libgnu.la
-
-all-local: libvirt.py libvirt_qemu.py libvirt_lxc.py
-
-pyexec_LTLIBRARIES = libvirtmod.la libvirtmod_qemu.la libvirtmod_lxc.la
-
-libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c
-nodist_libvirtmod_la_SOURCES = libvirt.c libvirt.h
-# Python <= 2.4 header files contain a redundant decl, hence we
-# need extra flags here
-libvirtmod_la_CFLAGS = $(WARN_CFLAGS) $(WARN_PYTHON_CFLAGS)
-
-libvirtmod_la_LDFLAGS = -module -avoid-version -shared \
- -L$(top_builddir)/src/.libs \
- $(AM_LDFLAGS) \
- $(CYGWIN_EXTRA_LDFLAGS)
-libvirtmod_la_LIBADD = $(mylibs) \
- $(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
-
-libvirtmod_qemu_la_SOURCES = libvirt-qemu-override.c typewrappers.c
-nodist_libvirtmod_qemu_la_SOURCES = libvirt-qemu.c libvirt-qemu.h
-# Python <= 2.4 header files contain a redundant decl, hence we
-# need extra flags here
-libvirtmod_qemu_la_CFLAGS = $(WARN_PYTHON_CFLAGS)
-
-libvirtmod_qemu_la_LDFLAGS = -module -avoid-version -shared \
- -L$(top_builddir)/src/.libs \
- $(AM_LDFLAGS) \
- $(CYGWIN_EXTRA_LDFLAGS)
-libvirtmod_qemu_la_LIBADD = $(myqemulibs) \
- $(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
-
-libvirtmod_lxc_la_SOURCES = libvirt-lxc-override.c typewrappers.c
-nodist_libvirtmod_lxc_la_SOURCES = libvirt-lxc.c libvirt-lxc.h
-# Python <= 2.4 header files contain a redundant decl, hence we
-# need extra flags here
-libvirtmod_lxc_la_CFLAGS = $(WARN_PYTHON_CFLAGS)
-
-libvirtmod_lxc_la_LDFLAGS = -module -avoid-version -shared \
- -L$(top_builddir)/src/.libs \
- $(AM_LDFLAGS) \
- $(CYGWIN_EXTRA_LDFLAGS)
-libvirtmod_lxc_la_LIBADD = $(mylxclibs) \
- $(CYGWIN_EXTRA_LIBADD) $(CYGWIN_EXTRA_PYTHON_LIBADD)
-
-GENERATE = generator.py
-API_DESC = $(top_srcdir)/docs/libvirt-api.xml \
- $(srcdir)/libvirt-override-api.xml
-GENERATED= libvirt-export.c \
- libvirt.c \
- libvirt.h \
- libvirt.py
-
-QEMU_API_DESC = $(top_srcdir)/docs/libvirt-qemu-api.xml \
- $(srcdir)/libvirt-qemu-override-api.xml
-QEMU_GENERATED= libvirt-qemu-export.c \
- libvirt-qemu.c \
- libvirt-qemu.h \
- libvirt_qemu.py
-
-LXC_API_DESC = $(top_srcdir)/docs/libvirt-lxc-api.xml \
- $(srcdir)/libvirt-lxc-override-api.xml
-LXC_GENERATED= libvirt-lxc-export.c \
- libvirt-lxc.c \
- libvirt-lxc.h \
- libvirt_lxc.py
-
-$(GENERATE).stamp: $(srcdir)/$(GENERATE) \
- $(API_DESC) \
- $(QEMU_API_DESC) \
- $(LXC_API_DESC) \
- $(CLASSES_EXTRA)
- $(AM_V_GEN)$(PYTHON) $(srcdir)/$(GENERATE) $(PYTHON) && \
- touch $@
-
-$(GENERATED) $(QEMU_GENERATED) $(LXC_GENERATED): $(GENERATE).stamp
-
-$(libvirtmod_la_OBJECTS): $(GENERATED)
-$(libvirtmod_qemu_la_OBJECTS): $(QEMU_GENERATED)
-$(libvirtmod_lxc_la_OBJECTS): $(LXC_GENERATED)
-
-check-local:
- $(AM_V_GEN)../run $(PYTHON) $(srcdir)/sanitytest.py
-
-install-data-local:
- $(mkinstalldirs) $(DESTDIR)$(pyexecdir)
- $(INSTALL) -m 0644 libvirt.py $(DESTDIR)$(pyexecdir)
- $(INSTALL) -m 0644 libvirt_lxc.py $(DESTDIR)$(pyexecdir)
- $(INSTALL) -m 0644 libvirt_qemu.py $(DESTDIR)$(pyexecdir)
-
-uninstall-local:
- rm -f $(DESTDIR)$(pyexecdir)/libvirt.py
- rm -f $(DESTDIR)$(pyexecdir)/libvirt_lxc.py
- rm -f $(DESTDIR)$(pyexecdir)/libvirt_qemu.py
-
-CLEANFILES= $(GENERATED) $(QEMU_GENERATED) $(LXC_GENERATED) $(GENERATE).stamp \
- *.pyc
-
-else ! WITH_PYTHON
-all:
-endif ! WITH_PYTHON
-
-dummy:
-
-tests test: all dummy
- -@(cd tests && $(MAKE) MAKEFLAGS+=--silent tests)
diff --git a/python/README b/python/README
deleted file mode 100644
index 02d4cc4..0000000
--- a/python/README
+++ /dev/null
@@ -1,27 +0,0 @@
- libvirt Python Bindings README
- ==============================
-
-Most of the libvirt python binding code is automatically generated
-using the script generator.py, and the API description from
-docs/libvirt-api.xml
-
-
-Manually written files:
-
- - libvirt-override.c: methods where the C binding needs to be hand crafted
- - libvirt-override.py: global methods where the C and python bindings have different args
- - libvirt-override-api.xml: methods where the auto-extracted API docs are not
- suitable for python auto-generator. Overriding this if the method is going
- into libvirt-override.c, but we still want auto-generated libvirt-override.py
- - libvirt-override-virConnect.py: virConnect class methods
- - typewrappers.h,.c: Python object wrappers for each libvirt C object
-
-
-Auto-generated files:
-
- - libvirt.py: The main python binding. Comprises auto-generated code, along
- with contents from libvirt-override.py and libvirt-override-virConnect.py
- - libvirt.c, libvirt.h: The C glue layer for the python binding. Comprises
- auto-generated code, along with libvirt-override.c
- - libvirt-export.c: List of auto-generated C methods, included into
- the libvirt-override.c method table
diff --git a/python/generator.py b/python/generator.py
deleted file mode 100755
index 20f5dff..0000000
--- a/python/generator.py
+++ /dev/null
@@ -1,1976 +0,0 @@
-#!/usr/bin/python -u
-#
-# generate python wrappers from the XML API description
-#
-
-functions = {}
-lxc_functions = {}
-qemu_functions = {}
-enums = {} # { enumType: { enumConstant: enumValue } }
-lxc_enums = {} # { enumType: { enumConstant: enumValue } }
-qemu_enums = {} # { enumType: { enumConstant: enumValue } }
-
-import os
-import sys
-import string
-import re
-
-quiet=True
-
-if __name__ == "__main__":
- # launched as a script
- srcPref = os.path.dirname(sys.argv[0])
- if len(sys.argv) > 1:
- python = sys.argv[1]
- else:
- print "Python binary not specified"
- sys.exit(1)
-else:
- # imported
- srcPref = os.path.dirname(__file__)
-
-#######################################################################
-#
-# That part if purely the API acquisition phase from the
-# libvirt API description
-#
-#######################################################################
-import os
-import xml.sax
-
-debug = 0
-
-def getparser():
- # Attach parser to an unmarshalling object. return both objects.
- target = docParser()
- parser = xml.sax.make_parser()
- parser.setContentHandler(target)
- return parser, target
-
-class docParser(xml.sax.handler.ContentHandler):
- def __init__(self):
- self._methodname = None
- self._data = []
- self.in_function = 0
-
- self.startElement = self.start
- self.endElement = self.end
- self.characters = self.data
-
- def close(self):
- if debug:
- print "close"
-
- def getmethodname(self):
- return self._methodname
-
- def data(self, text):
- if debug:
- print "data %s" % text
- self._data.append(text)
-
- def cdata(self, text):
- if debug:
- print "data %s" % text
- self._data.append(text)
-
- def start(self, tag, attrs):
- if debug:
- print "start %s, %s" % (tag, attrs)
- if tag == 'function':
- self._data = []
- self.in_function = 1
- self.function = None
- self.function_cond = None
- self.function_args = []
- self.function_descr = None
- self.function_return = None
- self.function_file = None
- self.function_module= None
- if attrs.has_key('name'):
- self.function = attrs['name']
- if attrs.has_key('file'):
- self.function_file = attrs['file']
- if attrs.has_key('module'):
- self.function_module= attrs['module']
- elif tag == 'cond':
- self._data = []
- elif tag == 'info':
- self._data = []
- elif tag == 'arg':
- if self.in_function == 1:
- self.function_arg_name = None
- self.function_arg_type = None
- self.function_arg_info = None
- if attrs.has_key('name'):
- self.function_arg_name = attrs['name']
- if self.function_arg_name == 'from':
- self.function_arg_name = 'frm'
- if attrs.has_key('type'):
- self.function_arg_type = attrs['type']
- if attrs.has_key('info'):
- self.function_arg_info = attrs['info']
- elif tag == 'return':
- if self.in_function == 1:
- self.function_return_type = None
- self.function_return_info = None
- self.function_return_field = None
- if attrs.has_key('type'):
- self.function_return_type = attrs['type']
- if attrs.has_key('info'):
- self.function_return_info = attrs['info']
- if attrs.has_key('field'):
- self.function_return_field = attrs['field']
- elif tag == 'enum':
- # enums come from header files, hence virterror.h
- if (attrs['file'] == "libvirt" or
- attrs['file'] == "virterror"):
- enum(attrs['type'],attrs['name'],attrs['value'])
- elif attrs['file'] == "libvirt-lxc":
- lxc_enum(attrs['type'],attrs['name'],attrs['value'])
- elif attrs['file'] == "libvirt-qemu":
- qemu_enum(attrs['type'],attrs['name'],attrs['value'])
-
- def end(self, tag):
- if debug:
- print "end %s" % tag
- if tag == 'function':
- # fuctions come from source files, hence 'virerror.c'
- if self.function is not None:
- if (self.function_module == "libvirt" or
- self.function_module == "virevent" or
- self.function_module == "virerror"):
- function(self.function, self.function_descr,
- self.function_return, self.function_args,
- self.function_file, self.function_module,
- self.function_cond)
- elif self.function_module == "libvirt-lxc":
- lxc_function(self.function, self.function_descr,
- self.function_return, self.function_args,
- self.function_file, self.function_module,
- self.function_cond)
- elif self.function_module == "libvirt-qemu":
- qemu_function(self.function, self.function_descr,
- self.function_return, self.function_args,
- self.function_file, self.function_module,
- self.function_cond)
- elif self.function_file == "python":
- function(self.function, self.function_descr,
- self.function_return, self.function_args,
- self.function_file, self.function_module,
- self.function_cond)
- elif self.function_file == "python-lxc":
- lxc_function(self.function, self.function_descr,
- self.function_return, self.function_args,
- self.function_file, self.function_module,
- self.function_cond)
- elif self.function_file == "python-qemu":
- qemu_function(self.function, self.function_descr,
- self.function_return, self.function_args,
- self.function_file, self.function_module,
- self.function_cond)
- self.in_function = 0
- elif tag == 'arg':
- if self.in_function == 1:
- self.function_args.append([self.function_arg_name,
- self.function_arg_type,
- self.function_arg_info])
- elif tag == 'return':
- if self.in_function == 1:
- self.function_return = [self.function_return_type,
- self.function_return_info,
- self.function_return_field]
- elif tag == 'info':
- str = ''
- for c in self._data:
- str = str + c
- if self.in_function == 1:
- self.function_descr = str
- elif tag == 'cond':
- str = ''
- for c in self._data:
- str = str + c
- if self.in_function == 1:
- self.function_cond = str
-
-
-def function(name, desc, ret, args, file, module, cond):
- functions[name] = (desc, ret, args, file, module, cond)
-
-def qemu_function(name, desc, ret, args, file, module, cond):
- qemu_functions[name] = (desc, ret, args, file, module, cond)
-
-def lxc_function(name, desc, ret, args, file, module, cond):
- lxc_functions[name] = (desc, ret, args, file, module, cond)
-
-def enum(type, name, value):
- if not enums.has_key(type):
- enums[type] = {}
- if value == 'VIR_TYPED_PARAM_INT':
- value = 1
- elif value == 'VIR_TYPED_PARAM_UINT':
- value = 2
- elif value == 'VIR_TYPED_PARAM_LLONG':
- value = 3
- elif value == 'VIR_TYPED_PARAM_ULLONG':
- value = 4
- elif value == 'VIR_TYPED_PARAM_DOUBLE':
- value = 5
- elif value == 'VIR_TYPED_PARAM_BOOLEAN':
- value = 6
- elif value == 'VIR_DOMAIN_AFFECT_CURRENT':
- value = 0
- elif value == 'VIR_DOMAIN_AFFECT_LIVE':
- value = 1
- elif value == 'VIR_DOMAIN_AFFECT_CONFIG':
- value = 2
- if name[-5:] != '_LAST':
- enums[type][name] = value
-
-def lxc_enum(type, name, value):
- if not lxc_enums.has_key(type):
- lxc_enums[type] = {}
- lxc_enums[type][name] = value
-
-def qemu_enum(type, name, value):
- if not qemu_enums.has_key(type):
- qemu_enums[type] = {}
- qemu_enums[type][name] = value
-
-
-#######################################################################
-#
-# Some filtering rukes to drop functions/types which should not
-# be exposed as-is on the Python interface
-#
-#######################################################################
-
-functions_failed = []
-lxc_functions_failed = []
-qemu_functions_failed = []
-functions_skipped = [
- "virConnectListDomains",
-]
-lxc_functions_skipped = []
-qemu_functions_skipped = []
-
-skipped_modules = {
-}
-
-skipped_types = {
-# 'int *': "usually a return type",
- 'virConnectDomainEventCallback': "No function types in python",
- 'virConnectDomainEventGenericCallback': "No function types in python",
- 'virConnectDomainEventRTCChangeCallback': "No function types in python",
- 'virConnectDomainEventWatchdogCallback': "No function types in python",
- 'virConnectDomainEventIOErrorCallback': "No function types in python",
- 'virConnectDomainEventGraphicsCallback': "No function types in python",
- 'virStreamEventCallback': "No function types in python",
- 'virEventHandleCallback': "No function types in python",
- 'virEventTimeoutCallback': "No function types in python",
- 'virDomainBlockJobInfoPtr': "Not implemented yet",
-}
-
-#######################################################################
-#
-# Table of remapping to/from the python type or class to the C
-# counterpart.
-#
-#######################################################################
-
-py_types = {
- 'void': (None, None, None, None),
- 'int': ('i', None, "int", "int"),
- 'long': ('l', None, "long", "long"),
- 'double': ('d', None, "double", "double"),
- 'unsigned int': ('i', None, "int", "int"),
- 'unsigned long': ('l', None, "long", "long"),
- 'long long': ('L', None, "longlong", "long long"),
- 'unsigned long long': ('L', None, "longlong", "long long"),
- 'unsigned char *': ('z', None, "charPtr", "char *"),
- 'char *': ('z', None, "charPtr", "char *"),
- 'const char *': ('z', None, "constcharPtr", "const char *"),
- 'size_t': ('n', None, "size_t", "size_t"),
-
- 'virDomainPtr': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
- 'virDomain *': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
- 'const virDomain *': ('O', "virDomain", "virDomainPtr", "virDomainPtr"),
-
- 'virNetworkPtr': ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
- 'virNetwork *': ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
- 'const virNetwork *': ('O', "virNetwork", "virNetworkPtr", "virNetworkPtr"),
-
- 'virInterfacePtr': ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
- 'virInterface *': ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
- 'const virInterface *': ('O', "virInterface", "virInterfacePtr", "virInterfacePtr"),
-
- 'virStoragePoolPtr': ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
- 'virStoragePool *': ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
- 'const virStoragePool *': ('O', "virStoragePool", "virStoragePoolPtr", "virStoragePoolPtr"),
-
- 'virStorageVolPtr': ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
- 'virStorageVol *': ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
- 'const virStorageVol *': ('O', "virStorageVol", "virStorageVolPtr", "virStorageVolPtr"),
-
- 'virConnectPtr': ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
- 'virConnect *': ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
- 'const virConnect *': ('O', "virConnect", "virConnectPtr", "virConnectPtr"),
-
- 'virNodeDevicePtr': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
- 'virNodeDevice *': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
- 'const virNodeDevice *': ('O', "virNodeDevice", "virNodeDevicePtr", "virNodeDevicePtr"),
-
- 'virSecretPtr': ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
- 'virSecret *': ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
- 'const virSecret *': ('O', "virSecret", "virSecretPtr", "virSecretPtr"),
-
- 'virNWFilterPtr': ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
- 'virNWFilter *': ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
- 'const virNWFilter *': ('O', "virNWFilter", "virNWFilterPtr", "virNWFilterPtr"),
-
- 'virStreamPtr': ('O', "virStream", "virStreamPtr", "virStreamPtr"),
- 'virStream *': ('O', "virStream", "virStreamPtr", "virStreamPtr"),
- 'const virStream *': ('O', "virStream", "virStreamPtr", "virStreamPtr"),
-
- 'virDomainSnapshotPtr': ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
- 'virDomainSnapshot *': ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
- 'const virDomainSnapshot *': ('O', "virDomainSnapshot", "virDomainSnapshotPtr", "virDomainSnapshotPtr"),
-}
-
-py_return_types = {
-}
-
-unknown_types = {}
-
-foreign_encoding_args = (
-)
-
-#######################################################################
-#
-# This part writes the C <-> Python stubs libvirt.[ch] and
-# the table libvirt-export.c to add when registrering the Python module
-#
-#######################################################################
-
-# Class methods which are written by hand in libvirt.c but the Python-level
-# code is still automatically generated (so they are not in skip_function()).
-skip_impl = (
- 'virConnectGetVersion',
- 'virConnectGetLibVersion',
- 'virConnectListDomainsID',
- 'virConnectListDefinedDomains',
- 'virConnectListNetworks',
- 'virConnectListDefinedNetworks',
- 'virConnectListSecrets',
- 'virConnectListInterfaces',
- 'virConnectListStoragePools',
- 'virConnectListDefinedStoragePools',
- 'virConnectListStorageVols',
- 'virConnectListDefinedStorageVols',
- 'virConnectListDefinedInterfaces',
- 'virConnectListNWFilters',
- 'virDomainSnapshotListNames',
- 'virDomainSnapshotListChildrenNames',
- 'virConnGetLastError',
- 'virGetLastError',
- 'virDomainGetInfo',
- 'virDomainGetState',
- 'virDomainGetControlInfo',
- 'virDomainGetBlockInfo',
- 'virDomainGetJobInfo',
- 'virDomainGetJobStats',
- 'virNodeGetInfo',
- 'virDomainGetUUID',
- 'virDomainGetUUIDString',
- 'virDomainLookupByUUID',
- 'virNetworkGetUUID',
- 'virNetworkGetUUIDString',
- 'virNetworkLookupByUUID',
- 'virDomainGetAutostart',
- 'virNetworkGetAutostart',
- 'virDomainBlockStats',
- 'virDomainInterfaceStats',
- 'virDomainMemoryStats',
- 'virNodeGetCellsFreeMemory',
- 'virDomainGetSchedulerType',
- 'virDomainGetSchedulerParameters',
- 'virDomainGetSchedulerParametersFlags',
- 'virDomainSetSchedulerParameters',
- 'virDomainSetSchedulerParametersFlags',
- 'virDomainSetBlkioParameters',
- 'virDomainGetBlkioParameters',
- 'virDomainSetMemoryParameters',
- 'virDomainGetMemoryParameters',
- 'virDomainSetNumaParameters',
- 'virDomainGetNumaParameters',
- 'virDomainGetVcpus',
- 'virDomainPinVcpu',
- 'virDomainPinVcpuFlags',
- 'virDomainGetVcpuPinInfo',
- 'virDomainGetEmulatorPinInfo',
- 'virDomainPinEmulator',
- 'virSecretGetValue',
- 'virSecretSetValue',
- 'virSecretGetUUID',
- 'virSecretGetUUIDString',
- 'virSecretLookupByUUID',
- 'virNWFilterGetUUID',
- 'virNWFilterGetUUIDString',
- 'virNWFilterLookupByUUID',
- 'virStoragePoolGetUUID',
- 'virStoragePoolGetUUIDString',
- 'virStoragePoolLookupByUUID',
- 'virStoragePoolGetInfo',
- 'virStorageVolGetInfo',
- 'virStoragePoolGetAutostart',
- 'virStoragePoolListVolumes',
- 'virDomainBlockPeek',
- 'virDomainMemoryPeek',
- 'virEventRegisterImpl',
- 'virNodeListDevices',
- 'virNodeDeviceListCaps',
- 'virConnectBaselineCPU',
- 'virDomainRevertToSnapshot',
- 'virDomainSendKey',
- 'virNodeGetCPUStats',
- 'virNodeGetMemoryStats',
- 'virDomainGetBlockJobInfo',
- 'virDomainMigrateGetCompressionCache',
- 'virDomainMigrateGetMaxSpeed',
- 'virDomainBlockStatsFlags',
- 'virDomainSetBlockIoTune',
- 'virDomainGetBlockIoTune',
- 'virDomainSetInterfaceParameters',
- 'virDomainGetInterfaceParameters',
- 'virDomainGetCPUStats',
- 'virDomainGetDiskErrors',
- 'virNodeGetMemoryParameters',
- 'virNodeSetMemoryParameters',
- 'virNodeGetCPUMap',
- 'virDomainMigrate3',
- 'virDomainMigrateToURI3',
- 'virConnectGetCPUModelNames',
-)
-
-lxc_skip_impl = (
- 'virDomainLxcOpenNamespace',
-)
-
-qemu_skip_impl = (
- 'virDomainQemuMonitorCommand',
- 'virDomainQemuAgentCommand',
-)
-
-
-# These are functions which the generator skips completly - no python
-# or C code is generated. Generally should not be used for any more
-# functions than those already listed
-skip_function = (
- 'virConnectListDomains', # Python API is called virConectListDomainsID for unknown reasons
- 'virConnSetErrorFunc', # Not used in Python API XXX is this a bug ?
- 'virResetError', # Not used in Python API XXX is this a bug ?
- 'virGetVersion', # Python C code is manually written
- 'virSetErrorFunc', # Python API is called virRegisterErrorHandler for unknown reasons
- 'virConnCopyLastError', # Python API is called virConnGetLastError instead
- 'virCopyLastError', # Python API is called virGetLastError instead
- 'virConnectOpenAuth', # Python C code is manually written
- 'virDefaultErrorFunc', # Python virErrorFuncHandler impl calls this from C
- 'virDomainGetSecurityLabel', # Needs investigation...
- 'virDomainGetSecurityLabelList', # Needs investigation...
- 'virNodeGetSecurityModel', # Needs investigation...
- 'virConnectDomainEventRegister', # overridden in virConnect.py
- 'virConnectDomainEventDeregister', # overridden in virConnect.py
- 'virConnectDomainEventRegisterAny', # overridden in virConnect.py
- 'virConnectDomainEventDeregisterAny', # overridden in virConnect.py
- 'virSaveLastError', # We have our own python error wrapper
- 'virFreeError', # Only needed if we use virSaveLastError
- 'virConnectListAllDomains', # overridden in virConnect.py
- 'virDomainListAllSnapshots', # overridden in virDomain.py
- 'virDomainSnapshotListAllChildren', # overridden in virDomainSnapshot.py
- 'virConnectListAllStoragePools', # overridden in virConnect.py
- 'virStoragePoolListAllVolumes', # overridden in virStoragePool.py
- 'virConnectListAllNetworks', # overridden in virConnect.py
- 'virConnectListAllInterfaces', # overridden in virConnect.py
- 'virConnectListAllNodeDevices', # overridden in virConnect.py
- 'virConnectListAllNWFilters', # overridden in virConnect.py
- 'virConnectListAllSecrets', # overridden in virConnect.py
-
- 'virStreamRecvAll', # Pure python libvirt-override-virStream.py
- 'virStreamSendAll', # Pure python libvirt-override-virStream.py
- 'virStreamRecv', # overridden in libvirt-override-virStream.py
- 'virStreamSend', # overridden in libvirt-override-virStream.py
-
- 'virConnectUnregisterCloseCallback', # overridden in virConnect.py
- 'virConnectRegisterCloseCallback', # overridden in virConnect.py
-
- 'virDomainCreateXMLWithFiles', # overridden in virConnect.py
- 'virDomainCreateWithFiles', # overridden in virDomain.py
-
- # 'Ref' functions have no use for bindings users.
- "virConnectRef",
- "virDomainRef",
- "virInterfaceRef",
- "virNetworkRef",
- "virNodeDeviceRef",
- "virSecretRef",
- "virNWFilterRef",
- "virStoragePoolRef",
- "virStorageVolRef",
- 'virStreamRef',
-
- # This functions shouldn't be called via the bindings (and even the docs
- # contain an explicit warning to that effect). The equivalent should be
- # implemented in pure python for each class
- "virDomainGetConnect",
- "virInterfaceGetConnect",
- "virNetworkGetConnect",
- "virSecretGetConnect",
- "virNWFilterGetConnect",
- "virStoragePoolGetConnect",
- "virStorageVolGetConnect",
- "virDomainSnapshotGetConnect",
- "virDomainSnapshotGetDomain",
-
- # only useful in C code, python code uses dict for typed parameters
- "virTypedParamsAddBoolean",
- "virTypedParamsAddDouble",
- "virTypedParamsAddFromString",
- "virTypedParamsAddInt",
- "virTypedParamsAddLLong",
- "virTypedParamsAddString",
- "virTypedParamsAddUInt",
- "virTypedParamsAddULLong",
- "virTypedParamsClear",
- "virTypedParamsFree",
- "virTypedParamsGet",
- "virTypedParamsGetBoolean",
- "virTypedParamsGetDouble",
- "virTypedParamsGetInt",
- "virTypedParamsGetLLong",
- "virTypedParamsGetString",
- "virTypedParamsGetUInt",
- "virTypedParamsGetULLong",
-)
-
-lxc_skip_function = (
- "virDomainLxcEnterNamespace",
- "virDomainLxcEnterSecurityLabel",
-)
-qemu_skip_function = (
- #"virDomainQemuAttach",
-)
-
-# Generate C code, but skip python impl
-function_skip_python_impl = (
- "virStreamFree", # Needed in custom virStream __del__, but free shouldn't
- # be exposed in bindings
-)
-
-lxc_function_skip_python_impl = ()
-qemu_function_skip_python_impl = ()
-
-function_skip_index_one = (
- "virDomainRevertToSnapshot",
-)
-
-def print_function_wrapper(module, name, output, export, include):
- global py_types
- global unknown_types
- global functions
- global lxc_functions
- global qemu_functions
- global skipped_modules
- global function_skip_python_impl
-
- try:
- if module == "libvirt":
- (desc, ret, args, file, mod, cond) = functions[name]
- if module == "libvirt-lxc":
- (desc, ret, args, file, mod, cond) = lxc_functions[name]
- if module == "libvirt-qemu":
- (desc, ret, args, file, mod, cond) = qemu_functions[name]
- except:
- print "failed to get function %s infos" % name
- return
-
- if skipped_modules.has_key(module):
- return 0
-
- if module == "libvirt":
- if name in skip_function:
- return 0
- if name in skip_impl:
- # Don't delete the function entry in the caller.
- return 1
- elif module == "libvirt-lxc":
- if name in lxc_skip_function:
- return 0
- if name in lxc_skip_impl:
- # Don't delete the function entry in the caller.
- return 1
- elif module == "libvirt-qemu":
- if name in qemu_skip_function:
- return 0
- if name in qemu_skip_impl:
- # Don't delete the function entry in the caller.
- return 1
-
- c_call = ""
- format=""
- format_args=""
- c_args=""
- c_return=""
- c_convert=""
- num_bufs=0
- for arg in args:
- # This should be correct
- if arg[1][0:6] == "const ":
- arg[1] = arg[1][6:]
- c_args = c_args + " %s %s;\n" % (arg[1], arg[0])
- if py_types.has_key(arg[1]):
- (f, t, n, c) = py_types[arg[1]]
- if (f == 'z') and (name in foreign_encoding_args) and (num_bufs == 0):
- f = 't#'
- if f is not None:
- format = format + f
- if t is not None:
- format_args = format_args + ", &pyobj_%s" % (arg[0])
- c_args = c_args + " PyObject *pyobj_%s;\n" % (arg[0])
- c_convert = c_convert + \
- " %s = (%s) Py%s_Get(pyobj_%s);\n" % (arg[0],
- arg[1], t, arg[0])
- else:
- format_args = format_args + ", &%s" % (arg[0])
- if f == 't#':
- format_args = format_args + ", &py_buffsize%d" % num_bufs
- c_args = c_args + " int py_buffsize%d;\n" % num_bufs
- num_bufs = num_bufs + 1
- if c_call != "":
- c_call = c_call + ", "
- c_call = c_call + "%s" % (arg[0])
- else:
- if skipped_types.has_key(arg[1]):
- return 0
- if unknown_types.has_key(arg[1]):
- lst = unknown_types[arg[1]]
- lst.append(name)
- else:
- unknown_types[arg[1]] = [name]
- return -1
- if format != "":
- format = format + ":%s" % (name)
-
- if ret[0] == 'void':
- if file == "python_accessor":
- if args[1][1] == "char *":
- c_call = "\n VIR_FREE(%s->%s);\n" % (
- args[0][0], args[1][0], args[0][0], args[1][0])
- c_call = c_call + " %s->%s = (%s)strdup((const xmlChar *)%s);\n" % (args[0][0],
- args[1][0], args[1][1], args[1][0])
- else:
- c_call = "\n %s->%s = %s;\n" % (args[0][0], args[1][0],
- args[1][0])
- else:
- c_call = "\n %s(%s);\n" % (name, c_call)
- ret_convert = " Py_INCREF(Py_None);\n return Py_None;\n"
- elif py_types.has_key(ret[0]):
- (f, t, n, c) = py_types[ret[0]]
- c_return = " %s c_retval;\n" % (ret[0])
- if file == "python_accessor" and ret[2] is not None:
- c_call = "\n c_retval = %s->%s;\n" % (args[0][0], ret[2])
- else:
- c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
- ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
- ret_convert = ret_convert + " return py_retval;\n"
- elif py_return_types.has_key(ret[0]):
- (f, t, n, c) = py_return_types[ret[0]]
- c_return = " %s c_retval;\n" % (ret[0])
- c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
- ret_convert = " py_retval = libvirt_%sWrap((%s) c_retval);\n" % (n,c)
- ret_convert = ret_convert + " return py_retval;\n"
- else:
- if skipped_types.has_key(ret[0]):
- return 0
- if unknown_types.has_key(ret[0]):
- lst = unknown_types[ret[0]]
- lst.append(name)
- else:
- unknown_types[ret[0]] = [name]
- return -1
-
- if cond is not None and cond != "":
- include.write("#if %s\n" % cond)
- export.write("#if %s\n" % cond)
- output.write("#if %s\n" % cond)
-
- include.write("PyObject * ")
- if module == "libvirt":
- include.write("libvirt_%s(PyObject *self, PyObject *args);\n" % (name))
- export.write(" { (char *)\"%s\", libvirt_%s, METH_VARARGS, NULL },\n" %
- (name, name))
- elif module == "libvirt-lxc":
- include.write("libvirt_lxc_%s(PyObject *self, PyObject *args);\n" % (name))
- export.write(" { (char *)\"%s\", libvirt_lxc_%s, METH_VARARGS, NULL },\n" %
- (name, name))
- elif module == "libvirt-qemu":
- include.write("libvirt_qemu_%s(PyObject *self, PyObject *args);\n" % (name))
- export.write(" { (char *)\"%s\", libvirt_qemu_%s, METH_VARARGS, NULL },\n" %
- (name, name))
-
- if file == "python":
- # Those have been manually generated
- if cond is not None and cond != "":
- include.write("#endif\n")
- export.write("#endif\n")
- output.write("#endif\n")
- return 1
- if file == "python_accessor" and ret[0] != "void" and ret[2] is None:
- # Those have been manually generated
- if cond is not None and cond != "":
- include.write("#endif\n")
- export.write("#endif\n")
- output.write("#endif\n")
- return 1
-
- output.write("PyObject *\n")
- if module == "libvirt":
- output.write("libvirt_%s(PyObject *self ATTRIBUTE_UNUSED," % (name))
- elif module == "libvirt-lxc":
- output.write("libvirt_lxc_%s(PyObject *self ATTRIBUTE_UNUSED," % (name))
- elif module == "libvirt-qemu":
- output.write("libvirt_qemu_%s(PyObject *self ATTRIBUTE_UNUSED," % (name))
- output.write(" PyObject *args")
- if format == "":
- output.write(" ATTRIBUTE_UNUSED")
- output.write(") {\n")
- if ret[0] != 'void':
- output.write(" PyObject *py_retval;\n")
- if c_return != "":
- output.write(c_return)
- if c_args != "":
- output.write(c_args)
- if format != "":
- output.write("\n if (!PyArg_ParseTuple(args, (char *)\"%s\"%s))\n" %
- (format, format_args))
- output.write(" return NULL;\n")
- if c_convert != "":
- output.write(c_convert + "\n")
-
- output.write(" LIBVIRT_BEGIN_ALLOW_THREADS;")
- output.write(c_call)
- output.write(" LIBVIRT_END_ALLOW_THREADS;\n")
- output.write(ret_convert)
- output.write("}\n\n")
- if cond is not None and cond != "":
- include.write("#endif /* %s */\n" % cond)
- export.write("#endif /* %s */\n" % cond)
- output.write("#endif /* %s */\n" % cond)
-
- if module == "libvirt":
- if name in function_skip_python_impl:
- return 0
- elif module == "libvirt-lxc":
- if name in lxc_function_skip_python_impl:
- return 0
- elif module == "libvirt-qemu":
- if name in qemu_function_skip_python_impl:
- return 0
- return 1
-
-def buildStubs(module):
- global py_types
- global py_return_types
- global unknown_types
-
- if module not in ["libvirt", "libvirt-qemu", "libvirt-lxc"]:
- print "ERROR: Unknown module type: %s" % module
- return None
-
- if module == "libvirt":
- funcs = functions
- funcs_failed = functions_failed
- funcs_skipped = functions_skipped
- elif module == "libvirt-lxc":
- funcs = lxc_functions
- funcs_failed = lxc_functions_failed
- funcs_skipped = lxc_functions_skipped
- elif module == "libvirt-qemu":
- funcs = qemu_functions
- funcs_failed = qemu_functions_failed
- funcs_skipped = qemu_functions_skipped
-
- api_xml = "%s-api.xml" % module
-
- try:
- f = open(os.path.join(srcPref,api_xml))
- data = f.read()
- f.close()
- (parser, target) = getparser()
- parser.feed(data)
- parser.close()
- except IOError, msg:
- try:
- f = open(os.path.join(srcPref,"..","docs",api_xml))
- data = f.read()
- f.close()
- (parser, target) = getparser()
- parser.feed(data)
- parser.close()
- except IOError, msg:
- print file, ":", msg
- sys.exit(1)
-
- n = len(funcs.keys())
- if not quiet:
- print "Found %d functions in %s" % ((n), api_xml)
-
- override_api_xml = "%s-override-api.xml" % module
- py_types['pythonObject'] = ('O', "pythonObject", "pythonObject", "pythonObject")
-
- try:
- f = open(os.path.join(srcPref, override_api_xml))
- data = f.read()
- f.close()
- (parser, target) = getparser()
- parser.feed(data)
- parser.close()
- except IOError, msg:
- print file, ":", msg
-
- if not quiet:
- # XXX: This is not right, same function already in @functions
- # will be overwritten.
- print "Found %d functions in %s" % ((len(funcs.keys()) - n), override_api_xml)
- nb_wrap = 0
- failed = 0
- skipped = 0
-
- header_file = "%s.h" % module
- export_file = "%s-export.c" % module
- wrapper_file = "%s.c" % module
-
- include = open(header_file, "w")
- include.write("/* Generated */\n\n")
-
- export = open(export_file, "w")
- export.write("/* Generated */\n\n")
-
- wrapper = open(wrapper_file, "w")
- wrapper.write("/* Generated by generator.py */\n\n")
- wrapper.write("#include <config.h>\n")
- wrapper.write("#include <Python.h>\n")
- wrapper.write("#include <libvirt/" + module + ".h>\n")
- wrapper.write("#include \"typewrappers.h\"\n")
- wrapper.write("#include \"" + module + ".h\"\n\n")
-
- for function in funcs.keys():
- # Skip the functions which are not for the module
- ret = print_function_wrapper(module, function, wrapper, export, include)
- if ret < 0:
- failed = failed + 1
- funcs_failed.append(function)
- del funcs[function]
- if ret == 0:
- skipped = skipped + 1
- funcs_skipped.append(function)
- del funcs[function]
- if ret == 1:
- nb_wrap = nb_wrap + 1
- include.close()
- export.close()
- wrapper.close()
-
- if not quiet:
- print "Generated %d wrapper functions" % nb_wrap
-
- if unknown_types:
- print "Missing type converters: "
- for type in unknown_types.keys():
- print "%s:%d " % (type, len(unknown_types[type])),
-
- for f in funcs_failed:
- print "ERROR: failed %s" % f
-
- if failed > 0:
- return -1
- if len(unknown_types) > 0:
- return -1
- return 0
-
-#######################################################################
-#
-# This part writes part of the Python front-end classes based on
-# mapping rules between types and classes and also based on function
-# renaming to get consistent function names at the Python level
-#
-#######################################################################
-
-#
-# The type automatically remapped to generated classes
-#
-classes_type = {
- "virDomainPtr": ("._o", "virDomain(self,_obj=%s)", "virDomain"),
- "virDomain *": ("._o", "virDomain(self, _obj=%s)", "virDomain"),
- "virNetworkPtr": ("._o", "virNetwork(self, _obj=%s)", "virNetwork"),
- "virNetwork *": ("._o", "virNetwork(self, _obj=%s)", "virNetwork"),
- "virInterfacePtr": ("._o", "virInterface(self, _obj=%s)", "virInterface"),
- "virInterface *": ("._o", "virInterface(self, _obj=%s)", "virInterface"),
- "virStoragePoolPtr": ("._o", "virStoragePool(self, _obj=%s)", "virStoragePool"),
- "virStoragePool *": ("._o", "virStoragePool(self, _obj=%s)", "virStoragePool"),
- "virStorageVolPtr": ("._o", "virStorageVol(self, _obj=%s)", "virStorageVol"),
- "virStorageVol *": ("._o", "virStorageVol(self, _obj=%s)", "virStorageVol"),
- "virNodeDevicePtr": ("._o", "virNodeDevice(self, _obj=%s)", "virNodeDevice"),
- "virNodeDevice *": ("._o", "virNodeDevice(self, _obj=%s)", "virNodeDevice"),
- "virSecretPtr": ("._o", "virSecret(self, _obj=%s)", "virSecret"),
- "virSecret *": ("._o", "virSecret(self, _obj=%s)", "virSecret"),
- "virNWFilterPtr": ("._o", "virNWFilter(self, _obj=%s)", "virNWFilter"),
- "virNWFilter *": ("._o", "virNWFilter(self, _obj=%s)", "virNWFilter"),
- "virStreamPtr": ("._o", "virStream(self, _obj=%s)", "virStream"),
- "virStream *": ("._o", "virStream(self, _obj=%s)", "virStream"),
- "virConnectPtr": ("._o", "virConnect(_obj=%s)", "virConnect"),
- "virConnect *": ("._o", "virConnect(_obj=%s)", "virConnect"),
- "virDomainSnapshotPtr": ("._o", "virDomainSnapshot(self,_obj=%s)", "virDomainSnapshot"),
- "virDomainSnapshot *": ("._o", "virDomainSnapshot(self, _obj=%s)", "virDomainSnapshot"),
-}
-
-converter_type = {
-}
-
-primary_classes = ["virDomain", "virNetwork", "virInterface",
- "virStoragePool", "virStorageVol",
- "virConnect", "virNodeDevice", "virSecret",
- "virNWFilter", "virStream", "virDomainSnapshot"]
-
-classes_ancestor = {
-}
-
-classes_destructors = {
- "virDomain": "virDomainFree",
- "virNetwork": "virNetworkFree",
- "virInterface": "virInterfaceFree",
- "virStoragePool": "virStoragePoolFree",
- "virStorageVol": "virStorageVolFree",
- "virNodeDevice" : "virNodeDeviceFree",
- "virSecret": "virSecretFree",
- "virNWFilter": "virNWFilterFree",
- "virDomainSnapshot": "virDomainSnapshotFree",
- # We hand-craft __del__ for this one
- #"virStream": "virStreamFree",
-}
-
-class_skip_connect_impl = {
- "virConnect" : True,
-}
-
-class_domain_impl = {
- "virDomainSnapshot": True,
-}
-
-functions_noexcept = {
- 'virDomainGetID': True,
- 'virDomainGetName': True,
- 'virNetworkGetName': True,
- 'virInterfaceGetName': True,
- 'virStoragePoolGetName': True,
- 'virStorageVolGetName': True,
- 'virStorageVolGetkey': True,
- 'virNodeDeviceGetName': True,
- 'virNodeDeviceGetParent': True,
- 'virSecretGetUsageType': True,
- 'virSecretGetUsageID': True,
- 'virNWFilterGetName': True,
-}
-
-reference_keepers = {
-}
-
-function_classes = {}
-
-function_classes["None"] = []
-
-function_post = {}
-
-# Functions returning an integral type which need special rules to
-# check for errors and raise exceptions.
-functions_int_exception_test = {
- 'virDomainGetMaxMemory': "%s == 0",
-}
-functions_int_default_test = "%s == -1"
-
-def is_integral_type (name):
- return not re.search ("^(unsigned)? ?(int|long)$", name) is None
-
-def is_optional_arg(info):
- return re.search("^\(?\optional\)?", info) is not None
-# Functions returning lists which need special rules to check for errors
-# and raise exceptions.
-functions_list_exception_test = {
-}
-functions_list_default_test = "%s is None"
-
-def is_python_noninteger_type (name):
-
- return name[-1:] == "*"
-
-def nameFixup(name, classe, type, file):
- # avoid a desastrous clash
- listname = classe + "List"
- ll = len(listname)
- l = len(classe)
- if name[0:l] == listname:
- func = name[l:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:16] == "virNetworkDefine":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:19] == "virNetworkCreateXML":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:16] == "virNetworkLookup":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:18] == "virInterfaceDefine":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:21] == "virInterfaceCreateXML":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:18] == "virInterfaceLookup":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:15] == "virSecretDefine":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:15] == "virSecretLookup":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:17] == "virNWFilterDefine":
- func = name[3:]
- func = string.lower(func[0:3]) + func[3:]
- elif name[0:17] == "virNWFilterLookup":
- func = name[3:]
- func = string.lower(func[0:3]) + func[3:]
- elif name[0:20] == "virStoragePoolDefine":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:23] == "virStoragePoolCreateXML":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:20] == "virStoragePoolLookup":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:19] == "virStorageVolDefine":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:19] == "virStorageVolLookup":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:20] == "virDomainGetCPUStats":
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:12] == "virDomainGet":
- func = name[12:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:29] == "virDomainSnapshotLookupByName":
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:26] == "virDomainSnapshotListNames":
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:28] == "virDomainSnapshotNumChildren":
- func = name[17:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:20] == "virDomainSnapshotNum":
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:26] == "virDomainSnapshotCreateXML":
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:24] == "virDomainSnapshotCurrent":
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:17] == "virDomainSnapshot":
- func = name[17:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:9] == "virDomain":
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:13] == "virNetworkGet":
- func = name[13:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:10] == "virNetwork":
- func = name[10:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:15] == "virInterfaceGet":
- func = name[15:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:12] == "virInterface":
- func = name[12:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:12] == 'virSecretGet':
- func = name[12:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:9] == 'virSecret':
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:14] == 'virNWFilterGet':
- func = name[14:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:11] == 'virNWFilter':
- func = name[11:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:12] == 'virStreamNew':
- func = "newStream"
- elif name[0:9] == 'virStream':
- func = name[9:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:17] == "virStoragePoolGet":
- func = name[17:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:14] == "virStoragePool":
- func = name[14:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:16] == "virStorageVolGet":
- func = name[16:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:13] == "virStorageVol":
- func = name[13:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:13] == "virNodeDevice":
- if name[13:16] == "Get":
- func = string.lower(name[16]) + name[17:]
- elif name[13:19] == "Lookup" or name[13:19] == "Create":
- func = string.lower(name[3]) + name[4:]
- else:
- func = string.lower(name[13]) + name[14:]
- elif name[0:7] == "virNode":
- func = name[7:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:10] == "virConnect":
- func = name[10:]
- func = string.lower(func[0:1]) + func[1:]
- elif name[0:3] == "xml":
- func = name[3:]
- func = string.lower(func[0:1]) + func[1:]
- else:
- func = name
- if func == "iD":
- func = "ID"
- if func == "uUID":
- func = "UUID"
- if func == "uUIDString":
- func = "UUIDString"
- if func == "oSType":
- func = "OSType"
- if func == "xMLDesc":
- func = "XMLDesc"
- if func == "mACString":
- func = "MACString"
-
- return func
-
-
-def functionCompare(info1, info2):
- (index1, func1, name1, ret1, args1, file1, mod1) = info1
- (index2, func2, name2, ret2, args2, file2, mod2) = info2
- if file1 == file2:
- if func1 < func2:
- return -1
- if func1 > func2:
- return 1
- if file1 == "python_accessor":
- return -1
- if file2 == "python_accessor":
- return 1
- if file1 < file2:
- return -1
- if file1 > file2:
- return 1
- return 0
-
-def writeDoc(module, name, args, indent, output):
- if module == "libvirt":
- funcs = functions
- elif module == "libvirt-lxc":
- funcs = lxc_functions
- elif module == "libvirt-qemu":
- funcs = qemu_functions
- if funcs[name][0] is None or funcs[name][0] == "":
- return
- val = funcs[name][0]
- val = string.replace(val, "NULL", "None")
- output.write(indent)
- output.write('"""')
- i = string.find(val, "\n")
- while i >= 0:
- str = val[0:i+1]
- val = val[i+1:]
- output.write(str)
- i = string.find(val, "\n")
- output.write(indent)
- output.write(val)
- output.write(' """\n')
-
-def buildWrappers(module):
- global ctypes
- global py_types
- global py_return_types
- global unknown_types
- global functions
- global function_classes
- global classes_type
- global classes_list
- global primary_classes
- global classes_ancestor
- global converter_type
- global classes_destructors
- global functions_noexcept
-
- if not module == "libvirt":
- print "ERROR: Unknown module type: %s" % module
- return None
-
- for type in classes_type.keys():
- function_classes[classes_type[type][2]] = []
-
- #
- # Build the list of C types to look for ordered to start
- # with primary classes
- #
- ctypes = []
- classes_list = []
- ctypes_processed = {}
- classes_processed = {}
- for classe in primary_classes:
- classes_list.append(classe)
- classes_processed[classe] = ()
- for type in classes_type.keys():
- tinfo = classes_type[type]
- if tinfo[2] == classe:
- ctypes.append(type)
- ctypes_processed[type] = ()
- for type in classes_type.keys():
- if ctypes_processed.has_key(type):
- continue
- tinfo = classes_type[type]
- if not classes_processed.has_key(tinfo[2]):
- classes_list.append(tinfo[2])
- classes_processed[tinfo[2]] = ()
-
- ctypes.append(type)
- ctypes_processed[type] = ()
-
- for name in functions.keys():
- found = 0
- (desc, ret, args, file, mod, cond) = functions[name]
- for type in ctypes:
- classe = classes_type[type][2]
-
- if name[0:3] == "vir" and len(args) >= 1 and args[0][1] == type:
- found = 1
- func = nameFixup(name, classe, type, file)
- info = (0, func, name, ret, args, file, mod)
- function_classes[classe].append(info)
- elif name[0:3] == "vir" and len(args) >= 2 and args[1][1] == type \
- and file != "python_accessor" and not name in function_skip_index_one:
- found = 1
- func = nameFixup(name, classe, type, file)
- info = (1, func, name, ret, args, file, mod)
- function_classes[classe].append(info)
- if found == 1:
- continue
- func = nameFixup(name, "None", file, file)
- info = (0, func, name, ret, args, file, mod)
- function_classes['None'].append(info)
-
- classes_file = "%s.py" % module
- extra_file = os.path.join(srcPref, "%s-override.py" % module)
- extra = None
-
- classes = open(classes_file, "w")
-
- if os.path.exists(extra_file):
- extra = open(extra_file, "r")
- classes.write("#! " + python + " -i\n")
- classes.write("#\n")
- classes.write("# WARNING WARNING WARNING WARNING\n")
- classes.write("#\n")
- classes.write("# This file is automatically written by generator.py. Any changes\n")
- classes.write("# made here will be lost.\n")
- classes.write("#\n")
- classes.write("# To change the manually written methods edit " + module + "-override.py\n")
- classes.write("# To change the automatically written methods edit generator.py\n")
- classes.write("#\n")
- classes.write("# WARNING WARNING WARNING WARNING\n")
- classes.write("#\n")
- if extra is not None:
- classes.writelines(extra.readlines())
- classes.write("#\n")
- classes.write("# WARNING WARNING WARNING WARNING\n")
- classes.write("#\n")
- classes.write("# Automatically written part of python bindings for libvirt\n")
- classes.write("#\n")
- classes.write("# WARNING WARNING WARNING WARNING\n")
- if extra is not None:
- extra.close()
-
- if function_classes.has_key("None"):
- flist = function_classes["None"]
- flist.sort(functionCompare)
- oldfile = ""
- for info in flist:
- (index, func, name, ret, args, file, mod) = info
- if file != oldfile:
- classes.write("#\n# Functions from module %s\n#\n\n" % file)
- oldfile = file
- classes.write("def %s(" % func)
- n = 0
- for arg in args:
- if n != 0:
- classes.write(", ")
- classes.write("%s" % arg[0])
- if arg[0] == "flags" or is_optional_arg(arg[2]):
- if is_integral_type(arg[1]):
- classes.write("=0")
- else:
- classes.write("=None")
- n = n + 1
- classes.write("):\n")
- writeDoc(module, name, args, ' ', classes)
-
- for arg in args:
- if classes_type.has_key(arg[1]):
- classes.write(" if %s is None: %s__o = None\n" %
- (arg[0], arg[0]))
- classes.write(" else: %s__o = %s%s\n" %
- (arg[0], arg[0], classes_type[arg[1]][0]))
- if ret[0] != "void":
- classes.write(" ret = ")
- else:
- classes.write(" ")
- classes.write("libvirtmod.%s(" % name)
- n = 0
- for arg in args:
- if n != 0:
- classes.write(", ")
- classes.write("%s" % arg[0])
- if classes_type.has_key(arg[1]):
- classes.write("__o")
- n = n + 1
- classes.write(")\n")
-
- if ret[0] != "void":
- if classes_type.has_key(ret[0]):
- #
- # Raise an exception
- #
- if functions_noexcept.has_key(name):
- classes.write(" if ret is None:return None\n")
- else:
- classes.write(
- " if ret is None:raise libvirtError('%s() failed')\n" %
- (name))
-
- classes.write(" return ")
- classes.write(classes_type[ret[0]][1] % ("ret"))
- classes.write("\n")
-
- # For functions returning an integral type there are
- # several things that we can do, depending on the
- # contents of functions_int_*:
- elif is_integral_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_int_exception_test.has_key (name):
- test = functions_int_exception_test[name]
- else:
- test = functions_int_default_test
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed')\n") %
- ("ret", name))
- classes.write(" return ret\n")
-
- elif is_python_noninteger_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_list_exception_test.has_key (name):
- test = functions_list_exception_test[name]
- else:
- test = functions_list_default_test
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed')\n") %
- ("ret", name))
- classes.write(" return ret\n")
-
- else:
- classes.write(" return ret\n")
-
- classes.write("\n")
-
- for classname in classes_list:
- if classname == "None":
- pass
- else:
- if classes_ancestor.has_key(classname):
- classes.write("class %s(%s):\n" % (classname,
- classes_ancestor[classname]))
- classes.write(" def __init__(self, _obj=None):\n")
- if reference_keepers.has_key(classname):
- rlist = reference_keepers[classname]
- for ref in rlist:
- classes.write(" self.%s = None\n" % ref[1])
- classes.write(" self._o = _obj\n")
- classes.write(" %s.__init__(self, _obj=_obj)\n\n" % (
- classes_ancestor[classname]))
- else:
- classes.write("class %s(object):\n" % (classname))
- if classname in [ "virDomain", "virNetwork", "virInterface", "virStoragePool",
- "virStorageVol", "virNodeDevice", "virSecret","virStream",
- "virNWFilter" ]:
- classes.write(" def __init__(self, conn, _obj=None):\n")
- elif classname in [ 'virDomainSnapshot' ]:
- classes.write(" def __init__(self, dom, _obj=None):\n")
- else:
- classes.write(" def __init__(self, _obj=None):\n")
- if reference_keepers.has_key(classname):
- list = reference_keepers[classname]
- for ref in list:
- classes.write(" self.%s = None\n" % ref[1])
- if classname in [ "virDomain", "virNetwork", "virInterface",
- "virNodeDevice", "virSecret", "virStream",
- "virNWFilter" ]:
- classes.write(" self._conn = conn\n")
- elif classname in [ "virStorageVol", "virStoragePool" ]:
- classes.write(" self._conn = conn\n" + \
- " if not isinstance(conn, virConnect):\n" + \
- " self._conn = conn._conn\n")
- elif classname in [ "virDomainSnapshot" ]:
- classes.write(" self._dom = dom\n")
- classes.write(" self._conn = dom.connect()\n")
- classes.write(" self._o = _obj\n\n")
- destruct=None
- if classes_destructors.has_key(classname):
- classes.write(" def __del__(self):\n")
- classes.write(" if self._o is not None:\n")
- classes.write(" libvirtmod.%s(self._o)\n" %
- classes_destructors[classname])
- classes.write(" self._o = None\n\n")
- destruct=classes_destructors[classname]
-
- if not class_skip_connect_impl.has_key(classname):
- # Build python safe 'connect' method
- classes.write(" def connect(self):\n")
- classes.write(" return self._conn\n\n")
-
- if class_domain_impl.has_key(classname):
- classes.write(" def domain(self):\n")
- classes.write(" return self._dom\n\n")
-
- flist = function_classes[classname]
- flist.sort(functionCompare)
- oldfile = ""
- for info in flist:
- (index, func, name, ret, args, file, mod) = info
- #
- # Do not provide as method the destructors for the class
- # to avoid double free
- #
- if name == destruct:
- continue
- if file != oldfile:
- if file == "python_accessor":
- classes.write(" # accessors for %s\n" % (classname))
- else:
- classes.write(" #\n")
- classes.write(" # %s functions from module %s\n" % (
- classname, file))
- classes.write(" #\n\n")
- oldfile = file
- classes.write(" def %s(self" % func)
- n = 0
- for arg in args:
- if n != index:
- classes.write(", %s" % arg[0])
- if arg[0] == "flags" or is_optional_arg(arg[2]):
- if is_integral_type(arg[1]):
- classes.write("=0")
- else:
- classes.write("=None")
- n = n + 1
- classes.write("):\n")
- writeDoc(module, name, args, ' ', classes)
- n = 0
- for arg in args:
- if classes_type.has_key(arg[1]):
- if n != index:
- classes.write(" if %s is None: %s__o = None\n" %
- (arg[0], arg[0]))
- classes.write(" else: %s__o = %s%s\n" %
- (arg[0], arg[0], classes_type[arg[1]][0]))
- n = n + 1
- if ret[0] != "void":
- classes.write(" ret = ")
- else:
- classes.write(" ")
- n = 0
- classes.write("libvirtmod.%s(" % name)
- for arg in args:
- if n != 0:
- classes.write(", ")
- if n != index:
- classes.write("%s" % arg[0])
- if classes_type.has_key(arg[1]):
- classes.write("__o")
- else:
- classes.write("self")
- if classes_type.has_key(arg[1]):
- classes.write(classes_type[arg[1]][0])
- n = n + 1
- classes.write(")\n")
-
- if name == "virConnectClose":
- classes.write(" self._o = None\n")
-
- # For functions returning object types:
- if ret[0] != "void":
- if classes_type.has_key(ret[0]):
- #
- # Raise an exception
- #
- if functions_noexcept.has_key(name):
- classes.write(
- " if ret is None:return None\n")
- else:
- if classname == "virConnect":
- classes.write(
- " if ret is None:raise libvirtError('%s() failed', conn=self)\n" %
- (name))
- elif classname == "virDomain":
- classes.write(
- " if ret is None:raise libvirtError('%s() failed', dom=self)\n" %
- (name))
- elif classname == "virNetwork":
- classes.write(
- " if ret is None:raise libvirtError('%s() failed', net=self)\n" %
- (name))
- elif classname == "virInterface":
- classes.write(
- " if ret is None:raise libvirtError('%s() failed', net=self)\n" %
- (name))
- elif classname == "virStoragePool":
- classes.write(
- " if ret is None:raise libvirtError('%s() failed', pool=self)\n" %
- (name))
- elif classname == "virStorageVol":
- classes.write(
- " if ret is None:raise libvirtError('%s() failed', vol=self)\n" %
- (name))
- elif classname == "virDomainSnapshot":
- classes.write(
- " if ret is None:raise libvirtError('%s() failed', dom=self._dom)\n" %
- (name))
- else:
- classes.write(
- " if ret is None:raise libvirtError('%s() failed')\n" %
- (name))
-
- #
- # generate the returned class wrapper for the object
- #
- classes.write(" __tmp = ")
- classes.write(classes_type[ret[0]][1] % ("ret"))
- classes.write("\n")
-
- #
- # Sometime one need to keep references of the source
- # class in the returned class object.
- # See reference_keepers for the list
- #
- tclass = classes_type[ret[0]][2]
- if reference_keepers.has_key(tclass):
- list = reference_keepers[tclass]
- for pref in list:
- if pref[0] == classname:
- classes.write(" __tmp.%s = self\n" %
- pref[1])
-
- # Post-processing - just before we return.
- if function_post.has_key(name):
- classes.write(" %s\n" %
- (function_post[name]))
-
- #
- # return the class
- #
- classes.write(" return __tmp\n")
- elif converter_type.has_key(ret[0]):
- #
- # Raise an exception
- #
- if functions_noexcept.has_key(name):
- classes.write(
- " if ret is None:return None")
-
- # Post-processing - just before we return.
- if function_post.has_key(name):
- classes.write(" %s\n" %
- (function_post[name]))
-
- classes.write(" return ")
- classes.write(converter_type[ret[0]] % ("ret"))
- classes.write("\n")
-
- # For functions returning an integral type there
- # are several things that we can do, depending on
- # the contents of functions_int_*:
- elif is_integral_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_int_exception_test.has_key (name):
- test = functions_int_exception_test[name]
- else:
- test = functions_int_default_test
- if classname == "virConnect":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', conn=self)\n") %
- ("ret", name))
- elif classname == "virDomain":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', dom=self)\n") %
- ("ret", name))
- elif classname == "virNetwork":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', net=self)\n") %
- ("ret", name))
- elif classname == "virInterface":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', net=self)\n") %
- ("ret", name))
- elif classname == "virStoragePool":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', pool=self)\n") %
- ("ret", name))
- elif classname == "virStorageVol":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', vol=self)\n") %
- ("ret", name))
- else:
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed')\n") %
- ("ret", name))
-
- # Post-processing - just before we return.
- if function_post.has_key(name):
- classes.write(" %s\n" %
- (function_post[name]))
-
- classes.write (" return ret\n")
-
- elif is_python_noninteger_type (ret[0]):
- if not functions_noexcept.has_key (name):
- if functions_list_exception_test.has_key (name):
- test = functions_list_exception_test[name]
- else:
- test = functions_list_default_test
- if classname == "virConnect":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', conn=self)\n") %
- ("ret", name))
- elif classname == "virDomain":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', dom=self)\n") %
- ("ret", name))
- elif classname == "virNetwork":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', net=self)\n") %
- ("ret", name))
- elif classname == "virInterface":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', net=self)\n") %
- ("ret", name))
- elif classname == "virStoragePool":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', pool=self)\n") %
- ("ret", name))
- elif classname == "virStorageVol":
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed', vol=self)\n") %
- ("ret", name))
- else:
- classes.write ((" if " + test +
- ": raise libvirtError ('%s() failed')\n") %
- ("ret", name))
-
- # Post-processing - just before we return.
- if function_post.has_key(name):
- classes.write(" %s\n" %
- (function_post[name]))
-
- classes.write (" return ret\n")
-
- else:
- # Post-processing - just before we return.
- if function_post.has_key(name):
- classes.write(" %s\n" %
- (function_post[name]))
-
- classes.write(" return ret\n")
-
- classes.write("\n")
- # Append "<classname>.py" to class def, iff it exists
- try:
- extra = open(os.path.join(srcPref,"libvirt-override-" + classname + ".py"), "r")
- classes.write (" #\n")
- classes.write (" # %s methods from %s.py (hand coded)\n" % (classname,classname))
- classes.write (" #\n")
- classes.writelines(extra.readlines())
- classes.write("\n")
- extra.close()
- except:
- pass
-
- #
- # Generate enum constants
- #
- for type,enum in enums.items():
- classes.write("# %s\n" % type)
- items = enum.items()
- items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
- for name,value in items:
- classes.write("%s = %s\n" % (name,value))
- classes.write("\n")
-
- classes.close()
-
-def qemuBuildWrappers(module):
- global qemu_functions
-
- if not module == "libvirt-qemu":
- print "ERROR: only libvirt-qemu is supported"
- return None
-
- extra_file = os.path.join(srcPref, "%s-override.py" % module)
- extra = None
-
- fd = open("libvirt_qemu.py", "w")
-
- if os.path.exists(extra_file):
- extra = open(extra_file, "r")
- fd.write("#! " + python + " -i\n")
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- fd.write("#\n")
- fd.write("# This file is automatically written by generator.py. Any changes\n")
- fd.write("# made here will be lost.\n")
- fd.write("#\n")
- fd.write("# To change the manually written methods edit " + module + "-override.py\n")
- fd.write("# To change the automatically written methods edit generator.py\n")
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- fd.write("#\n")
- if extra is not None:
- fd.writelines(extra.readlines())
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- fd.write("#\n")
- fd.write("# Automatically written part of python bindings for libvirt\n")
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- if extra is not None:
- extra.close()
-
- fd.write("try:\n")
- fd.write(" import libvirtmod_qemu\n")
- fd.write("except ImportError, lib_e:\n")
- fd.write(" try:\n")
- fd.write(" import cygvirtmod_qemu as libvirtmod_qemu\n")
- fd.write(" except ImportError, cyg_e:\n")
- fd.write(" if str(cyg_e).count(\"No module named\"):\n")
- fd.write(" raise lib_e\n\n")
-
- fd.write("import libvirt\n\n")
- fd.write("#\n# Functions from module %s\n#\n\n" % module)
- #
- # Generate functions directly, no classes
- #
- for name in qemu_functions.keys():
- func = nameFixup(name, 'None', None, None)
- (desc, ret, args, file, mod, cond) = qemu_functions[name]
- fd.write("def %s(" % func)
- n = 0
- for arg in args:
- if n != 0:
- fd.write(", ")
- fd.write("%s" % arg[0])
- n = n + 1
- fd.write("):\n")
- writeDoc(module, name, args, ' ', fd)
-
- if ret[0] != "void":
- fd.write(" ret = ")
- else:
- fd.write(" ")
- fd.write("libvirtmod_qemu.%s(" % name)
- n = 0
-
- conn = None
-
- for arg in args:
- if arg[1] == "virConnectPtr":
- conn = arg[0]
-
- if n != 0:
- fd.write(", ")
- if arg[1] in ["virDomainPtr", "virConnectPtr"]:
- # FIXME: This might have problem if the function
- # has multiple args which are objects.
- fd.write("%s.%s" % (arg[0], "_o"))
- else:
- fd.write("%s" % arg[0])
- n = n + 1
- fd.write(")\n")
-
- if ret[0] != "void":
- fd.write(" if ret is None: raise libvirt.libvirtError('" + name + "() failed')\n")
- if ret[0] == "virDomainPtr":
- fd.write(" __tmp = virDomain(" + conn + ",_obj=ret)\n")
- fd.write(" return __tmp\n")
- else:
- fd.write(" return ret\n")
-
- fd.write("\n")
-
- #
- # Generate enum constants
- #
- for type,enum in qemu_enums.items():
- fd.write("# %s\n" % type)
- items = enum.items()
- items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
- for name,value in items:
- fd.write("%s = %s\n" % (name,value))
- fd.write("\n")
-
- fd.close()
-
-
-def lxcBuildWrappers(module):
- global lxc_functions
-
- if not module == "libvirt-lxc":
- print "ERROR: only libvirt-lxc is supported"
- return None
-
- extra_file = os.path.join(srcPref, "%s-override.py" % module)
- extra = None
-
- fd = open("libvirt_lxc.py", "w")
-
- if os.path.exists(extra_file):
- extra = open(extra_file, "r")
- fd.write("#! " + python + " -i\n")
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- fd.write("#\n")
- fd.write("# This file is automatically written by generator.py. Any changes\n")
- fd.write("# made here will be lost.\n")
- fd.write("#\n")
- fd.write("# To change the manually written methods edit " + module + "-override.py\n")
- fd.write("# To change the automatically written methods edit generator.py\n")
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- fd.write("#\n")
- if extra is not None:
- fd.writelines(extra.readlines())
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- fd.write("#\n")
- fd.write("# Automatically written part of python bindings for libvirt\n")
- fd.write("#\n")
- fd.write("# WARNING WARNING WARNING WARNING\n")
- if extra is not None:
- extra.close()
-
- fd.write("try:\n")
- fd.write(" import libvirtmod_lxc\n")
- fd.write("except ImportError, lib_e:\n")
- fd.write(" try:\n")
- fd.write(" import cygvirtmod_lxc as libvirtmod_lxc\n")
- fd.write(" except ImportError, cyg_e:\n")
- fd.write(" if str(cyg_e).count(\"No module named\"):\n")
- fd.write(" raise lib_e\n\n")
-
- fd.write("import libvirt\n\n")
- fd.write("#\n# Functions from module %s\n#\n\n" % module)
- #
- # Generate functions directly, no classes
- #
- for name in lxc_functions.keys():
- func = nameFixup(name, 'None', None, None)
- (desc, ret, args, file, mod, cond) = lxc_functions[name]
- fd.write("def %s(" % func)
- n = 0
- for arg in args:
- if n != 0:
- fd.write(", ")
- fd.write("%s" % arg[0])
- n = n + 1
- fd.write("):\n")
- writeDoc(module, name, args, ' ', fd)
-
- if ret[0] != "void":
- fd.write(" ret = ")
- else:
- fd.write(" ")
- fd.write("libvirtmod_lxc.%s(" % name)
- n = 0
-
- conn = None
-
- for arg in args:
- if arg[1] == "virConnectPtr":
- conn = arg[0]
-
- if n != 0:
- fd.write(", ")
- if arg[1] in ["virDomainPtr", "virConnectPtr"]:
- # FIXME: This might have problem if the function
- # has multiple args which are objects.
- fd.write("%s.%s" % (arg[0], "_o"))
- else:
- fd.write("%s" % arg[0])
- n = n + 1
- fd.write(")\n")
-
- if ret[0] != "void":
- fd.write(" if ret is None: raise libvirt.libvirtError('" + name + "() failed')\n")
- if ret[0] == "virDomainPtr":
- fd.write(" __tmp = virDomain(" + conn + ",_obj=ret)\n")
- fd.write(" return __tmp\n")
- else:
- fd.write(" return ret\n")
-
- fd.write("\n")
-
- #
- # Generate enum constants
- #
- for type,enum in lxc_enums.items():
- fd.write("# %s\n" % type)
- items = enum.items()
- items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
- for name,value in items:
- fd.write("%s = %s\n" % (name,value))
- fd.write("\n")
-
- fd.close()
-
-
-quiet = 0
-if buildStubs("libvirt") < 0:
- sys.exit(1)
-if buildStubs("libvirt-lxc") < 0:
- sys.exit(1)
-if buildStubs("libvirt-qemu") < 0:
- sys.exit(1)
-buildWrappers("libvirt")
-lxcBuildWrappers("libvirt-lxc")
-qemuBuildWrappers("libvirt-qemu")
-sys.exit(0)
diff --git a/python/libvirt-lxc-override-api.xml b/python/libvirt-lxc-override-api.xml
deleted file mode 100644
index db0d45d..0000000
--- a/python/libvirt-lxc-override-api.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0"?>
-<api name='libvir-lxc-python'>
- <symbols>
- <function name='virDomainLxcOpenNamespace' file='python-lxc'>
- <info><![CDATA[This API is LXC specific, so it will only work with hypervisor
-connections to the LXC driver.
-
-Open the namespaces associated with the container @domain
-and return a list of file descriptors associated with the
-container.
-
-The returned file descriptors are intended to be used with
-the setns() system call.]]></info>
- <return type='int' info='the list of open file descriptors, or -1 on error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='flags' type='unsigned int' info='currently unused, pass 0'/>
- </function>
- </symbols>
-</api>
diff --git a/python/libvirt-lxc-override.c b/python/libvirt-lxc-override.c
deleted file mode 100644
index f76ff4b..0000000
--- a/python/libvirt-lxc-override.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * libvir.c: this modules implements the main part of the glue of the
- * libvir library and the Python interpreter. It provides the
- * entry points where an automatically generated stub is
- * unpractical
- *
- * Copyright (C) 2012-2013 Red Hat, Inc.
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-#include <config.h>
-
-/* Horrible kludge to work around even more horrible name-space pollution
- via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
- which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
-#undef HAVE_PTHREAD_H
-
-#include <Python.h>
-#include <libvirt/libvirt-lxc.h>
-#include <libvirt/virterror.h>
-#include "typewrappers.h"
-#include "libvirt-lxc.h"
-#include "viralloc.h"
-#include "virfile.h"
-
-#ifndef __CYGWIN__
-extern void initlibvirtmod_lxc(void);
-#else
-extern void initcygvirtmod_lxc(void);
-#endif
-
-#if 0
-# define DEBUG_ERROR 1
-#endif
-
-#if DEBUG_ERROR
-# define DEBUG(fmt, ...) \
- printf(fmt, __VA_ARGS__)
-#else
-# define DEBUG(fmt, ...) \
- do {} while (0)
-#endif
-
-/* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
- is so common that we encapsulate it here. Now, each use is simply
- return VIR_PY_NONE; */
-#define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
-#define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
-#define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
-
-/************************************************************************
- * *
- * Statistics *
- * *
- ************************************************************************/
-
-static PyObject *
-libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- unsigned int flags;
- int c_retval;
- int *fdlist = NULL;
- size_t i;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainLxcOpenNamespace",
- &pyobj_domain, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (domain == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainLxcOpenNamespace(domain, &fdlist, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyList_New(0);
- for (i = 0; i < c_retval; i++) {
- PyObject *item = NULL;
-
- if ((item = PyInt_FromLong(fdlist[i])) == NULL)
- goto error;
-
- if (PyList_Append(py_retval, item) < 0) {
- Py_DECREF(item);
- goto error;
- }
- }
- VIR_FREE(fdlist);
- return py_retval;
-
-error:
- for (i = 0; i < c_retval; i++) {
- VIR_FORCE_CLOSE(fdlist[i]);
- }
- VIR_FREE(fdlist);
- return VIR_PY_NONE;
-}
-/************************************************************************
- * *
- * The registration stuff *
- * *
- ************************************************************************/
-static PyMethodDef libvirtLxcMethods[] = {
-#include "libvirt-lxc-export.c"
- {(char *) "virDomainLxcOpenNamespace", libvirt_lxc_virDomainLxcOpenNamespace, METH_VARARGS, NULL},
- {NULL, NULL, 0, NULL}
-};
-
-void
-#ifndef __CYGWIN__
-initlibvirtmod_lxc
-#else
-initcygvirtmod_lxc
-#endif
- (void)
-{
- static int initialized = 0;
-
- if (initialized != 0)
- return;
-
- if (virInitialize() < 0)
- return;
-
- /* initialize the python extension module */
- Py_InitModule((char *)
-#ifndef __CYGWIN__
- "libvirtmod_lxc"
-#else
- "cygvirtmod_lxc"
-#endif
- , libvirtLxcMethods);
-
- initialized = 1;
-}
diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
deleted file mode 100644
index 337d0a0..0000000
--- a/python/libvirt-override-api.xml
+++ /dev/null
@@ -1,613 +0,0 @@
-<?xml version="1.0"?>
-<api name='libvir-python'>
- <!-- This file lists libvirt API functions whose Python stubs are
- written by hand in libvirt-override.c, but the Python-level code
- are still automatically generated by the generator.py script.
-
- The type of return value is supposed to be C type. If a function's
- stub will return a python non-integer data type like string, list,
- tuple, dictionary, etc, please use "char *" as the type of its return
- value.
- -->
- <symbols>
- <function name="virConnectGetVersion" file='python'>
- <info>Returns the running hypervisor version of the connection host</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='int' info="0 on success, -1 on error"/>
- </function>
- <function name="virConnectGetLibVersion" file='python'>
- <info>Returns the libvirt version of the connection host</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='int' info="0 on success, -1 on error"/>
- </function>
- <function name="virConnectListDomainsID" file='python'>
- <info>Returns the list of the ID of the domains on the hypervisor</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info="the list of ID or None in case of error"/>
- </function>
- <function name='virConnectListDefinedDomains' file='python'>
- <info>list the defined domains, stores the pointers to the names in @names</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virConnectListAllDomains' file='python'>
- <info>returns list of all defined domains</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of domains or None in case of error'/>
- </function>
- <function name='virConnectListNetworks' file='python'>
- <info>list the networks, stores the pointers to the names in @names</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virConnectListDefinedNetworks' file='python'>
- <info>list the defined networks, stores the pointers to the names in @names</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virConnectListAllNetworks' file='python'>
- <info>returns list of all networks</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of networks or None in case of error'/>
- </function>
- <function name='virDomainLookupByUUID' file='python'>
- <info>Try to lookup a domain on the given hypervisor based on its UUID.</info>
- <return type='virDomainPtr' info='a new domain object or NULL in case of failure'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='uuid' type='const unsigned char *' info='the UUID string for the domain, must be 16 bytes'/>
- </function>
- <function name='virNetworkLookupByUUID' file='python'>
- <info>Try to lookup a network on the given hypervisor based on its UUID.</info>
- <return type='virNetworkPtr' info='a new network object or NULL in case of failure'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='uuid' type='const unsigned char *' info='the UUID string for the network, must be 16 bytes'/>
- </function>
- <function name='virDomainGetInfo' file='python'>
- <info>Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
- <return type='char *' info='the list of information or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- </function>
- <function name='virDomainGetState' file='python'>
- <info>Extract domain state.</info>
- <return type='char *' info='the list containing state and reason or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='flags' type='unsigned int' info='additional flags'/>
- </function>
- <function name='virDomainGetControlInfo' file='python'>
- <info>Extract details about current state of control interface to a domain.</info>
- <return type='char *' info='the list of information or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='flags' type='unsigned int' info='additional flags'/>
- </function>
- <function name='virDomainGetBlockInfo' file='python'>
- <info>Extract information about a domain block device size</info>
- <return type='char *' info='the list of information or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='path' type='const char *' info='path to the block device or file'/>
- <arg name='flags' type='unsigned int' info='currently unused'/>
- </function>
- <function name='virDomainGetJobInfo' file='python'>
- <info>Extract information about an active job being processed for a domain.</info>
- <return type='char *' info='the list of information or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- </function>
- <function name='virDomainGetJobStats' file='python'>
- <info>Extract information about an active job being processed for a domain.</info>
- <return type='char *' info='dictionary mapping field names to values or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
- </function>
- <function name='virNodeGetInfo' file='python'>
- <info>Extract hardware information about the Node. Note that the memory size is reported in MiB instead of KiB.</info>
- <return type='char *' info='the list of information or None in case of error'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- </function>
- <function name='virNodeGetCPUStats' file='python'>
- <info>Extract node's CPU statistics.</info>
- <return type='char *' info='dictionary mapping field names to values or None in case of error'/>
- <arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
- <arg name='cpuNum' type='int' info='number of node cpu. (VIR_NODE_CPU_STATS_ALL_CPUS means total cpu statistics)'/>
- <arg name='flags' type='unsigned int' info='additional flags'/>
- </function>
- <function name='virNodeGetMemoryStats' file='python'>
- <info>Extract node's memory statistics.</info>
- <return type='char *' info='dictionary mapping field names to values or None in case of error'/>
- <arg name='conn' type='virConnectPtr' info='pointer to hypervisor connection'/>
- <arg name='cellNum' type='int' info='number of node cell. (VIR_NODE_MEMORY_STATS_ALL_CELLS means total cell statistics)'/>
- <arg name='flags' type='unsigned int' info='additional flags'/>
- </function>
- <function name='virDomainGetUUID' file='python'>
- <info>Extract the UUID unique Identifier of a domain.</info>
- <return type='char *' info='the 16 bytes string or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- </function>
- <function name='virDomainGetUUIDString' file='python'>
- <info>Fetch globally unique ID of the domain as a string.</info>
- <return type='char *' info='the UUID string or None in case of error'/>
- <arg name='pool' type='virDomainPtr' info='a domain object'/>
- </function>
- <function name='virNetworkGetUUID' file='python'>
- <info>Extract the UUID unique Identifier of a network.</info>
- <return type='char *' info='the 16 bytes string or None in case of error'/>
- <arg name='domain' type='virNetworkPtr' info='a network object'/>
- </function>
- <function name='virNetworkGetUUIDString' file='python'>
- <info>Fetch globally unique ID of the network as a string.</info>
- <return type='char *' info='the UUID string or None in case of error'/>
- <arg name='net' type='virNetworkPtr' info='a network object'/>
- </function>
- <function name='virStoragePoolGetUUID' file='python'>
- <info>Extract the UUID unique Identifier of a storage pool.</info>
- <return type='char *' info='the 16 bytes string or None in case of error'/>
- <arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
- </function>
- <function name='virStoragePoolGetUUIDString' file='python'>
- <info>Fetch globally unique ID of the storage pool as a string.</info>
- <return type='char *' info='the UUID string or None in case of error'/>
- <arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
- </function>
- <function name='virNetworkGetAutostart' file='python'>
- <info>Extract the autostart flag for a network.</info>
- <return type='int' info='the autostart flag, or None in case of error'/>
- <arg name='domain' type='virNetworkPtr' info='a network object'/>
- </function>
- <function name='virDomainGetAutostart' file='python'>
- <info>Extract the autostart flag for a domain</info>
- <return type='int' info='the autostart flag, or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a network object'/>
- </function>
- <function name='virStoragePoolGetAutostart' file='python'>
- <info>Extract the autostart flag for a storage pool</info>
- <return type='int' info='the autostart flag, or None in case of error'/>
- <arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
- </function>
- <function name='virDomainBlockStats' file='python'>
- <info>Extracts block device statistics for a domain</info>
- <return type='char *' info='a tuple of statistics'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='path' type='char *' info='the path for the block device'/>
- </function>
- <function name='virDomainBlockStatsFlags' file='python'>
- <info>Extracts block device statistics parameters of a running domain</info>
- <return type='char *' info='None in case of error, returns a dictionary of params'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='path' type='char *' info='the path for the block device'/>
- <arg name='flags' type='int' info='flags (unused; pass 0)'/>
- </function>
- <function name='virDomainGetCPUStats' file='python'>
- <info>Extracts CPU statistics for a running domain. On success it will
- return a list of data of dictionary type. If boolean total is False or 0, the
- first element of the list refers to CPU0 on the host, second element is
- CPU1, and so on. The format of data struct is as follows:
- [{cpu_time:xxx}, {cpu_time:xxx}, ...]
- If it is True or 1, it returns total domain CPU statistics in the format of
- [{cpu_time:xxx, user_time:xxx, system_time:xxx}]</info>
- <return type='char *' info='returns a list of dictionary in case of success, None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='total' type='bool' info='on true, return total domain CPU statistics, false return per-cpu info'/>
- <arg name='flags' type='int' info='flags (unused; pass 0)'/>
- </function>
- <function name='virDomainInterfaceStats' file='python'>
- <info>Extracts interface device statistics for a domain</info>
- <return type='char *' info='a tuple of statistics'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='path' type='char *' info='the path for the interface device'/>
- </function>
- <function name='virDomainMemoryStats' file='python'>
- <info>Extracts memory statistics for a domain</info>
- <return type='char *' info='a dictionary of statistics'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- </function>
- <function name="virNodeGetCellsFreeMemory" file='python'>
- <info>Returns the available memory for a list of cells</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='startCell' type='int' info='first cell in the list'/>
- <arg name='maxCells' type='int' info='number of cell in the list'/>
- <return type='char *' info="the list available memory in the cells"/>
- </function>
- <function name='virDomainGetSchedulerParameters' file='python'>
- <info>Get the scheduler parameters, the @params array will be filled with the values.</info>
- <return type='char *' info='None in case of error, returns a dictionary of params.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- </function>
- <function name='virDomainGetSchedulerParametersFlags' file='python'>
- <info>Get the scheduler parameters</info>
- <return type='char *' info='None in case of error, returns a dictionary of params'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainGetSchedulerType' file='python'>
- <info>Get the scheduler type.</info>
- <return type='char *' info='NULL in case of error. The caller must free the returned string.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- </function>
- <function name='virDomainGetVcpus' file='python'>
- <info>Extract information about virtual CPUs of domain, store it in info array and also in cpumaps if this pointer is'nt NULL.</info>
- <return type='int' info='the number of info filled in case of success, -1 in case of failure.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
- </function>
- <function name='virDomainPinVcpu' file='python'>
- <info>Dynamically change the real CPUs which can be allocated to a virtual CPU. This function requires privileged access to the hypervisor.</info>
- <return type='int' info='0 in case of success, -1 in case of failure.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
- <arg name='vcpu' type='unsigned int' info='virtual CPU number'/>
- <arg name='cpumap' type='unsigned char *' info='pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit.'/>
- </function>
- <function name='virDomainPinVcpuFlags' file='python'>
- <info>Dynamically change the real CPUs which can be allocated to a virtual CPU. This function requires privileged access to the hypervisor.</info>
- <return type='int' info='0 in case of success, -1 in case of failure.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
- <arg name='vcpu' type='unsigned int' info='virtual CPU number'/>
- <arg name='cpumap' type='unsigned char *' info='pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit.'/>
- <arg name='flags' type='int' info='flags to specify'/>
- </function>
- <function name='virDomainGetVcpuPinInfo' file='python'>
- <info>Query the CPU affinity setting of all virtual CPUs of domain</info>
- <return type='char *' info='the array of cpumap'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainGetEmulatorPinInfo' file='python'>
- <info>Query the CPU affinity setting of the emulator process of domain</info>
- <return type='char *' info='the array of cpumap'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainPinEmulator' file='python'>
- <info>Dynamically change the real CPUs which can be allocated to the emulator process of a domain.
- This function requires privileged access to the hypervisor.</info>
- <return type='int' info='0 in case of success, -1 in case of failure.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object, or NULL for Domain0'/>
- <arg name='cpumap' type='unsigned char *' info='pointer to a bit map of real CPUs (in 8-bit bytes) (IN) Each bit set to 1 means that corresponding CPU is usable. Bytes are stored in little-endian order: CPU0-7, 8-15... In each byte, lowest CPU number is least significant bit.'/>
- <arg name='flags' type='int' info='flags to specify'/>
- </function>
- <function name='virDomainSetSchedulerParameters' file='python'>
- <info>Change the scheduler parameters</info>
- <return type='int' info='-1 in case of error, 0 in case of success.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='params' type='virSchedParameterPtr' info='pointer to scheduler parameter objects'/>
- </function>
- <function name='virDomainSetSchedulerParametersFlags' file='python'>
- <info>Change the scheduler parameters</info>
- <return type='int' info='-1 in case of error, 0 in case of success.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='params' type='virSchedParameterPtr' info='pointer to scheduler parameter objects'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainSetBlkioParameters' file='python'>
- <info>Change the blkio tunables</info>
- <return type='int' info='-1 in case of error, 0 in case of success.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='params' type='virBlkioParameterPtr' info='pointer to blkio tunable objects'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainGetBlkioParameters' file='python'>
- <info>Get the blkio parameters</info>
- <return type='char *' info='None in case of error, returns a dictionary of params'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainSetMemoryParameters' file='python'>
- <info>Change the memory tunables</info>
- <return type='int' info='-1 in case of error, 0 in case of success.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='params' type='virMemoryParameterPtr' info='pointer to memory tunable objects'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainGetMemoryParameters' file='python'>
- <info>Get the memory parameters</info>
- <return type='char *' info='None in case of error, returns a dictionary of params'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainSetNumaParameters' file='python'>
- <info>Change the NUMA tunables</info>
- <return type='int' info='-1 in case of error, 0 in case of success.'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='params' type='virTypedParameterPtr' info='pointer to numa tunable objects'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainGetNumaParameters' file='python'>
- <info>Get the NUMA parameters</info>
- <return type='char *' info='returns a dictionary of params in case of success, None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='flags' type='int' info='an OR'ed set of virDomainModificationImpact'/>
- </function>
- <function name='virDomainSetInterfaceParameters' file='python'>
- <info>Change the bandwidth tunables for a interface device</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='device' type='const char *' info='interface name'/>
- <arg name='params' type='virTypedParameterPtr' info='Pointer to bandwidth tuning params object'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
- <return type='int' info='0 in case of success, -1 in case of failure'/>
- </function>
- <function name='virDomainGetInterfaceParameters' file='python'>
- <info>Get the bandwidth tunables for a interface device</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='device' type='const char *' info='interface name'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
- <return type='char *' info='the bandwidth tunables value or None in case of error'/>
- </function>
-
- <function name='virConnectListStoragePools' file='python'>
- <info>list the storage pools, stores the pointers to the names in @names</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info='the list of Names of None in case of error'/>
- </function>
- <function name='virConnectListDefinedStoragePools' file='python'>
- <info>list the defined storage pool, stores the pointers to the names in @names</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info='the list of Names of None in case of error'/>
- </function>
- <function name='virConnectListAllStoragePools' file='python'>
- <info>returns list of all storage pools</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of pools or None in case of error'/>
- </function>
- <function name='virStoragePoolListVolumes' file='python'>
- <info>list the storage volumes, stores the pointers to the names in @names</info>
- <arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virStoragePoolListAllVolumes' file='python'>
- <info>return list of storage volume objects</info>
- <arg name='pool' type='virStoragePoolPtr' info='pointer to the storage pool'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of volumes or None in case of error'/>
- </function>
- <function name='virStoragePoolGetInfo' file='python'>
- <info>Extract information about a storage pool. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
- <return type='char *' info='the list of information or None in case of error'/>
- <arg name='pool' type='virStoragePoolPtr' info='a storage pool object'/>
- </function>
- <function name='virStorageVolGetInfo' file='python'>
- <info>Extract information about a storage volume. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
- <return type='char *' info='the list of information or None in case of error'/>
- <arg name='vol' type='virStorageVolPtr' info='a storage vol object'/>
- </function>
- <function name='virNodeListDevices' file='python'>
- <info>list the node devices</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='cap' type='const unsigned char *' info='capability name'/>
- <arg name='flags' type='unsigned int' info='flags (unused; pass 0)'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virConnectListAllNodeDevices' file='python'>
- <info>returns list of all host node devices</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of host node device or None in case of error'/>
- </function>
- <function name='virNodeDeviceListCaps' file='python'>
- <info>list the node device's capabilities</info>
- <arg name='dev' type='virNodeDevicePtr' info='pointer to the node device'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virSecretGetValue' file='libvirt' module='libvirt'>
- <info>Fetches the value associated with a secret.</info>
- <return type='char *' info='the secret value or None in case of error'/>
- <arg name='secret' type='virSecretPtr' info='virSecret secret'/>
- <arg name='flags' type='unsigned int' info='flags (unused; pass 0)'/>
- </function>
- <function name='virConnectListSecrets' file='libvirt' module='libvirt'>
- <info>List the defined secret IDs</info>
- <arg name='conn' type='virConnectPtr' info='virConnect connection'/>
- <return type='char *' info='the list of secret IDs or None in case of error'/>
- </function>
- <function name='virConnectListAllSecrets' file='python'>
- <info>returns list of all interfaces</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of secrets or None in case of error'/>
- </function>
- <function name='virSecretSetValue' file='libvirt' module='libvirt'>
- <info>Associates a value with a secret.</info>
- <return type='int' info='0 on success, -1 on failure.'/>
- <arg name='secret' type='virSecretPtr' info='virSecret secret'/>
- <arg name='value' type='const char *' info='The secret value'/>
- <arg name='flags' type='unsigned int' info='flags (unused; pass 0)'/>
- </function>
- <function name='virSecretLookupByUUID' file='python'>
- <info>Try to lookup a secret on the given hypervisor based on its UUID.</info>
- <return type='virSecretPtr' info='a new secret object or NULL in case of failure'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='uuid' type='const unsigned char *' info='the UUID string for the secret, must be 16 bytes'/>
- </function>
- <function name='virSecretGetUUID' file='python'>
- <info>Extract the UUID unique Identifier of a secret.</info>
- <return type='char *' info='the 16 bytes string or None in case of error'/>
- <arg name='secret' type='virSecretPtr' info='a secret object'/>
- </function>
- <function name='virSecretGetUUIDString' file='python'>
- <info>Fetch globally unique ID of the secret as a string.</info>
- <return type='char *' info='the UUID string or None in case of error'/>
- <arg name='secret' type='virSecretPtr' info='a secret object'/>
- </function>
- <function name='virConnectListNWFilters' file='libvirt' module='libvirt'>
- <info>List the defined network filters</info>
- <arg name='conn' type='virConnectPtr' info='virConnect connection'/>
- <return type='char *' info='the list of network filter IDs or None in case of error'/>
- </function>
- <function name='virConnectListAllNWFilters' file='python'>
- <info>returns list of all network fitlers</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of network filters or None in case of error'/>
- </function>
- <function name='virNWFilterLookupByUUID' file='python'>
- <info>Try to lookup a network filter on the given hypervisor based on its UUID.</info>
- <return type='virNWFilterPtr' info='a new network filter object or NULL in case of failure'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='uuid' type='const unsigned char *' info='the UUID string for the secret, must be 16 bytes'/>
- </function>
- <function name='virNWFilterGetUUID' file='python'>
- <info>Extract the UUID unique Identifier of a network filter.</info>
- <return type='char *' info='the 16 bytes string or None in case of error'/>
- <arg name='nwfilter' type='virNWFilterPtr' info='a network filter object'/>
- </function>
- <function name='virNWFilterGetUUIDString' file='python'>
- <info>Fetch globally unique ID of the network filter as a string.</info>
- <return type='char *' info='the UUID string or None in case of error'/>
- <arg name='nwfilter' type='virNWFilterPtr' info='a network filter object'/>
- </function>
- <function name='virConnectListInterfaces' file='python'>
- <info>list the running interfaces, stores the pointers to the names in @names</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info='the list of Names of None in case of error'/>
- </function>
- <function name='virConnectListDefinedInterfaces' file='python'>
- <info>list the defined interfaces, stores the pointers to the names in @names</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <return type='char *' info='the list of Names of None in case of error'/>
- </function>
- <function name='virConnectListAllInterfaces' file='python'>
- <info>returns list of all interfaces</info>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='unsigned int' info='optional flags'/>
- <return type='char *' info='the list of interfaces or None in case of error'/>
- </function>
- <function name='virConnectBaselineCPU' file='python'>
- <info>Computes the most feature-rich CPU which is compatible with all given host CPUs.</info>
- <return type='char *' info='XML description of the computed CPU or NULL on error.'/>
- <arg name='conn' type='virConnectPtr' info='virConnect connection'/>
- <arg name='xmlCPUs' type='const char **' info='array of XML descriptions of host CPUs'/>
- <arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
- </function>
- <function name='virConnectGetCPUModelNames' file='python'>
- <info>Get the list of supported CPU models.</info>
- <return type='char *' info='list of supported CPU models'/>
- <arg name='conn' type='virConnectPtr' info='virConnect connection'/>
- <arg name='arch' type='const char *' info='arch'/>
- <arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
- </function>
- <function name='virDomainSnapshotListNames' file='python'>
- <info>collect the list of snapshot names for the given domain</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='flags' type='unsigned int' info='flags'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virDomainListAllSnapshots' file='python'>
- <info>returns the list of snapshots for the given domain</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='flags' type='unsigned int' info='flags'/>
- <return type='char *' info='the list of snapshots or None in case of error'/>
- </function>
- <function name='virDomainSnapshotListChildrenNames' file='python'>
- <info>collect the list of child snapshot names for the given snapshot</info>
- <arg name='snapshot' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
- <arg name='flags' type='unsigned int' info='flags'/>
- <return type='char *' info='the list of Names or None in case of error'/>
- </function>
- <function name='virDomainSnapshotListAllChildren' file='python'>
- <info>returns the list of child snapshots for the given snapshot</info>
- <arg name='snapshot' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
- <arg name='flags' type='unsigned int' info='flags'/>
- <return type='char *' info='the list of snapshots or None in case of error'/>
- </function>
- <function name='virDomainRevertToSnapshot' file='python'>
- <info>revert the domain to the given snapshot</info>
- <arg name='dom' type='virDomainPtr' info='dummy domain pointer'/>
- <arg name='snap' type='virDomainSnapshotPtr' info='pointer to the snapshot'/>
- <arg name='flags' type='unsigned int' info='flags'/>
- <return type='int' info="0 on success, -1 on error"/>
- </function>
- <function name='virDomainGetBlockJobInfo' file='python'>
- <info>Get progress information for a block job</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='path' type='const char *' info='Fully-qualified filename of disk'/>
- <arg name='flags' type='unsigned int' info='fine-tuning flags, currently unused, pass 0.'/>
- <return type='char *' info='A dictionary containing job information.' />
- </function>
- <function name='virDomainMigrateGetCompressionCache' file='python'>
- <info>Get current size of the cache (in bytes) used for compressing
- repeatedly transferred memory pages during live migration.</info>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
- <return type='unsigned long long' info='current cache size, or None in case of error'/>
- </function>
- <function name='virDomainMigrateGetMaxSpeed' file='python'>
- <info>Get currently configured maximum migration speed for a domain</info>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='flags' type='unsigned int' info='flags, currently unused, pass 0.'/>
- <return type='unsigned long' info='current max migration speed, or None in case of error'/>
- </function>
- <function name='virDomainMigrate3' file='python'>
- <info>Migrate the domain object from its current host to the destination host
- given by dconn (a connection to the destination host).</info>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='dconn' type='virConnectPtr' info='pointer to the destination host connection'/>
- <arg name='params' type='char *' info='dictionary with migration parameters'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMigrateFlags'/>
- <return type='virDomainPtr' info='a new domain object or NULL in case of failure'/>
- </function>
- <function name='virDomainMigrateToURI3' file='python'>
- <info>Migrate the domain object from its current host to the destination host
- given by URI.</info>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='dconnuri' type='virConnectPtr' info='URI for target libvirtd if @flags includes VIR_MIGRATE_PEER2PEER'/>
- <arg name='params' type='char *' info='dictionary with migration parameters'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMigrateFlags'/>
- <return type='int' info='0 in case of success, -1 in case of failure.'/>
- </function>
- <function name='virDomainSetBlockIoTune' file='python'>
- <info>Change the I/O tunables for a block device</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='disk' type='const char *' info='disk name'/>
- <arg name='params' type='virTypedParameterPtr' info='Pointer to blkio tuning params object'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
- <return type='int' info='0 in case of success, -1 in case of failure'/>
- </function>
- <function name='virDomainGetBlockIoTune' file='python'>
- <info>Get the I/O tunables for a block device</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='disk' type='const char *' info='disk name'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainModificationImpact'/>
- <return type='char *' info='the I/O tunables value or None in case of error'/>
- </function>
- <function name='virDomainBlockPeek' file='python'>
- <info>Read the contents of domain's disk device</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='disk' type='const char *' info='disk name'/>
- <arg name='offset' type='unsigned long long' info='offset within block device'/>
- <arg name='size' type='size_t' info='size to read'/>
- <arg name='flags' type='unsigned int' info='unused, always pass 0'/>
- <return type='char *' info='the returned buffer or None in case of error'/>
- </function>
- <function name='virDomainMemoryPeek' file='python'>
- <info>Read the contents of domain's memory</info>
- <arg name='dom' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='start' type='unsigned long long' info='start of memory to peek'/>
- <arg name='size' type='size_t' info='size of memory to peek'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainMemoryFlags'/>
- <return type='char *' info='the returned buffer or None in case of error'/>
- </function>
- <function name='virDomainGetDiskErrors' file='python'>
- <info>Extract errors on disk devices.</info>
- <return type='char *' info='dictionary of disks and their errors or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='a domain object'/>
- <arg name='flags' type='unsigned int' info='unused, always pass 0'/>
- </function>
- <function name='virNodeSetMemoryParameters' file='python'>
- <info>Change the node memory tunables</info>
- <return type='int' info='-1 in case of error, 0 in case of success.'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='params' type='virTypedParameterPtr' info='pointer to the memory tunable objects'/>
- <arg name='flags' type='int' info='unused, always pass 0'/>
- </function>
- <function name='virNodeGetMemoryParameters' file='python'>
- <info>Get the node memory parameters</info>
- <return type='char *' info='None in case of error, returns a dictionary of params'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='int' info='unused, always pass 0'/>
- </function>
- <function name='virNodeGetCPUMap' file='python'>
- <info>Get node CPU information</info>
- <return type='char *' info='(cpunum, cpumap, online) on success, None on error'/>
- <arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
- <arg name='flags' type='int' info='unused, pass 0'/>
- </function>
- </symbols>
-</api>
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
deleted file mode 100644
index 4ba3d30..0000000
--- a/python/libvirt-override-virConnect.py
+++ /dev/null
@@ -1,351 +0,0 @@
- def __del__(self):
- try:
- for cb,opaque in self.domainEventCallbacks.items():
- del self.domainEventCallbacks[cb]
- del self.domainEventCallbacks
- libvirtmod.virConnectDomainEventDeregister(self._o, self)
- except AttributeError:
- pass
-
- if self._o is not None:
- libvirtmod.virConnectClose(self._o)
- self._o = None
-
- def domainEventDeregister(self, cb):
- """Removes a Domain Event Callback. De-registering for a
- domain callback will disable delivery of this event type """
- try:
- del self.domainEventCallbacks[cb]
- if len(self.domainEventCallbacks) == 0:
- del self.domainEventCallbacks
- ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
- if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
- except AttributeError:
- pass
-
- def domainEventRegister(self, cb, opaque):
- """Adds a Domain Event Callback. Registering for a domain
- callback will enable delivery of the events """
- try:
- self.domainEventCallbacks[cb] = opaque
- except AttributeError:
- self.domainEventCallbacks = {cb:opaque}
- ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
- if ret == -1: raise libvirtError ('virConnectDomainEventRegister() failed', conn=self)
-
- def _dispatchDomainEventCallbacks(self, dom, event, detail):
- """Dispatches events to python user domain event callbacks
- """
- try:
- for cb,opaque in self.domainEventCallbacks.items():
- cb(self,dom,event,detail,opaque)
- return 0
- except AttributeError:
- pass
-
- def _dispatchDomainEventLifecycleCallback(self, dom, event, detail, cbData):
- """Dispatches events to python user domain lifecycle event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), event, detail, opaque)
- return 0
-
- def _dispatchDomainEventGenericCallback(self, dom, cbData):
- """Dispatches events to python user domain generic event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), opaque)
- return 0
-
- def _dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
- """Dispatches events to python user domain RTC change event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), offset ,opaque)
- return 0
-
- def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
- """Dispatches events to python user domain watchdog event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), action, opaque)
- return 0
-
- def _dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias,
- action, cbData):
- """Dispatches events to python user domain IO error event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, opaque)
- return 0
-
- def _dispatchDomainEventIOErrorReasonCallback(self, dom, srcPath,
- devAlias, action, reason,
- cbData):
- """Dispatches events to python user domain IO error event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action,
- reason, opaque)
- return 0
-
- def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
- remoteAddr, authScheme, subject,
- cbData):
- """Dispatches events to python user domain graphics event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr,
- authScheme, subject, opaque)
- return 0
-
- def dispatchDomainEventBlockPullCallback(self, dom, path, type, status, cbData):
- """Dispatches events to python user domain blockJob event callbacks
- """
- try:
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), path, type, status, opaque)
- return 0
- except AttributeError:
- pass
-
- def _dispatchDomainEventDiskChangeCallback(self, dom, oldSrcPath, newSrcPath, devAlias, reason, cbData):
- """Dispatches event to python user domain diskChange event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason, opaque)
- return 0
-
- def _dispatchDomainEventTrayChangeCallback(self, dom, devAlias, reason, cbData):
- """Dispatches event to python user domain trayChange event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), devAlias, reason, opaque)
- return 0
-
- def _dispatchDomainEventPMWakeupCallback(self, dom, reason, cbData):
- """Dispatches event to python user domain pmwakeup event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), reason, opaque)
- return 0
-
- def _dispatchDomainEventPMSuspendCallback(self, dom, reason, cbData):
- """Dispatches event to python user domain pmsuspend event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), reason, opaque)
- return 0
-
- def _dispatchDomainEventBalloonChangeCallback(self, dom, actual, cbData):
- """Dispatches events to python user domain balloon change event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), actual, opaque)
- return 0
-
- def _dispatchDomainEventPMSuspendDiskCallback(self, dom, reason, cbData):
- """Dispatches event to python user domain pmsuspend-disk event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), reason, opaque)
- return 0
-
- def _dispatchDomainEventDeviceRemovedCallback(self, dom, devAlias, cbData):
- """Dispatches event to python user domain device removed event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, virDomain(self, _obj=dom), devAlias, opaque)
- return 0
-
- def domainEventDeregisterAny(self, callbackID):
- """Removes a Domain Event Callback. De-registering for a
- domain callback will disable delivery of this event type """
- try:
- ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
- if ret == -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn=self)
- del self.domainEventCallbackID[callbackID]
- except AttributeError:
- pass
-
- def domainEventRegisterAny(self, dom, eventID, cb, opaque):
- """Adds a Domain Event Callback. Registering for a domain
- callback will enable delivery of the events """
- if not hasattr(self, 'domainEventCallbackID'):
- self.domainEventCallbackID = {}
- cbData = { "cb": cb, "conn": self, "opaque": opaque }
- if dom is None:
- ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
- else:
- ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
- if ret == -1:
- raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn=self)
- self.domainEventCallbackID[ret] = opaque
- return ret
-
- def listAllDomains(self, flags=0):
- """List all domains and returns a list of domain objects"""
- ret = libvirtmod.virConnectListAllDomains(self._o, flags)
- if ret is None:
- raise libvirtError("virConnectListAllDomains() failed", conn=self)
-
- retlist = list()
- for domptr in ret:
- retlist.append(virDomain(self, _obj=domptr))
-
- return retlist
-
- def listAllStoragePools(self, flags=0):
- """Returns a list of storage pool objects"""
- ret = libvirtmod.virConnectListAllStoragePools(self._o, flags)
- if ret is None:
- raise libvirtError("virConnectListAllStoragePools() failed", conn=self)
-
- retlist = list()
- for poolptr in ret:
- retlist.append(virStoragePool(self, _obj=poolptr))
-
- return retlist
-
- def listAllNetworks(self, flags=0):
- """Returns a list of network objects"""
- ret = libvirtmod.virConnectListAllNetworks(self._o, flags)
- if ret is None:
- raise libvirtError("virConnectListAllNetworks() failed", conn=self)
-
- retlist = list()
- for netptr in ret:
- retlist.append(virNetwork(self, _obj=netptr))
-
- return retlist
-
- def listAllInterfaces(self, flags=0):
- """Returns a list of interface objects"""
- ret = libvirtmod.virConnectListAllInterfaces(self._o, flags)
- if ret is None:
- raise libvirtError("virConnectListAllInterfaces() failed", conn=self)
-
- retlist = list()
- for ifaceptr in ret:
- retlist.append(virInterface(self, _obj=ifaceptr))
-
- return retlist
-
- def listAllDevices(self, flags=0):
- """Returns a list of host node device objects"""
- ret = libvirtmod.virConnectListAllNodeDevices(self._o, flags)
- if ret is None:
- raise libvirtError("virConnectListAllNodeDevices() failed", conn=self)
-
- retlist = list()
- for devptr in ret:
- retlist.append(virNodeDevice(self, _obj=devptr))
-
- return retlist
-
- def listAllNWFilters(self, flags=0):
- """Returns a list of network filter objects"""
- ret = libvirtmod.virConnectListAllNWFilters(self._o, flags)
- if ret is None:
- raise libvirtError("virConnectListAllNWFilters() failed", conn=self)
-
- retlist = list()
- for filter_ptr in ret:
- retlist.append(virNWFilter(self, _obj=filter_ptr))
-
- return retlist
-
- def listAllSecrets(self, flags=0):
- """Returns a list of secret objects"""
- ret = libvirtmod.virConnectListAllSecrets(self._o, flags)
- if ret is None:
- raise libvirtError("virConnectListAllSecrets() failed", conn=self)
-
- retlist = list()
- for secret_ptr in ret:
- retlist.append(virSecret(self, _obj=secret_ptr))
-
- return retlist
-
- def _dispatchCloseCallback(self, reason, cbData):
- """Dispatches events to python user close callback"""
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, reason, opaque)
- return 0
-
-
- def unregisterCloseCallback(self):
- """Removes a close event callback"""
- ret = libvirtmod.virConnectUnregisterCloseCallback(self._o)
- if ret == -1: raise libvirtError ('virConnectUnregisterCloseCallback() failed', conn=self)
-
- def registerCloseCallback(self, cb, opaque):
- """Adds a close event callback, providing a notification
- when a connection fails / closes"""
- cbData = { "cb": cb, "conn": self, "opaque": opaque }
- ret = libvirtmod.virConnectRegisterCloseCallback(self._o, cbData)
- if ret == -1:
- raise libvirtError ('virConnectRegisterCloseCallback() failed', conn=self)
- return ret
-
- def createXMLWithFiles(self, xmlDesc, files, flags=0):
- """Launch a new guest domain, based on an XML description similar
- to the one returned by virDomainGetXMLDesc()
- This function may require privileged access to the hypervisor.
- The domain is not persistent, so its definition will disappear when it
- is destroyed, or if the host is restarted (see virDomainDefineXML() to
- define persistent domains).
-
- @files provides an array of file descriptors which will be
- made available to the 'init' process of the guest. The file
- handles exposed to the guest will be renumbered to start
- from 3 (ie immediately following stderr). This is only
- supported for guests which use container based virtualization
- technology.
-
- If the VIR_DOMAIN_START_PAUSED flag is set, the guest domain
- will be started, but its CPUs will remain paused. The CPUs
- can later be manually started using virDomainResume.
-
- If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
- domain will be automatically destroyed when the virConnectPtr
- object is finally released. This will also happen if the
- client application crashes / loses its connection to the
- libvirtd daemon. Any domains marked for auto destroy will
- block attempts at migration, save-to-file, or snapshots. """
- ret = libvirtmod.virDomainCreateXMLWithFiles(self._o, xmlDesc, files, flags)
- if ret is None:raise libvirtError('virDomainCreateXMLWithFiles() failed', conn=self)
- __tmp = virDomain(self,_obj=ret)
- return __tmp
diff --git a/python/libvirt-override-virDomain.py b/python/libvirt-override-virDomain.py
deleted file mode 100644
index c96cc5e..0000000
--- a/python/libvirt-override-virDomain.py
+++ /dev/null
@@ -1,49 +0,0 @@
- def listAllSnapshots(self, flags=0):
- """List all snapshots and returns a list of snapshot objects"""
- ret = libvirtmod.virDomainListAllSnapshots(self._o, flags)
- if ret is None:
- raise libvirtError("virDomainListAllSnapshots() failed", conn=self)
-
- retlist = list()
- for snapptr in ret:
- retlist.append(virDomainSnapshot(self, _obj=snapptr))
-
- return retlist
-
-
- def createWithFiles(self, files, flags=0):
- """Launch a defined domain. If the call succeeds the domain moves from the
- defined to the running domains pools.
-
- @files provides an array of file descriptors which will be
- made available to the 'init' process of the guest. The file
- handles exposed to the guest will be renumbered to start
- from 3 (ie immediately following stderr). This is only
- supported for guests which use container based virtualization
- technology.
-
- If the VIR_DOMAIN_START_PAUSED flag is set, or if the guest domain
- has a managed save image that requested paused state (see
- virDomainManagedSave()) the guest domain will be started, but its
- CPUs will remain paused. The CPUs can later be manually started
- using virDomainResume(). In all other cases, the guest domain will
- be running.
-
- If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
- domain will be automatically destroyed when the virConnectPtr
- object is finally released. This will also happen if the
- client application crashes / loses its connection to the
- libvirtd daemon. Any domains marked for auto destroy will
- block attempts at migration, save-to-file, or snapshots.
-
- If the VIR_DOMAIN_START_BYPASS_CACHE flag is set, and there is a
- managed save file for this domain (created by virDomainManagedSave()),
- then libvirt will attempt to bypass the file system cache while restoring
- the file, or fail if it cannot do so for the given system; this can allow
- less pressure on file system cache, but also risks slowing loads from NFS.
-
- If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
- file for this domain is discarded, and the domain boots from scratch. """
- ret = libvirtmod.virDomainCreateWithFiles(self._o, files, flags)
- if ret == -1: raise libvirtError ('virDomainCreateWithFiles() failed', dom=self)
- return ret
diff --git a/python/libvirt-override-virDomainSnapshot.py b/python/libvirt-override-virDomainSnapshot.py
deleted file mode 100644
index ec53358..0000000
--- a/python/libvirt-override-virDomainSnapshot.py
+++ /dev/null
@@ -1,19 +0,0 @@
- def getConnect(self):
- """Get the connection that owns the domain that a snapshot was created for"""
- return self.connect()
-
- def getDomain(self):
- """Get the domain that a snapshot was created for"""
- return self.domain()
-
- def listAllChildren(self, flags=0):
- """List all child snapshots and returns a list of snapshot objects"""
- ret = libvirtmod.virDomainSnapshotListAllChildren(self._o, flags)
- if ret is None:
- raise libvirtError("virDomainSnapshotListAllChildren() failed", conn=self)
-
- retlist = list()
- for snapptr in ret:
- retlist.append(virDomainSnapshot(self, _obj=snapptr))
-
- return retlist
diff --git a/python/libvirt-override-virStoragePool.py b/python/libvirt-override-virStoragePool.py
deleted file mode 100644
index 325e403..0000000
--- a/python/libvirt-override-virStoragePool.py
+++ /dev/null
@@ -1,11 +0,0 @@
- def listAllVolumes(self, flags=0):
- """List all storage volumes and returns a list of storage volume objects"""
- ret = libvirtmod.virStoragePoolListAllVolumes(self._o, flags)
- if ret is None:
- raise libvirtError("virStoragePoolListAllVolumes() failed", conn=self)
-
- retlist = list()
- for volptr in ret:
- retlist.append(virStorageVol(self, _obj=volptr))
-
- return retlist
diff --git a/python/libvirt-override-virStream.py b/python/libvirt-override-virStream.py
deleted file mode 100644
index 53000da..0000000
--- a/python/libvirt-override-virStream.py
+++ /dev/null
@@ -1,125 +0,0 @@
- def __del__(self):
- try:
- if self.cb:
- libvirtmod.virStreamEventRemoveCallback(self._o)
- except AttributeError:
- pass
-
- if self._o is not None:
- libvirtmod.virStreamFree(self._o)
- self._o = None
-
- def _dispatchStreamEventCallback(self, events, cbData):
- """
- Dispatches events to python user's stream event callbacks
- """
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(self, events, opaque)
- return 0
-
- def eventAddCallback(self, events, cb, opaque):
- self.cb = cb
- cbData = {"stream": self, "cb" : cb, "opaque" : opaque}
- ret = libvirtmod.virStreamEventAddCallback(self._o, events, cbData)
- if ret == -1: raise libvirtError ('virStreamEventAddCallback() failed')
-
- def recvAll(self, handler, opaque):
- """Receive the entire data stream, sending the data to the
- requested data sink. This is simply a convenient alternative
- to virStreamRecv, for apps that do blocking-I/o.
-
- A hypothetical handler function looks like:
-
- def handler(stream, # virStream instance
- buf, # string containing received data
- opaque): # extra data passed to recvAll as opaque
- fd = opaque
- return os.write(fd, buf)
- """
- while True:
- got = self.recv(1024*64)
- if got == -2:
- raise libvirtError("cannot use recvAll with "
- "nonblocking stream")
- if len(got) == 0:
- break
-
- try:
- ret = handler(self, got, opaque)
- if type(ret) is int and ret < 0:
- raise RuntimeError("recvAll handler returned %d" % ret)
- except Exception, e:
- try:
- self.abort()
- except:
- pass
- raise e
-
- def sendAll(self, handler, opaque):
- """
- Send the entire data stream, reading the data from the
- requested data source. This is simply a convenient alternative
- to virStreamSend, for apps that do blocking-I/o.
-
- A hypothetical handler function looks like:
-
- def handler(stream, # virStream instance
- nbytes, # int amt of data to read
- opaque): # extra data passed to recvAll as opaque
- fd = opaque
- return os.read(fd, nbytes)
- """
- while True:
- try:
- got = handler(self, 1024*64, opaque)
- except:
- try:
- self.abort()
- except:
- pass
- raise e
-
- if got == "":
- break
-
- ret = self.send(got)
- if ret == -2:
- raise libvirtError("cannot use sendAll with "
- "nonblocking stream")
-
- def recv(self, nbytes):
- """Reads a series of bytes from the stream. This method may
- block the calling application for an arbitrary amount
- of time.
-
- Errors are not guaranteed to be reported synchronously
- with the call, but may instead be delayed until a
- subsequent call.
-
- On success, the received data is returned. On failure, an
- exception is raised. If the stream is a NONBLOCK stream and
- the request would block, integer -2 is returned.
- """
- ret = libvirtmod.virStreamRecv(self._o, nbytes)
- if ret is None: raise libvirtError ('virStreamRecv() failed')
- return ret
-
- def send(self, data):
- """Write a series of bytes to the stream. This method may
- block the calling application for an arbitrary amount
- of time. Once an application has finished sending data
- it should call virStreamFinish to wait for successful
- confirmation from the driver, or detect any error
-
- This method may not be used if a stream source has been
- registered
-
- Errors are not guaranteed to be reported synchronously
- with the call, but may instead be delayed until a
- subsequent call.
- """
- ret = libvirtmod.virStreamSend(self._o, data, len(data))
- if ret == -1: raise libvirtError ('virStreamSend() failed')
- return ret
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
deleted file mode 100644
index c60747d..0000000
--- a/python/libvirt-override.c
+++ /dev/null
@@ -1,7379 +0,0 @@
-/*
- * libvir.c: this modules implements the main part of the glue of the
- * libvir library and the Python interpreter. It provides the
- * entry points where an automatically generated stub is
- * unpractical
- *
- * Copyright (C) 2005, 2007-2013 Red Hat, Inc.
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-#include <config.h>
-
-/* Horrible kludge to work around even more horrible name-space pollution
- via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
- which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
-#undef HAVE_PTHREAD_H
-
-/* We want to see *_LAST enums. */
-#define VIR_ENUM_SENTINELS
-
-#include <Python.h>
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
-#include "typewrappers.h"
-#include "libvirt.h"
-#include "viralloc.h"
-#include "virtypedparam.h"
-#include "ignore-value.h"
-#include "virutil.h"
-#include "virstring.h"
-
-#ifndef __CYGWIN__
-extern void initlibvirtmod(void);
-#else
-extern void initcygvirtmod(void);
-#endif
-
-#if 0
-# define DEBUG_ERROR 1
-#endif
-
-#if DEBUG_ERROR
-# define DEBUG(fmt, ...) \
- printf(fmt, __VA_ARGS__)
-#else
-# define DEBUG(fmt, ...) \
- do {} while (0)
-#endif
-
-/* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
- is so common that we encapsulate it here. Now, each use is simply
- return VIR_PY_NONE; */
-#define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
-#define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
-#define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
-
-/* We don't want to free() returned value. As written in doc:
- * PyString_AsString returns pointer to 'internal buffer of string,
- * not a copy' and 'It must not be deallocated'. */
-static char *py_str(PyObject *obj)
-{
- PyObject *str = PyObject_Str(obj);
- if (!str) {
- PyErr_Print();
- PyErr_Clear();
- return NULL;
- };
- return PyString_AsString(str);
-}
-
-/* Helper function to convert a virTypedParameter output array into a
- * Python dictionary for return to the user. Return NULL on failure,
- * after raising a python exception. */
-static PyObject *
-getPyVirTypedParameter(const virTypedParameter *params, int nparams)
-{
- PyObject *key, *val, *info;
- size_t i;
-
- if ((info = PyDict_New()) == NULL)
- return NULL;
-
- for (i = 0; i < nparams; i++) {
- switch (params[i].type) {
- case VIR_TYPED_PARAM_INT:
- val = PyInt_FromLong(params[i].value.i);
- break;
-
- case VIR_TYPED_PARAM_UINT:
- val = PyInt_FromLong(params[i].value.ui);
- break;
-
- case VIR_TYPED_PARAM_LLONG:
- val = PyLong_FromLongLong(params[i].value.l);
- break;
-
- case VIR_TYPED_PARAM_ULLONG:
- val = PyLong_FromUnsignedLongLong(params[i].value.ul);
- break;
-
- case VIR_TYPED_PARAM_DOUBLE:
- val = PyFloat_FromDouble(params[i].value.d);
- break;
-
- case VIR_TYPED_PARAM_BOOLEAN:
- val = PyBool_FromLong(params[i].value.b);
- break;
-
- case VIR_TYPED_PARAM_STRING:
- val = libvirt_constcharPtrWrap(params[i].value.s);
- break;
-
- default:
- /* Possible if a newer server has a bug and sent stuff we
- * don't recognize. */
- PyErr_Format(PyExc_LookupError,
- "Type value \"%d\" not recognized",
- params[i].type);
- val = NULL;
- break;
- }
-
- key = libvirt_constcharPtrWrap(params[i].field);
- if (!key || !val)
- goto cleanup;
-
- if (PyDict_SetItem(info, key, val) < 0) {
- Py_DECREF(info);
- goto cleanup;
- }
-
- Py_DECREF(key);
- Py_DECREF(val);
- }
- return info;
-
-cleanup:
- Py_XDECREF(key);
- Py_XDECREF(val);
- return NULL;
-}
-
-/* Allocate a new typed parameter array with the same contents and
- * length as info, and using the array params of length nparams as
- * hints on what types to use when creating the new array. The caller
- * must NOT clear the array before freeing it, as it points into info
- * rather than allocated strings. Return NULL on failure, after
- * raising a python exception. */
-static virTypedParameterPtr ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
-setPyVirTypedParameter(PyObject *info,
- const virTypedParameter *params, int nparams)
-{
- PyObject *key, *value;
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
- int pos = 0;
-#else
- Py_ssize_t pos = 0;
-#endif
- virTypedParameterPtr temp = NULL, ret = NULL;
- Py_ssize_t size;
- size_t i;
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- /* Libvirt APIs use NULL array and 0 size as a special case;
- * setting should have at least one parameter. */
- if (size == 0) {
- PyErr_Format(PyExc_LookupError, "Dictionary must not be empty");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(ret, size) < 0) {
- PyErr_NoMemory();
- return NULL;
- }
-
- temp = &ret[0];
- while (PyDict_Next(info, &pos, &key, &value)) {
- char *keystr = NULL;
-
- if ((keystr = PyString_AsString(key)) == NULL)
- goto cleanup;
-
- for (i = 0; i < nparams; i++) {
- if (STREQ(params[i].field, keystr))
- break;
- }
- if (i == nparams) {
- PyErr_Format(PyExc_LookupError,
- "Attribute name \"%s\" could not be recognized",
- keystr);
- goto cleanup;
- }
-
- ignore_value(virStrcpyStatic(temp->field, keystr));
- temp->type = params[i].type;
-
- switch (params[i].type) {
- case VIR_TYPED_PARAM_INT:
- if (libvirt_intUnwrap(value, &temp->value.i) < 0)
- goto cleanup;
- break;
-
- case VIR_TYPED_PARAM_UINT:
- if (libvirt_uintUnwrap(value, &temp->value.ui) < 0)
- goto cleanup;
- break;
-
- case VIR_TYPED_PARAM_LLONG:
- if (libvirt_longlongUnwrap(value, &temp->value.l) < 0)
- goto cleanup;
- break;
-
- case VIR_TYPED_PARAM_ULLONG:
- if (libvirt_ulonglongUnwrap(value, &temp->value.ul) < 0)
- goto cleanup;
- break;
-
- case VIR_TYPED_PARAM_DOUBLE:
- if (libvirt_doubleUnwrap(value, &temp->value.d) < 0)
- goto cleanup;
- break;
-
- case VIR_TYPED_PARAM_BOOLEAN:
- {
- bool b;
- if (libvirt_boolUnwrap(value, &b) < 0)
- goto cleanup;
- temp->value.b = b;
- break;
- }
- case VIR_TYPED_PARAM_STRING:
- {
- char *string_val = PyString_AsString(value);
- if (!string_val)
- goto cleanup;
- temp->value.s = string_val;
- break;
- }
-
- default:
- /* Possible if a newer server has a bug and sent stuff we
- * don't recognize. */
- PyErr_Format(PyExc_LookupError,
- "Type value \"%d\" not recognized",
- params[i].type);
- goto cleanup;
- }
-
- temp++;
- }
- return ret;
-
-cleanup:
- VIR_FREE(ret);
- return NULL;
-}
-
-
-typedef struct {
- const char *name;
- int type;
-} virPyTypedParamsHint;
-typedef virPyTypedParamsHint *virPyTypedParamsHintPtr;
-
-/* Automatically convert dict into type parameters based on types reported
- * by python. All integer types are converted into LLONG (in case of a negative
- * value) or ULLONG (in case of a positive value). If you need different
- * handling, use @hints to explicitly specify what types should be used for
- * specific parameters.
- */
-static int
-ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
-virPyDictToTypedParams(PyObject *dict,
- virTypedParameterPtr *ret_params,
- int *ret_nparams,
- virPyTypedParamsHintPtr hints,
- int nhints)
-{
- PyObject *key;
- PyObject *value;
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 4
- int pos = 0;
-#else
- Py_ssize_t pos = 0;
-#endif
- virTypedParameterPtr params = NULL;
- size_t i;
- int n = 0;
- int max = 0;
- int ret = -1;
-
- *ret_params = NULL;
- *ret_nparams = 0;
-
- if (PyDict_Size(dict) < 0)
- return -1;
-
- while (PyDict_Next(dict, &pos, &key, &value)) {
- char *keystr;
- int type = -1;
-
- if (!(keystr = PyString_AsString(key)))
- goto cleanup;
-
- for (i = 0; i < nhints; i++) {
- if (STREQ(hints[i].name, keystr)) {
- type = hints[i].type;
- break;
- }
- }
-
- if (type == -1) {
- if (PyString_Check(value)) {
- type = VIR_TYPED_PARAM_STRING;
- } else if (PyBool_Check(value)) {
- type = VIR_TYPED_PARAM_BOOLEAN;
- } else if (PyLong_Check(value)) {
- unsigned long long ull = PyLong_AsUnsignedLongLong(value);
- if (ull == (unsigned long long) -1 && PyErr_Occurred())
- type = VIR_TYPED_PARAM_LLONG;
- else
- type = VIR_TYPED_PARAM_ULLONG;
- } else if (PyInt_Check(value)) {
- if (PyInt_AS_LONG(value) < 0)
- type = VIR_TYPED_PARAM_LLONG;
- else
- type = VIR_TYPED_PARAM_ULLONG;
- } else if (PyFloat_Check(value)) {
- type = VIR_TYPED_PARAM_DOUBLE;
- }
- }
-
- if (type == -1) {
- PyErr_Format(PyExc_TypeError,
- "Unknown type of \"%s\" field", keystr);
- goto cleanup;
- }
-
- switch ((virTypedParameterType) type) {
- case VIR_TYPED_PARAM_INT:
- {
- int val;
- if (libvirt_intUnwrap(value, &val) < 0 ||
- virTypedParamsAddInt(¶ms, &n, &max, keystr, val) < 0)
- goto cleanup;
- break;
- }
- case VIR_TYPED_PARAM_UINT:
- {
- unsigned int val;
- if (libvirt_uintUnwrap(value, &val) < 0 ||
- virTypedParamsAddUInt(¶ms, &n, &max, keystr, val) < 0)
- goto cleanup;
- break;
- }
- case VIR_TYPED_PARAM_LLONG:
- {
- long long val;
- if (libvirt_longlongUnwrap(value, &val) < 0 ||
- virTypedParamsAddLLong(¶ms, &n, &max, keystr, val) < 0)
- goto cleanup;
- break;
- }
- case VIR_TYPED_PARAM_ULLONG:
- {
- unsigned long long val;
- if (libvirt_ulonglongUnwrap(value, &val) < 0 ||
- virTypedParamsAddULLong(¶ms, &n, &max, keystr, val) < 0)
- goto cleanup;
- break;
- }
- case VIR_TYPED_PARAM_DOUBLE:
- {
- double val;
- if (libvirt_doubleUnwrap(value, &val) < 0 ||
- virTypedParamsAddDouble(¶ms, &n, &max, keystr, val) < 0)
- goto cleanup;
- break;
- }
- case VIR_TYPED_PARAM_BOOLEAN:
- {
- bool val;
- if (libvirt_boolUnwrap(value, &val) < 0 ||
- virTypedParamsAddBoolean(¶ms, &n, &max, keystr, val) < 0)
- goto cleanup;
- break;
- }
- case VIR_TYPED_PARAM_STRING:
- {
- char *val = PyString_AsString(value);
- if (!val ||
- virTypedParamsAddString(¶ms, &n, &max, keystr, val) < 0)
- goto cleanup;
- break;
- }
- case VIR_TYPED_PARAM_LAST:
- break; /* unreachable */
- }
- }
-
- *ret_params = params;
- *ret_nparams = n;
- params = NULL;
- ret = 0;
-
-cleanup:
- virTypedParamsFree(params, n);
- return ret;
-}
-
-
-/*
- * Utility function to retrieve the number of node CPUs present.
- * It first tries virGetNodeCPUMap, which will return the
- * number reliably, if available.
- * As a fallback and for compatibility with backlevel libvirt
- * versions virGetNodeInfo will be called to calculate the
- * CPU number, which has the potential to return a too small
- * number if some host CPUs are offline.
- */
-static int
-getPyNodeCPUCount(virConnectPtr conn) {
- int i_retval;
- virNodeInfo nodeinfo;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeGetCPUMap(conn, NULL, NULL, 0);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- /* fallback: use nodeinfo */
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeGetInfo(conn, &nodeinfo);
- LIBVIRT_END_ALLOW_THREADS;
- if (i_retval < 0)
- goto cleanup;
-
- i_retval = VIR_NODEINFO_MAXCPUS(nodeinfo);
- }
-
-cleanup:
- return i_retval;
-}
-
-/************************************************************************
- * *
- * Statistics *
- * *
- ************************************************************************/
-
-static PyObject *
-libvirt_virDomainBlockStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- virDomainPtr domain;
- PyObject *pyobj_domain;
- char * path;
- int c_retval;
- virDomainBlockStatsStruct stats;
- PyObject *info;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainBlockStats",
- &pyobj_domain, &path))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainBlockStats(domain, path, &stats, sizeof(stats));
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- /* convert to a Python tuple of long objects */
- if ((info = PyTuple_New(5)) == NULL)
- return VIR_PY_NONE;
- PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rd_req));
- PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rd_bytes));
- PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.wr_req));
- PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.wr_bytes));
- PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.errs));
- return info;
-}
-
-static PyObject *
-libvirt_virDomainBlockStatsFlags(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- unsigned int flags;
- virTypedParameterPtr params;
- const char *path;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainBlockStatsFlags",
- &pyobj_domain, &path, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainBlockStatsFlags(domain, path, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainBlockStatsFlags(domain, path, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *totalbool;
- PyObject *cpu, *total;
- PyObject *ret = NULL;
- PyObject *error = NULL;
- int ncpus = -1, start_cpu = 0;
- int sumparams = 0, nparams = -1;
- size_t i;
- int i_retval;
- unsigned int flags;
- bool totalflag;
- virTypedParameterPtr params = NULL, cpuparams;
-
- if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainGetCPUStats",
- &pyobj_domain, &totalbool, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (libvirt_boolUnwrap(totalbool, &totalflag) < 0)
- return NULL;
-
- if ((ret = PyList_New(0)) == NULL)
- return NULL;
-
- if (!totalflag) {
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ncpus = virDomainGetCPUStats(domain, NULL, 0, 0, 0, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (ncpus < 0) {
- error = VIR_PY_NONE;
- goto error;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- nparams = virDomainGetCPUStats(domain, NULL, 0, 0, 1, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (nparams < 0) {
- error = VIR_PY_NONE;
- goto error;
- }
-
- sumparams = nparams * MIN(ncpus, 128);
-
- if (VIR_ALLOC_N_QUIET(params, sumparams) < 0) {
- error = PyErr_NoMemory();
- goto error;
- }
-
- while (ncpus) {
- int queried_ncpus = MIN(ncpus, 128);
- if (nparams) {
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetCPUStats(domain, params,
- nparams, start_cpu, queried_ncpus, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- error = VIR_PY_NONE;
- goto error;
- }
- } else {
- i_retval = 0;
- }
-
- for (i = 0; i < queried_ncpus; i++) {
- cpuparams = ¶ms[i * nparams];
- if ((cpu = getPyVirTypedParameter(cpuparams, i_retval)) == NULL) {
- goto error;
- }
-
- if (PyList_Append(ret, cpu) < 0) {
- Py_DECREF(cpu);
- goto error;
- }
- Py_DECREF(cpu);
- }
-
- start_cpu += queried_ncpus;
- ncpus -= queried_ncpus;
- virTypedParamsClear(params, sumparams);
- }
- } else {
- LIBVIRT_BEGIN_ALLOW_THREADS;
- nparams = virDomainGetCPUStats(domain, NULL, 0, -1, 1, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (nparams < 0) {
- error = VIR_PY_NONE;
- goto error;
- }
-
- if (nparams) {
- sumparams = nparams;
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0) {
- error = PyErr_NoMemory();
- goto error;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetCPUStats(domain, params, nparams, -1, 1, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- error = VIR_PY_NONE;
- goto error;
- }
- } else {
- i_retval = 0;
- }
-
- if ((total = getPyVirTypedParameter(params, i_retval)) == NULL) {
- goto error;
- }
- if (PyList_Append(ret, total) < 0) {
- Py_DECREF(total);
- goto error;
- }
- Py_DECREF(total);
- }
-
- virTypedParamsFree(params, sumparams);
- return ret;
-
-error:
- virTypedParamsFree(params, sumparams);
- Py_DECREF(ret);
- return error;
-}
-
-static PyObject *
-libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- virDomainPtr domain;
- PyObject *pyobj_domain;
- char * path;
- int c_retval;
- virDomainInterfaceStatsStruct stats;
- PyObject *info;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz:virDomainInterfaceStats",
- &pyobj_domain, &path))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainInterfaceStats(domain, path, &stats, sizeof(stats));
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- /* convert to a Python tuple of long objects */
- if ((info = PyTuple_New(8)) == NULL)
- return VIR_PY_NONE;
- PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rx_bytes));
- PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rx_packets));
- PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.rx_errs));
- PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.rx_drop));
- PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.tx_bytes));
- PyTuple_SetItem(info, 5, PyLong_FromLongLong(stats.tx_packets));
- PyTuple_SetItem(info, 6, PyLong_FromLongLong(stats.tx_errs));
- PyTuple_SetItem(info, 7, PyLong_FromLongLong(stats.tx_drop));
- return info;
-}
-
-static PyObject *
-libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- virDomainPtr domain;
- PyObject *pyobj_domain;
- unsigned int nr_stats;
- size_t i;
- virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
- PyObject *info;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainMemoryStats", &pyobj_domain))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- nr_stats = virDomainMemoryStats(domain, stats,
- VIR_DOMAIN_MEMORY_STAT_NR, 0);
- if (nr_stats == -1)
- return VIR_PY_NONE;
-
- /* convert to a Python dictionary */
- if ((info = PyDict_New()) == NULL)
- return VIR_PY_NONE;
-
- for (i = 0; i < nr_stats; i++) {
- if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_IN)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("swap_in"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_OUT)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("swap_out"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("major_fault"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("minor_fault"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_UNUSED)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("unused"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_AVAILABLE)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("available"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("actual"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_RSS)
- PyDict_SetItem(info, libvirt_constcharPtrWrap("rss"),
- PyLong_FromUnsignedLongLong(stats[i].val));
- }
- return info;
-}
-
-static PyObject *
-libvirt_virDomainGetSchedulerType(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- char *c_retval;
- int nparams;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetScedulerType",
- &pyobj_domain))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetSchedulerType(domain, &nparams);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval == NULL)
- return VIR_PY_NONE;
-
- /* convert to a Python tuple of long objects */
- if ((info = PyTuple_New(2)) == NULL) {
- VIR_FREE(c_retval);
- return VIR_PY_NONE;
- }
-
- PyTuple_SetItem(info, 0, libvirt_constcharPtrWrap(c_retval));
- PyTuple_SetItem(info, 1, PyInt_FromLong((long)nparams));
- VIR_FREE(c_retval);
- return info;
-}
-
-static PyObject *
-libvirt_virDomainGetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- char *c_retval;
- int i_retval;
- int nparams = 0;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetScedulerParameters",
- &pyobj_domain))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetSchedulerType(domain, &nparams);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == NULL)
- return VIR_PY_NONE;
- VIR_FREE(c_retval);
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetSchedulerParameters(domain, params, &nparams);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- char *c_retval;
- int i_retval;
- int nparams = 0;
- unsigned int flags;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetScedulerParametersFlags",
- &pyobj_domain, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetSchedulerType(domain, &nparams);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == NULL)
- return VIR_PY_NONE;
- VIR_FREE(c_retval);
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetSchedulerParametersFlags(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- PyObject *ret = NULL;
- char *c_retval;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args, (char *)"OO:virDomainSetScedulerParameters",
- &pyobj_domain, &info))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetSchedulerType(domain, &nparams);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == NULL)
- return VIR_PY_INT_FAIL;
- VIR_FREE(c_retval);
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "Domain has no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetSchedulerParameters(domain, params, &nparams);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainSetSchedulerParameters(domain, new_params, size);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetSchedulerParametersFlags(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- PyObject *ret = NULL;
- char *c_retval;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args,
- (char *)"OOi:virDomainSetScedulerParametersFlags",
- &pyobj_domain, &info, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetSchedulerType(domain, &nparams);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == NULL)
- return VIR_PY_INT_FAIL;
- VIR_FREE(c_retval);
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "Domain has no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetSchedulerParametersFlags(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainSetSchedulerParametersFlags(domain, new_params, size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args,
- (char *)"OOi:virDomainSetBlkioParameters",
- &pyobj_domain, &info, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlkioParameters(domain, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "Domain has no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlkioParameters(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainSetBlkioParameters(domain, new_params, size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- unsigned int flags;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetBlkioParameters",
- &pyobj_domain, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlkioParameters(domain, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlkioParameters(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args,
- (char *)"OOi:virDomainSetMemoryParameters",
- &pyobj_domain, &info, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetMemoryParameters(domain, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "Domain has no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetMemoryParameters(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainSetMemoryParameters(domain, new_params, size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- unsigned int flags;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetMemoryParameters",
- &pyobj_domain, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetMemoryParameters(domain, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetMemoryParameters(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetNumaParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args,
- (char *)"OOi:virDomainSetNumaParameters",
- &pyobj_domain, &info, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetNumaParameters(domain, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "Domain has no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetNumaParameters(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainSetNumaParameters(domain, new_params, size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetNumaParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- unsigned int flags;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetNumaParameters",
- &pyobj_domain, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetNumaParameters(domain, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetNumaParameters(domain, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainSetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- unsigned int flags;
- const char *device = NULL;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args,
- (char *)"OzOi:virDomainSetInterfaceParameters",
- &pyobj_domain, &device, &info, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetInterfaceParameters(domain, device, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "Domain has no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetInterfaceParameters(domain, device, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainSetInterfaceParameters(domain, device, new_params, size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- unsigned int flags;
- const char *device = NULL;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetInterfaceParameters",
- &pyobj_domain, &device, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetInterfaceParameters(domain, device, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetInterfaceParameters(domain, device, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *pyretval = NULL, *pycpuinfo = NULL, *pycpumap = NULL;
- PyObject *error = NULL;
- virDomainInfo dominfo;
- virVcpuInfoPtr cpuinfo = NULL;
- unsigned char *cpumap = NULL;
- size_t cpumaplen, i;
- int i_retval, cpunum;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetVcpus",
- &pyobj_domain))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
- return VIR_PY_INT_FAIL;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetInfo(domain, &dominfo);
- LIBVIRT_END_ALLOW_THREADS;
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- if (VIR_ALLOC_N_QUIET(cpuinfo, dominfo.nrVirtCpu) < 0)
- return PyErr_NoMemory();
-
- cpumaplen = VIR_CPU_MAPLEN(cpunum);
- if (xalloc_oversized(dominfo.nrVirtCpu, cpumaplen) ||
- VIR_ALLOC_N_QUIET(cpumap, dominfo.nrVirtCpu * cpumaplen) < 0) {
- error = PyErr_NoMemory();
- goto cleanup;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetVcpus(domain,
- cpuinfo, dominfo.nrVirtCpu,
- cpumap, cpumaplen);
- LIBVIRT_END_ALLOW_THREADS;
- if (i_retval < 0) {
- error = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- /* convert to a Python tuple of long objects */
- if ((pyretval = PyTuple_New(2)) == NULL)
- goto cleanup;
- if ((pycpuinfo = PyList_New(dominfo.nrVirtCpu)) == NULL)
- goto cleanup;
- if ((pycpumap = PyList_New(dominfo.nrVirtCpu)) == NULL)
- goto cleanup;
-
- for (i = 0; i < dominfo.nrVirtCpu; i++) {
- PyObject *info = PyTuple_New(4);
- PyObject *item = NULL;
-
- if (info == NULL)
- goto cleanup;
-
- if ((item = PyInt_FromLong((long)cpuinfo[i].number)) == NULL ||
- PyTuple_SetItem(info, 0, item) < 0)
- goto itemError;
-
- if ((item = PyInt_FromLong((long)cpuinfo[i].state)) == NULL ||
- PyTuple_SetItem(info, 1, item) < 0)
- goto itemError;
-
- if ((item = PyLong_FromLongLong((long long)cpuinfo[i].cpuTime)) == NULL ||
- PyTuple_SetItem(info, 2, item) < 0)
- goto itemError;
-
- if ((item = PyInt_FromLong((long)cpuinfo[i].cpu)) == NULL ||
- PyTuple_SetItem(info, 3, item) < 0)
- goto itemError;
-
- if (PyList_SetItem(pycpuinfo, i, info) < 0)
- goto itemError;
-
- continue;
- itemError:
- Py_DECREF(info);
- Py_XDECREF(item);
- goto cleanup;
- }
- for (i = 0; i < dominfo.nrVirtCpu; i++) {
- PyObject *info = PyTuple_New(cpunum);
- size_t j;
- if (info == NULL)
- goto cleanup;
- for (j = 0; j < cpunum; j++) {
- PyObject *item = NULL;
- if ((item = PyBool_FromLong(VIR_CPU_USABLE(cpumap, cpumaplen, i, j))) == NULL ||
- PyTuple_SetItem(info, j, item) < 0) {
- Py_DECREF(info);
- Py_XDECREF(item);
- goto cleanup;
- }
- }
- if (PyList_SetItem(pycpumap, i, info) < 0) {
- Py_DECREF(info);
- goto cleanup;
- }
- }
- if (PyTuple_SetItem(pyretval, 0, pycpuinfo) < 0 ||
- PyTuple_SetItem(pyretval, 1, pycpumap) < 0)
- goto cleanup;
-
- VIR_FREE(cpuinfo);
- VIR_FREE(cpumap);
-
- return pyretval;
-
-cleanup:
- VIR_FREE(cpuinfo);
- VIR_FREE(cpumap);
- Py_XDECREF(pyretval);
- Py_XDECREF(pycpuinfo);
- Py_XDECREF(pycpumap);
- return error;
-}
-
-
-static PyObject *
-libvirt_virDomainPinVcpu(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *pycpumap;
- PyObject *ret = NULL;
- unsigned char *cpumap;
- int cpumaplen, vcpu, tuple_size, cpunum;
- size_t i;
- int i_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"OiO:virDomainPinVcpu",
- &pyobj_domain, &vcpu, &pycpumap))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
- return VIR_PY_INT_FAIL;
-
- if (PyTuple_Check(pycpumap)) {
- tuple_size = PyTuple_Size(pycpumap);
- if (tuple_size == -1)
- return ret;
- } else {
- PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
- return ret;
- }
-
- cpumaplen = VIR_CPU_MAPLEN(cpunum);
- if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
- return PyErr_NoMemory();
-
- for (i = 0; i < tuple_size; i++) {
- PyObject *flag = PyTuple_GetItem(pycpumap, i);
- bool b;
-
- if (!flag || libvirt_boolUnwrap(flag, &b) < 0)
- goto cleanup;
-
- if (b)
- VIR_USE_CPU(cpumap, i);
- else
- VIR_UNUSE_CPU(cpumap, i);
- }
-
- for (; i < cpunum; i++)
- VIR_UNUSE_CPU(cpumap, i);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainPinVcpu(domain, vcpu, cpumap, cpumaplen);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- VIR_FREE(cpumap);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainPinVcpuFlags(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *pycpumap;
- PyObject *ret = NULL;
- unsigned char *cpumap;
- int cpumaplen, vcpu, tuple_size, cpunum;
- size_t i;
- unsigned int flags;
- int i_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"OiOi:virDomainPinVcpuFlags",
- &pyobj_domain, &vcpu, &pycpumap, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
- return VIR_PY_INT_FAIL;
-
- if (PyTuple_Check(pycpumap)) {
- tuple_size = PyTuple_Size(pycpumap);
- if (tuple_size == -1)
- return ret;
- } else {
- PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
- return ret;
- }
-
- cpumaplen = VIR_CPU_MAPLEN(cpunum);
- if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
- return PyErr_NoMemory();
-
- for (i = 0; i < tuple_size; i++) {
- PyObject *flag = PyTuple_GetItem(pycpumap, i);
- bool b;
-
- if (!flag || libvirt_boolUnwrap(flag, &b) < 0)
- goto cleanup;
-
- if (b)
- VIR_USE_CPU(cpumap, i);
- else
- VIR_UNUSE_CPU(cpumap, i);
- }
-
- for (; i < cpunum; i++)
- VIR_UNUSE_CPU(cpumap, i);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainPinVcpuFlags(domain, vcpu, cpumap, cpumaplen, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- VIR_FREE(cpumap);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetVcpuPinInfo(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- virDomainPtr domain;
- PyObject *pyobj_domain, *pycpumaps = NULL;
- virDomainInfo dominfo;
- unsigned char *cpumaps = NULL;
- size_t cpumaplen, vcpu, pcpu;
- unsigned int flags;
- int i_retval, cpunum;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetVcpuPinInfo",
- &pyobj_domain, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
- return VIR_PY_INT_FAIL;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetInfo(domain, &dominfo);
- LIBVIRT_END_ALLOW_THREADS;
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- cpumaplen = VIR_CPU_MAPLEN(cpunum);
- if (xalloc_oversized(dominfo.nrVirtCpu, cpumaplen) ||
- VIR_ALLOC_N_QUIET(cpumaps, dominfo.nrVirtCpu * cpumaplen) < 0)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetVcpuPinInfo(domain, dominfo.nrVirtCpu,
- cpumaps, cpumaplen, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (i_retval < 0)
- goto cleanup;
-
- if ((pycpumaps = PyList_New(dominfo.nrVirtCpu)) == NULL)
- goto cleanup;
-
- for (vcpu = 0; vcpu < dominfo.nrVirtCpu; vcpu++) {
- PyObject *mapinfo = PyTuple_New(cpunum);
- if (mapinfo == NULL)
- goto cleanup;
-
- for (pcpu = 0; pcpu < cpunum; pcpu++) {
- PyTuple_SetItem(mapinfo, pcpu,
- PyBool_FromLong(VIR_CPU_USABLE(cpumaps, cpumaplen, vcpu, pcpu)));
- }
- PyList_SetItem(pycpumaps, vcpu, mapinfo);
- }
-
- VIR_FREE(cpumaps);
-
- return pycpumaps;
-
-cleanup:
- VIR_FREE(cpumaps);
-
- Py_XDECREF(pycpumaps);
-
- return VIR_PY_NONE;
-}
-
-
-static PyObject *
-libvirt_virDomainPinEmulator(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *pycpumap;
- unsigned char *cpumap = NULL;
- int cpumaplen, tuple_size, cpunum;
- size_t i;
- int i_retval;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainPinVcpu",
- &pyobj_domain, &pycpumap, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
- return VIR_PY_INT_FAIL;
-
- cpumaplen = VIR_CPU_MAPLEN(cpunum);
-
- if (!PyTuple_Check(pycpumap)) {
- PyErr_SetString(PyExc_TypeError, "Unexpected type, tuple is required");
- return NULL;
- }
-
- if ((tuple_size = PyTuple_Size(pycpumap)) == -1)
- return NULL;
-
- if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
- return PyErr_NoMemory();
-
- for (i = 0; i < tuple_size; i++) {
- PyObject *flag = PyTuple_GetItem(pycpumap, i);
- bool b;
-
- if (!flag || libvirt_boolUnwrap(flag, &b) < 0) {
- VIR_FREE(cpumap);
- return VIR_PY_INT_FAIL;
- }
-
- if (b)
- VIR_USE_CPU(cpumap, i);
- else
- VIR_UNUSE_CPU(cpumap, i);
- }
-
- for (; i < cpunum; i++)
- VIR_UNUSE_CPU(cpumap, i);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainPinEmulator(domain, cpumap, cpumaplen, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- VIR_FREE(cpumap);
-
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- return VIR_PY_INT_SUCCESS;
-}
-
-
-static PyObject *
-libvirt_virDomainGetEmulatorPinInfo(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *pycpumap;
- unsigned char *cpumap;
- size_t cpumaplen;
- size_t pcpu;
- unsigned int flags;
- int ret;
- int cpunum;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainEmulatorPinInfo",
- &pyobj_domain, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((cpunum = getPyNodeCPUCount(virDomainGetConnect(domain))) < 0)
- return VIR_PY_NONE;
-
- cpumaplen = VIR_CPU_MAPLEN(cpunum);
-
- if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virDomainGetEmulatorPinInfo(domain, cpumap, cpumaplen, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (ret < 0) {
- VIR_FREE(cpumap);
- return VIR_PY_NONE;
- }
-
- if (!(pycpumap = PyTuple_New(cpunum))) {
- VIR_FREE(cpumap);
- return NULL;
- }
-
- for (pcpu = 0; pcpu < cpunum; pcpu++)
- PyTuple_SET_ITEM(pycpumap, pcpu,
- PyBool_FromLong(VIR_CPU_USABLE(cpumap, cpumaplen,
- 0, pcpu)));
-
- VIR_FREE(cpumap);
- return pycpumap;
-}
-
-
-/************************************************************************
- * *
- * Global error handler at the Python level *
- * *
- ************************************************************************/
-
-static PyObject *libvirt_virPythonErrorFuncHandler = NULL;
-static PyObject *libvirt_virPythonErrorFuncCtxt = NULL;
-
-static PyObject *
-libvirt_virGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args ATTRIBUTE_UNUSED)
-{
- virError *err;
- PyObject *info;
-
- if ((err = virGetLastError()) == NULL)
- return VIR_PY_NONE;
-
- if ((info = PyTuple_New(9)) == NULL)
- return VIR_PY_NONE;
- PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
- PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
- PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
- PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
- PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
- PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
- PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
- PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
- PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
-
- return info;
-}
-
-static PyObject *
-libvirt_virConnGetLastError(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- virError *err;
- PyObject *info;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConGetLastError", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- err = virConnGetLastError(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (err == NULL)
- return VIR_PY_NONE;
-
- if ((info = PyTuple_New(9)) == NULL)
- return VIR_PY_NONE;
- PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
- PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
- PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
- PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
- PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
- PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
- PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
- PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
- PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
-
- return info;
-}
-
-static void
-libvirt_virErrorFuncHandler(ATTRIBUTE_UNUSED void *ctx, virErrorPtr err)
-{
- PyObject *list, *info;
- PyObject *result;
-
- DEBUG("libvirt_virErrorFuncHandler(%p, %s, ...) called\n", ctx,
- err->message);
-
- if ((err == NULL) || (err->code == VIR_ERR_OK))
- return;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- if ((libvirt_virPythonErrorFuncHandler == NULL) ||
- (libvirt_virPythonErrorFuncHandler == Py_None)) {
- virDefaultErrorFunc(err);
- } else {
- list = PyTuple_New(2);
- info = PyTuple_New(9);
- PyTuple_SetItem(list, 0, libvirt_virPythonErrorFuncCtxt);
- PyTuple_SetItem(list, 1, info);
- Py_XINCREF(libvirt_virPythonErrorFuncCtxt);
- PyTuple_SetItem(info, 0, PyInt_FromLong((long) err->code));
- PyTuple_SetItem(info, 1, PyInt_FromLong((long) err->domain));
- PyTuple_SetItem(info, 2, libvirt_constcharPtrWrap(err->message));
- PyTuple_SetItem(info, 3, PyInt_FromLong((long) err->level));
- PyTuple_SetItem(info, 4, libvirt_constcharPtrWrap(err->str1));
- PyTuple_SetItem(info, 5, libvirt_constcharPtrWrap(err->str2));
- PyTuple_SetItem(info, 6, libvirt_constcharPtrWrap(err->str3));
- PyTuple_SetItem(info, 7, PyInt_FromLong((long) err->int1));
- PyTuple_SetItem(info, 8, PyInt_FromLong((long) err->int2));
- /* TODO pass conn and dom if available */
- result = PyEval_CallObject(libvirt_virPythonErrorFuncHandler, list);
- Py_XDECREF(list);
- Py_XDECREF(result);
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virRegisterErrorHandler(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- PyObject *py_retval;
- PyObject *pyobj_f;
- PyObject *pyobj_ctx;
-
- if (!PyArg_ParseTuple
- (args, (char *) "OO:xmlRegisterErrorHandler", &pyobj_f,
- &pyobj_ctx))
- return NULL;
-
- DEBUG("libvirt_virRegisterErrorHandler(%p, %p) called\n", pyobj_ctx,
- pyobj_f);
-
- virSetErrorFunc(NULL, libvirt_virErrorFuncHandler);
- if (libvirt_virPythonErrorFuncHandler != NULL) {
- Py_XDECREF(libvirt_virPythonErrorFuncHandler);
- }
- if (libvirt_virPythonErrorFuncCtxt != NULL) {
- Py_XDECREF(libvirt_virPythonErrorFuncCtxt);
- }
-
- if ((pyobj_f == Py_None) && (pyobj_ctx == Py_None)) {
- libvirt_virPythonErrorFuncHandler = NULL;
- libvirt_virPythonErrorFuncCtxt = NULL;
- } else {
- Py_XINCREF(pyobj_ctx);
- Py_XINCREF(pyobj_f);
-
- /* TODO: check f is a function ! */
- libvirt_virPythonErrorFuncHandler = pyobj_f;
- libvirt_virPythonErrorFuncCtxt = pyobj_ctx;
- }
-
- py_retval = libvirt_intWrap(1);
- return py_retval;
-}
-
-static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
- unsigned int ncred,
- void *cbdata) {
- PyObject *list;
- PyObject *pycred;
- PyObject *pyauth = (PyObject *)cbdata;
- PyObject *pycbdata;
- PyObject *pycb;
- PyObject *pyret;
- int ret = -1;
- size_t i;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- pycb = PyList_GetItem(pyauth, 1);
- pycbdata = PyList_GetItem(pyauth, 2);
-
- list = PyTuple_New(2);
- pycred = PyTuple_New(ncred);
- for (i = 0; i < ncred; i++) {
- PyObject *pycreditem;
- pycreditem = PyList_New(5);
- Py_INCREF(Py_None);
- PyTuple_SetItem(pycred, i, pycreditem);
- PyList_SetItem(pycreditem, 0, PyInt_FromLong((long) cred[i].type));
- PyList_SetItem(pycreditem, 1, PyString_FromString(cred[i].prompt));
- if (cred[i].challenge) {
- PyList_SetItem(pycreditem, 2, PyString_FromString(cred[i].challenge));
- } else {
- Py_INCREF(Py_None);
- PyList_SetItem(pycreditem, 2, Py_None);
- }
- if (cred[i].defresult) {
- PyList_SetItem(pycreditem, 3, PyString_FromString(cred[i].defresult));
- } else {
- Py_INCREF(Py_None);
- PyList_SetItem(pycreditem, 3, Py_None);
- }
- PyList_SetItem(pycreditem, 4, Py_None);
- }
-
- PyTuple_SetItem(list, 0, pycred);
- Py_XINCREF(pycbdata);
- PyTuple_SetItem(list, 1, pycbdata);
-
- PyErr_Clear();
- pyret = PyEval_CallObject(pycb, list);
- if (PyErr_Occurred()) {
- PyErr_Print();
- goto cleanup;
- }
-
- ret = PyLong_AsLong(pyret);
- if (ret == 0) {
- for (i = 0; i < ncred; i++) {
- PyObject *pycreditem;
- PyObject *pyresult;
- char *result = NULL;
- pycreditem = PyTuple_GetItem(pycred, i);
- pyresult = PyList_GetItem(pycreditem, 4);
- if (pyresult != Py_None)
- result = PyString_AsString(pyresult);
- if (result != NULL) {
- cred[i].result = strdup(result);
- cred[i].resultlen = strlen(result);
- } else {
- cred[i].result = NULL;
- cred[i].resultlen = 0;
- }
- }
- }
-
- cleanup:
- Py_XDECREF(list);
- Py_XDECREF(pyret);
-
- LIBVIRT_RELEASE_THREAD_STATE;
-
- return ret;
-}
-
-
-static PyObject *
-libvirt_virConnectOpenAuth(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- virConnectPtr c_retval;
- char * name;
- unsigned int flags;
- PyObject *pyauth;
- PyObject *pycredcb;
- PyObject *pycredtype;
- virConnectAuth auth;
-
- memset(&auth, 0, sizeof(auth));
- if (!PyArg_ParseTuple(args, (char *)"zOi:virConnectOpenAuth", &name, &pyauth, &flags))
- return NULL;
-
- pycredtype = PyList_GetItem(pyauth, 0);
- pycredcb = PyList_GetItem(pyauth, 1);
-
- auth.ncredtype = PyList_Size(pycredtype);
- if (auth.ncredtype) {
- size_t i;
- if (VIR_ALLOC_N_QUIET(auth.credtype, auth.ncredtype) < 0)
- return VIR_PY_NONE;
- for (i = 0; i < auth.ncredtype; i++) {
- PyObject *val;
- val = PyList_GetItem(pycredtype, i);
- auth.credtype[i] = (int)PyLong_AsLong(val);
- }
- }
- if (pycredcb && pycredcb != Py_None)
- auth.cb = virConnectCredCallbackWrapper;
- auth.cbdata = pyauth;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- c_retval = virConnectOpenAuth(name, &auth, flags);
- LIBVIRT_END_ALLOW_THREADS;
- VIR_FREE(auth.credtype);
- py_retval = libvirt_virConnectPtrWrap((virConnectPtr) c_retval);
- return py_retval;
-}
-
-
-/************************************************************************
- * *
- * Wrappers for functions where generator fails *
- * *
- ************************************************************************/
-
-static PyObject *
-libvirt_virGetVersion(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- char *type = NULL;
- unsigned long libVer, typeVer = 0;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *) "|s", &type))
- return NULL;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- if (type == NULL)
- c_retval = virGetVersion(&libVer, NULL, NULL);
- else
- c_retval = virGetVersion(&libVer, type, &typeVer);
-
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == -1)
- return VIR_PY_NONE;
-
- if (type == NULL)
- return PyInt_FromLong(libVer);
- else
- return Py_BuildValue((char *) "kk", libVer, typeVer);
-}
-
-static PyObject *
-libvirt_virConnectGetVersion(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- unsigned long hvVersion;
- int c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectGetVersion",
- &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- c_retval = virConnectGetVersion(conn, &hvVersion);
-
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == -1)
- return VIR_PY_INT_FAIL;
-
- return PyInt_FromLong(hvVersion);
-}
-
-static PyObject *
-libvirt_virConnectGetCPUModelNames(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- int c_retval;
- virConnectPtr conn;
- PyObject *rv = NULL, *pyobj_conn;
- char **models = NULL;
- size_t i;
- int flags = 0;
- const char *arch = NULL;
-
- if (!PyArg_ParseTuple(args, (char *)"Osi:virConnectGetCPUModelNames",
- &pyobj_conn, &arch, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- c_retval = virConnectGetCPUModelNames(conn, arch, &models, flags);
-
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == -1)
- return VIR_PY_INT_FAIL;
-
- if ((rv = PyList_New(c_retval)) == NULL)
- goto error;
-
- for (i = 0; i < c_retval; i++) {
- PyObject *str;
- if ((str = PyString_FromString(models[i])) == NULL)
- goto error;
-
- PyList_SET_ITEM(rv, i, str);
- }
-
-done:
- if (models) {
- for (i = 0; i < c_retval; i++)
- VIR_FREE(models[i]);
- VIR_FREE(models);
- }
-
- return rv;
-
-error:
- Py_XDECREF(rv);
- rv = VIR_PY_INT_FAIL;
- goto done;
-}
-
-static PyObject *
-libvirt_virConnectGetLibVersion(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- unsigned long libVer;
- int c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectGetLibVersion",
- &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- c_retval = virConnectGetLibVersion(conn, &libVer);
-
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == -1)
- return VIR_PY_INT_FAIL;
-
- return PyInt_FromLong(libVer);
-}
-
-static PyObject *
-libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- int *ids = NULL, c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDomains", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfDomains(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(ids, c_retval) < 0)
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListDomains(conn, ids, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(ids);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (ids) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_intWrap(ids[i]));
- }
- VIR_FREE(ids);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllDomains(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_conn;
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virConnectPtr conn;
- virDomainPtr *doms = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllDomains",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListAllDomains(conn, &doms, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virDomainPtrWrap(doms[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- doms[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (doms[i])
- virDomainFree(doms[i]);
- VIR_FREE(doms);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedDomains", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfDefinedDomains(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListDefinedDomains(conn, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSnapshotListNames(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virDomainPtr dom;
- PyObject *pyobj_dom;
- PyObject *pyobj_snap;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainSnapshotListNames",
- &pyobj_dom, &flags))
- return NULL;
- dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainSnapshotNum(dom, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return PyErr_NoMemory();
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainSnapshotListNames(dom, names, c_retval, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
- if (!py_retval)
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_constcharPtrWrap(names[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- VIR_FREE(names[i]);
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainListAllSnapshots(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval = NULL;
- virDomainSnapshotPtr *snaps = NULL;
- int c_retval;
- size_t i;
- virDomainPtr dom;
- PyObject *pyobj_dom;
- unsigned int flags;
- PyObject *pyobj_snap;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainListAllSnapshots",
- &pyobj_dom, &flags))
- return NULL;
- dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainListAllSnapshots(dom, &snaps, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_virDomainSnapshotPtrWrap(snaps[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- snaps[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (snaps[i])
- virDomainSnapshotFree(snaps[i]);
- VIR_FREE(snaps);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSnapshotListChildrenNames(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virDomainSnapshotPtr snap;
- PyObject *pyobj_snap;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainSnapshotListChildrenNames",
- &pyobj_snap, &flags))
- return NULL;
- snap = (virDomainSnapshotPtr) PyvirDomainSnapshot_Get(pyobj_snap);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainSnapshotNumChildren(snap, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return PyErr_NoMemory();
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainSnapshotListChildrenNames(snap, names, c_retval,
- flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_constcharPtrWrap(names[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- VIR_FREE(names[i]);
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSnapshotListAllChildren(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval = NULL;
- virDomainSnapshotPtr *snaps = NULL;
- int c_retval;
- size_t i;
- virDomainSnapshotPtr parent;
- PyObject *pyobj_parent;
- unsigned int flags;
- PyObject *pyobj_snap;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainSnapshotListAllChildren",
- &pyobj_parent, &flags))
- return NULL;
- parent = (virDomainSnapshotPtr) PyvirDomainSnapshot_Get(pyobj_parent);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainSnapshotListAllChildren(parent, &snaps, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_virDomainSnapshotPtrWrap(snaps[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- snaps[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (snaps[i])
- virDomainSnapshotFree(snaps[i]);
- VIR_FREE(snaps);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainRevertToSnapshot(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- int c_retval;
- virDomainSnapshotPtr snap;
- PyObject *pyobj_snap;
- PyObject *pyobj_dom;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainRevertToSnapshot", &pyobj_dom, &pyobj_snap, &flags))
- return NULL;
- snap = (virDomainSnapshotPtr) PyvirDomainSnapshot_Get(pyobj_snap);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainRevertToSnapshot(snap, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_INT_FAIL;
-
- return PyInt_FromLong(c_retval);
-}
-
-static PyObject *
-libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- virDomainInfo info;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_domain))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetInfo(domain, &info);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyList_New(5);
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state));
- PyList_SetItem(py_retval, 1, libvirt_ulongWrap(info.maxMem));
- PyList_SetItem(py_retval, 2, libvirt_ulongWrap(info.memory));
- PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.nrVirtCpu));
- PyList_SetItem(py_retval, 4,
- libvirt_longlongWrap((unsigned long long) info.cpuTime));
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetState(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- PyObject *py_retval;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- int state;
- int reason;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetState",
- &pyobj_domain, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetState(domain, &state, &reason, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyList_New(2);
- PyList_SetItem(py_retval, 0, libvirt_intWrap(state));
- PyList_SetItem(py_retval, 1, libvirt_intWrap(reason));
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetControlInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- virDomainControlInfo info;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetControlInfo",
- &pyobj_domain, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetControlInfo(domain, &info, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyList_New(3);
- PyList_SetItem(py_retval, 0, libvirt_intWrap(info.state));
- PyList_SetItem(py_retval, 1, libvirt_intWrap(info.details));
- PyList_SetItem(py_retval, 2, libvirt_longlongWrap(info.stateTime));
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- virDomainBlockInfo info;
- const char *path;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetInfo", &pyobj_domain, &path, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetBlockInfo(domain, path, &info, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyList_New(3);
- PyList_SetItem(py_retval, 0, libvirt_ulonglongWrap(info.capacity));
- PyList_SetItem(py_retval, 1, libvirt_ulonglongWrap(info.allocation));
- PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.physical));
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- virNodeInfo info;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetInfo", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeGetInfo(conn, &info);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyList_New(8);
- PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&info.model[0]));
- PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.memory >> 10));
- PyList_SetItem(py_retval, 2, libvirt_intWrap((int) info.cpus));
- PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.mhz));
- PyList_SetItem(py_retval, 4, libvirt_intWrap((int) info.nodes));
- PyList_SetItem(py_retval, 5, libvirt_intWrap((int) info.sockets));
- PyList_SetItem(py_retval, 6, libvirt_intWrap((int) info.cores));
- PyList_SetItem(py_retval, 7, libvirt_intWrap((int) info.threads));
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- unsigned char uuid[VIR_UUID_BUFLEN];
- virDomainPtr domain;
- PyObject *pyobj_domain;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetUUID", &pyobj_domain))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (domain == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetUUID(domain, &uuid[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virDomainPtr dom;
- PyObject *pyobj_dom;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetUUIDString",
- &pyobj_dom))
- return NULL;
- dom = (virDomainPtr) PyvirDomain_Get(pyobj_dom);
-
- if (dom == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetUUIDString(dom, &uuidstr[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromString((char *) &uuidstr[0]);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- virDomainPtr c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- unsigned char * uuid;
- int len;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz#:virDomainLookupByUUID", &pyobj_conn, &uuid, &len))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainLookupByUUID(conn, uuid);
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_virDomainPtrWrap((virDomainPtr) c_retval);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListNetworks", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfNetworks(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListNetworks(conn, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedNetworks", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfDefinedNetworks(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListDefinedNetworks(conn, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllNetworks(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_conn;
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virConnectPtr conn;
- virNetworkPtr *nets = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNetworks",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListAllNetworks(conn, &nets, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virNetworkPtrWrap(nets[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- nets[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (nets[i])
- virNetworkFree(nets[i]);
- VIR_FREE(nets);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virNetworkGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- unsigned char uuid[VIR_UUID_BUFLEN];
- virNetworkPtr domain;
- PyObject *pyobj_domain;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetUUID", &pyobj_domain))
- return NULL;
- domain = (virNetworkPtr) PyvirNetwork_Get(pyobj_domain);
-
- if (domain == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNetworkGetUUID(domain, &uuid[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNetworkGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virNetworkPtr net;
- PyObject *pyobj_net;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetUUIDString",
- &pyobj_net))
- return NULL;
- net = (virNetworkPtr) PyvirNetwork_Get(pyobj_net);
-
- if (net == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNetworkGetUUIDString(net, &uuidstr[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromString((char *) &uuidstr[0]);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNetworkLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- virNetworkPtr c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- unsigned char * uuid;
- int len;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz#:virNetworkLookupByUUID", &pyobj_conn, &uuid, &len))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNetworkLookupByUUID(conn, uuid);
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_virNetworkPtrWrap((virNetworkPtr) c_retval);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virDomainGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval, autostart;
- virDomainPtr domain;
- PyObject *pyobj_domain;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetAutostart", &pyobj_domain))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetAutostart(domain, &autostart);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_INT_FAIL;
- py_retval = libvirt_intWrap(autostart);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virNetworkGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval, autostart;
- virNetworkPtr network;
- PyObject *pyobj_network;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virNetworkGetAutostart", &pyobj_network))
- return NULL;
-
- network = (virNetworkPtr) PyvirNetwork_Get(pyobj_network);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNetworkGetAutostart(network, &autostart);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_INT_FAIL;
- py_retval = libvirt_intWrap(autostart);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- PyObject *py_retval;
- PyObject *pyobj_conn;
- int startCell, maxCells, c_retval;
- size_t i;
- virConnectPtr conn;
- unsigned long long *freeMems;
-
- if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeGetCellsFreeMemory", &pyobj_conn, &startCell, &maxCells))
- return NULL;
-
- if ((startCell < 0) || (maxCells <= 0) || (startCell + maxCells > 10000))
- return VIR_PY_NONE;
-
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
- if (VIR_ALLOC_N_QUIET(freeMems, maxCells) < 0)
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeGetCellsFreeMemory(conn, freeMems, startCell, maxCells);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0) {
- VIR_FREE(freeMems);
- return VIR_PY_NONE;
- }
- py_retval = PyList_New(c_retval);
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i,
- libvirt_longlongWrap((long long) freeMems[i]));
- }
- VIR_FREE(freeMems);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- PyObject *ret = NULL;
- PyObject *key = NULL;
- PyObject *val = NULL;
- PyObject *pyobj_conn;
- virConnectPtr conn;
- unsigned int flags;
- int cpuNum, c_retval;
- size_t i;
- int nparams = 0;
- virNodeCPUStatsPtr stats = NULL;
-
- if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeGetCPUStats", &pyobj_conn, &cpuNum, &flags))
- return ret;
- conn = (virConnectPtr)(PyvirConnect_Get(pyobj_conn));
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeGetCPUStats(conn, cpuNum, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (nparams) {
- if (VIR_ALLOC_N_QUIET(stats, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeGetCPUStats(conn, cpuNum, stats, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(stats);
- return VIR_PY_NONE;
- }
- }
-
- if (!(ret = PyDict_New()))
- goto error;
-
- for (i = 0; i < nparams; i++) {
- key = libvirt_constcharPtrWrap(stats[i].field);
- val = libvirt_ulonglongWrap(stats[i].value);
-
- if (!key || !val || PyDict_SetItem(ret, key, val) < 0) {
- Py_DECREF(ret);
- ret = NULL;
- goto error;
- }
-
- Py_DECREF(key);
- Py_DECREF(val);
- }
-
- VIR_FREE(stats);
- return ret;
-
-error:
- VIR_FREE(stats);
- Py_XDECREF(key);
- Py_XDECREF(val);
- return ret;
-}
-
-static PyObject *
-libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- PyObject *ret = NULL;
- PyObject *key = NULL;
- PyObject *val = NULL;
- PyObject *pyobj_conn;
- virConnectPtr conn;
- unsigned int flags;
- int cellNum, c_retval;
- size_t i;
- int nparams = 0;
- virNodeMemoryStatsPtr stats = NULL;
-
- if (!PyArg_ParseTuple(args, (char *)"Oii:virNodeGetMemoryStats", &pyobj_conn, &cellNum, &flags))
- return ret;
- conn = (virConnectPtr)(PyvirConnect_Get(pyobj_conn));
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeGetMemoryStats(conn, cellNum, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (nparams) {
- if (VIR_ALLOC_N_QUIET(stats, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeGetMemoryStats(conn, cellNum, stats, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(stats);
- return VIR_PY_NONE;
- }
- }
-
- if (!(ret = PyDict_New()))
- goto error;
-
- for (i = 0; i < nparams; i++) {
- key = libvirt_constcharPtrWrap(stats[i].field);
- val = libvirt_ulonglongWrap(stats[i].value);
-
- if (!key || !val || PyDict_SetItem(ret, key, val) < 0) {
- Py_DECREF(ret);
- ret = NULL;
- goto error;
- }
-
- Py_DECREF(key);
- Py_DECREF(val);
- }
-
- VIR_FREE(stats);
- return ret;
-
-error:
- VIR_FREE(stats);
- Py_XDECREF(key);
- Py_XDECREF(val);
- return ret;
-}
-
-static PyObject *
-libvirt_virConnectListStoragePools(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListStoragePools", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfStoragePools(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListStoragePools(conn, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
- if (py_retval == NULL) {
- if (names) {
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
- }
- return VIR_PY_NONE;
- }
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedStoragePools", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfDefinedStoragePools(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListDefinedStoragePools(conn, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
- if (py_retval == NULL) {
- if (names) {
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
- }
- return VIR_PY_NONE;
- }
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllStoragePools(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_conn;
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virConnectPtr conn;
- virStoragePoolPtr *pools = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllStoragePools",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListAllStoragePools(conn, &pools, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virStoragePoolPtrWrap(pools[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- pools[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (pools[i])
- virStoragePoolFree(pools[i]);
- VIR_FREE(pools);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virStoragePoolPtr pool;
- PyObject *pyobj_pool;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolListVolumes", &pyobj_pool))
- return NULL;
- pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolNumOfVolumes(pool);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolListVolumes(pool, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
- if (py_retval == NULL) {
- if (names) {
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
- }
- return VIR_PY_NONE;
- }
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolListAllVolumes(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virStoragePoolPtr pool;
- virStorageVolPtr *vols = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
- PyObject *pyobj_pool;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virStoragePoolListAllVolumes",
- &pyobj_pool, &flags))
- return NULL;
-
- pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolListAllVolumes(pool, &vols, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virStorageVolPtrWrap(vols[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- vols[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (vols[i])
- virStorageVolFree(vols[i]);
- VIR_FREE(vols);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virStoragePoolGetAutostart(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval, autostart;
- virStoragePoolPtr pool;
- PyObject *pyobj_pool;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetAutostart", &pyobj_pool))
- return NULL;
-
- pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolGetAutostart(pool, &autostart);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = libvirt_intWrap(autostart);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virStoragePoolPtr pool;
- PyObject *pyobj_pool;
- virStoragePoolInfo info;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetInfo", &pyobj_pool))
- return NULL;
- pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolGetInfo(pool, &info);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if ((py_retval = PyList_New(4)) == NULL)
- return VIR_PY_NONE;
-
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state));
- PyList_SetItem(py_retval, 1,
- libvirt_longlongWrap((unsigned long long) info.capacity));
- PyList_SetItem(py_retval, 2,
- libvirt_longlongWrap((unsigned long long) info.allocation));
- PyList_SetItem(py_retval, 3,
- libvirt_longlongWrap((unsigned long long) info.available));
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virStorageVolGetInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virStorageVolPtr pool;
- PyObject *pyobj_pool;
- virStorageVolInfo info;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virStorageVolGetInfo", &pyobj_pool))
- return NULL;
- pool = (virStorageVolPtr) PyvirStorageVol_Get(pyobj_pool);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStorageVolGetInfo(pool, &info);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if ((py_retval = PyList_New(3)) == NULL)
- return VIR_PY_NONE;
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.type));
- PyList_SetItem(py_retval, 1,
- libvirt_longlongWrap((unsigned long long) info.capacity));
- PyList_SetItem(py_retval, 2,
- libvirt_longlongWrap((unsigned long long) info.allocation));
- return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- unsigned char uuid[VIR_UUID_BUFLEN];
- virStoragePoolPtr pool;
- PyObject *pyobj_pool;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetUUID", &pyobj_pool))
- return NULL;
- pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
- if (pool == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolGetUUID(pool, &uuid[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virStoragePoolPtr pool;
- PyObject *pyobj_pool;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virStoragePoolGetUUIDString", &pyobj_pool))
- return NULL;
- pool = (virStoragePoolPtr) PyvirStoragePool_Get(pyobj_pool);
-
- if (pool == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolGetUUIDString(pool, &uuidstr[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromString((char *) &uuidstr[0]);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virStoragePoolLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- virStoragePoolPtr c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- unsigned char * uuid;
- int len;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz#:virStoragePoolLookupByUUID", &pyobj_conn, &uuid, &len))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virStoragePoolLookupByUUID(conn, uuid);
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_virStoragePoolPtrWrap((virStoragePoolPtr) c_retval);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- char *cap;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozi:virNodeListDevices",
- &pyobj_conn, &cap, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeNumOfDevices(conn, cap, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeListDevices(conn, cap, names, c_retval, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllNodeDevices(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_conn;
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virConnectPtr conn;
- virNodeDevicePtr *devices = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNodeDevices",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListAllNodeDevices(conn, &devices, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virNodeDevicePtrWrap(devices[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- devices[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (devices[i])
- virNodeDeviceFree(devices[i]);
- VIR_FREE(devices);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virNodeDevicePtr dev;
- PyObject *pyobj_dev;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virNodeDeviceListCaps", &pyobj_dev))
- return NULL;
- dev = (virNodeDevicePtr) PyvirNodeDevice_Get(pyobj_dev);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeDeviceNumOfCaps(dev);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNodeDeviceListCaps(dev, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- unsigned char uuid[VIR_UUID_BUFLEN];
- virSecretPtr secret;
- PyObject *pyobj_secret;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virSecretGetUUID", &pyobj_secret))
- return NULL;
- secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret);
-
- if (secret == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virSecretGetUUID(secret, &uuid[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virSecretPtr dom;
- PyObject *pyobj_dom;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virSecretGetUUIDString",
- &pyobj_dom))
- return NULL;
- dom = (virSecretPtr) PyvirSecret_Get(pyobj_dom);
-
- if (dom == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virSecretGetUUIDString(dom, &uuidstr[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromString((char *) &uuidstr[0]);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- virSecretPtr c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- unsigned char * uuid;
- int len;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz#:virSecretLookupByUUID", &pyobj_conn, &uuid, &len))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virSecretLookupByUUID(conn, uuid);
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_virSecretPtrWrap((virSecretPtr) c_retval);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **uuids = NULL;
- virConnectPtr conn;
- int c_retval;
- size_t i;
- PyObject *pyobj_conn;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListSecrets", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfSecrets(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(uuids, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListSecrets(conn, uuids, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(uuids);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (uuids) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
- VIR_FREE(uuids[i]);
- }
- VIR_FREE(uuids);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_conn;
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virConnectPtr conn;
- virSecretPtr *secrets = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllSecrets",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListAllSecrets(conn, &secrets, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virSecretPtrWrap(secrets[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- secrets[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (secrets[i])
- virSecretFree(secrets[i]);
- VIR_FREE(secrets);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- unsigned char *c_retval;
- size_t size;
- virSecretPtr secret;
- PyObject *pyobj_secret;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virSecretGetValue", &pyobj_secret,
- &flags))
- return NULL;
- secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virSecretGetValue(secret, &size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval == NULL)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromStringAndSize((const char *)c_retval, size);
- VIR_FREE(c_retval);
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virSecretSetValue(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virSecretPtr secret;
- PyObject *pyobj_secret;
- const char *value;
- int size;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz#i:virSecretSetValue", &pyobj_secret,
- &value, &size, &flags))
- return NULL;
- secret = (virSecretPtr) PyvirSecret_Get(pyobj_secret);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virSecretSetValue(secret, (const unsigned char *)value, size,
- flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- py_retval = libvirt_intWrap(c_retval);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNWFilterGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- unsigned char uuid[VIR_UUID_BUFLEN];
- virNWFilterPtr nwfilter;
- PyObject *pyobj_nwfilter;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virNWFilterGetUUID", &pyobj_nwfilter))
- return NULL;
- nwfilter = (virNWFilterPtr) PyvirNWFilter_Get(pyobj_nwfilter);
-
- if (nwfilter == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNWFilterGetUUID(nwfilter, &uuid[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNWFilterGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virNWFilterPtr nwfilter;
- PyObject *pyobj_nwfilter;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virNWFilterGetUUIDString",
- &pyobj_nwfilter))
- return NULL;
- nwfilter = (virNWFilterPtr) PyvirNWFilter_Get(pyobj_nwfilter);
-
- if (nwfilter == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNWFilterGetUUIDString(nwfilter, &uuidstr[0]);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromString((char *) &uuidstr[0]);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNWFilterLookupByUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- virNWFilterPtr c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- unsigned char * uuid;
- int len;
-
- if (!PyArg_ParseTuple(args, (char *)"Oz#:virNWFilterLookupByUUID", &pyobj_conn, &uuid, &len))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virNWFilterLookupByUUID(conn, uuid);
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_virNWFilterPtrWrap((virNWFilterPtr) c_retval);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListNWFilters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **uuids = NULL;
- virConnectPtr conn;
- int c_retval;
- size_t i;
- PyObject *pyobj_conn;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListNWFilters", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfNWFilters(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(uuids, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListNWFilters(conn, uuids, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(uuids);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
-
- if (uuids) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
- VIR_FREE(uuids[i]);
- }
- VIR_FREE(uuids);
- }
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListAllNWFilters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_conn;
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virConnectPtr conn;
- virNWFilterPtr *filters = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNWFilters",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListAllNWFilters(conn, &filters, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virNWFilterPtrWrap(filters[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- filters[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (filters[i])
- virNWFilterFree(filters[i]);
- VIR_FREE(filters);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListInterfaces", &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfInterfaces(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListInterfaces(conn, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
- if (py_retval == NULL) {
- if (names) {
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
- }
- return VIR_PY_NONE;
- }
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char **names = NULL;
- int c_retval;
- size_t i;
- virConnectPtr conn;
- PyObject *pyobj_conn;
-
-
- if (!PyArg_ParseTuple(args, (char *)"O:virConnectListDefinedInterfaces",
- &pyobj_conn))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectNumOfDefinedInterfaces(conn);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (c_retval) {
- if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListDefinedInterfaces(conn, names, c_retval);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0) {
- VIR_FREE(names);
- return VIR_PY_NONE;
- }
- }
- py_retval = PyList_New(c_retval);
- if (py_retval == NULL) {
- if (names) {
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
- }
- return VIR_PY_NONE;
- }
-
- if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- VIR_FREE(names[i]);
- }
- VIR_FREE(names);
- }
-
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virConnectListAllInterfaces(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_conn;
- PyObject *py_retval = NULL;
- PyObject *tmp = NULL;
- virConnectPtr conn;
- virInterfacePtr *ifaces = NULL;
- int c_retval = 0;
- size_t i;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllInterfaces",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virConnectListAllInterfaces(conn, &ifaces, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- if (!(py_retval = PyList_New(c_retval)))
- goto cleanup;
-
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virInterfacePtrWrap(ifaces[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_DECREF(py_retval);
- py_retval = NULL;
- goto cleanup;
- }
- /* python steals the pointer */
- ifaces[i] = NULL;
- }
-
-cleanup:
- for (i = 0; i < c_retval; i++)
- if (ifaces[i])
- virInterfaceFree(ifaces[i]);
- VIR_FREE(ifaces);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *pyobj_conn;
- PyObject *list;
- virConnectPtr conn;
- unsigned int flags;
- const char **xmlcpus = NULL;
- int ncpus = 0;
- char *base_cpu;
- PyObject *pybase_cpu;
-
- if (!PyArg_ParseTuple(args, (char *)"OOi:virConnectBaselineCPU",
- &pyobj_conn, &list, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- if (PyList_Check(list)) {
- size_t i;
-
- ncpus = PyList_Size(list);
- if (VIR_ALLOC_N_QUIET(xmlcpus, ncpus) < 0)
- return VIR_PY_INT_FAIL;
-
- for (i = 0; i < ncpus; i++) {
- xmlcpus[i] = PyString_AsString(PyList_GetItem(list, i));
- if (xmlcpus[i] == NULL) {
- VIR_FREE(xmlcpus);
- return VIR_PY_INT_FAIL;
- }
- }
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- base_cpu = virConnectBaselineCPU(conn, xmlcpus, ncpus, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- VIR_FREE(xmlcpus);
-
- if (base_cpu == NULL)
- return VIR_PY_INT_FAIL;
-
- pybase_cpu = PyString_FromString(base_cpu);
- VIR_FREE(base_cpu);
-
- if (pybase_cpu == NULL)
- return VIR_PY_INT_FAIL;
-
- return pybase_cpu;
-}
-
-
-static PyObject *
-libvirt_virDomainGetJobInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- virDomainJobInfo info;
-
- if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetJobInfo", &pyobj_domain))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainGetJobInfo(domain, &info);
- LIBVIRT_END_ALLOW_THREADS;
- if (c_retval < 0)
- return VIR_PY_NONE;
- py_retval = PyList_New(12);
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.type));
- PyList_SetItem(py_retval, 1, libvirt_ulonglongWrap(info.timeElapsed));
- PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.timeRemaining));
- PyList_SetItem(py_retval, 3, libvirt_ulonglongWrap(info.dataTotal));
- PyList_SetItem(py_retval, 4, libvirt_ulonglongWrap(info.dataProcessed));
- PyList_SetItem(py_retval, 5, libvirt_ulonglongWrap(info.dataRemaining));
- PyList_SetItem(py_retval, 6, libvirt_ulonglongWrap(info.memTotal));
- PyList_SetItem(py_retval, 7, libvirt_ulonglongWrap(info.memProcessed));
- PyList_SetItem(py_retval, 8, libvirt_ulonglongWrap(info.memRemaining));
- PyList_SetItem(py_retval, 9, libvirt_ulonglongWrap(info.fileTotal));
- PyList_SetItem(py_retval, 10, libvirt_ulonglongWrap(info.fileProcessed));
- PyList_SetItem(py_retval, 11, libvirt_ulonglongWrap(info.fileRemaining));
-
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainGetJobStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- PyObject *pyobj_domain;
- virDomainPtr domain;
- unsigned int flags;
- virTypedParameterPtr params = NULL;
- int nparams = 0;
- int type;
- PyObject *dict = NULL;
- int rc;
-
- if (!PyArg_ParseTuple(args, (char *) "Oi:virDomainGetJobStats",
- &pyobj_domain, &flags))
- goto cleanup;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- rc = virDomainGetJobStats(domain, &type, ¶ms, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
- if (rc < 0)
- goto cleanup;
-
- if (!(dict = getPyVirTypedParameter(params, nparams)))
- goto cleanup;
-
- if (PyDict_SetItem(dict, libvirt_constcharPtrWrap("type"),
- libvirt_intWrap(type)) < 0) {
- Py_DECREF(dict);
- dict = NULL;
- goto cleanup;
- }
-
-cleanup:
- virTypedParamsFree(params, nparams);
- if (dict)
- return dict;
- else
- return VIR_PY_NONE;
-}
-
-static PyObject *
-libvirt_virDomainGetBlockJobInfo(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- const char *path;
- unsigned int flags;
- virDomainBlockJobInfo info;
- int c_ret;
- PyObject *type = NULL, *bandwidth = NULL, *cur = NULL, *end = NULL;
- PyObject *dict;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockJobInfo",
- &pyobj_domain, &path, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((dict = PyDict_New()) == NULL)
- return NULL;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_ret = virDomainGetBlockJobInfo(domain, path, &info, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_ret == 0) {
- return dict;
- } else if (c_ret < 0) {
- Py_DECREF(dict);
- return VIR_PY_NONE;
- }
-
- if ((type = libvirt_intWrap(info.type)) == NULL ||
- PyDict_SetItemString(dict, "type", type) < 0)
- goto error;
- Py_DECREF(type);
-
- if ((bandwidth = libvirt_ulongWrap(info.bandwidth)) == NULL ||
- PyDict_SetItemString(dict, "bandwidth", bandwidth) < 0)
- goto error;
- Py_DECREF(bandwidth);
-
- if ((cur = libvirt_ulonglongWrap(info.cur)) == NULL ||
- PyDict_SetItemString(dict, "cur", cur) < 0)
- goto error;
- Py_DECREF(cur);
-
- if ((end = libvirt_ulonglongWrap(info.end)) == NULL ||
- PyDict_SetItemString(dict, "end", end) < 0)
- goto error;
- Py_DECREF(end);
-
- return dict;
-
-error:
- Py_DECREF(dict);
- Py_XDECREF(type);
- Py_XDECREF(bandwidth);
- Py_XDECREF(cur);
- Py_XDECREF(end);
- return NULL;
-}
-
-static PyObject *
-libvirt_virDomainSetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain, *info;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- const char *disk;
- unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args, (char *)"OzOi:virDomainSetBlockIoTune",
- &pyobj_domain, &disk, &info, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlockIoTune(domain, disk, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "Domain has no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlockIoTune(domain, disk, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainSetBlockIoTune(domain, disk, new_params, size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- const char *disk;
- unsigned int flags;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockIoTune",
- &pyobj_domain, &disk, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlockIoTune(domain, disk, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virDomainGetBlockIoTune(domain, disk, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval = VIR_PY_NONE;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- unsigned int flags;
- virDomainDiskErrorPtr disks = NULL;
- unsigned int ndisks;
- int count;
- size_t i;
-
- if (!PyArg_ParseTuple(args, (char *) "Oi:virDomainGetDiskErrors",
- &pyobj_domain, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if ((count = virDomainGetDiskErrors(domain, NULL, 0, 0)) < 0)
- return VIR_PY_NONE;
- ndisks = count;
-
- if (ndisks) {
- if (VIR_ALLOC_N_QUIET(disks, ndisks) < 0)
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- count = virDomainGetDiskErrors(domain, disks, ndisks, 0);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (count < 0)
- goto cleanup;
- }
-
- if (!(py_retval = PyDict_New()))
- goto cleanup;
-
- for (i = 0; i < count; i++) {
- PyDict_SetItem(py_retval,
- libvirt_constcharPtrWrap(disks[i].disk),
- libvirt_intWrap(disks[i].error));
- }
-
-cleanup:
- if (disks) {
- for (i = 0; i < count; i++)
- VIR_FREE(disks[i].disk);
- VIR_FREE(disks);
- }
- return py_retval;
-}
-
-/*******************************************
- * Helper functions to avoid importing modules
- * for every callback
- *******************************************/
-static PyObject *libvirt_module = NULL;
-static PyObject *libvirt_dict = NULL;
-static PyObject *libvirt_dom_class = NULL;
-
-static PyObject *
-getLibvirtModuleObject(void) {
- if (libvirt_module)
- return libvirt_module;
-
- // PyImport_ImportModule returns a new reference
- /* Bogus (char *) cast for RHEL-5 python API brokenness */
- libvirt_module = PyImport_ImportModule((char *)"libvirt");
- if (!libvirt_module) {
- DEBUG("%s Error importing libvirt module\n", __FUNCTION__);
- PyErr_Print();
- return NULL;
- }
-
- return libvirt_module;
-}
-
-static PyObject *
-getLibvirtDictObject(void) {
- if (libvirt_dict)
- return libvirt_dict;
-
- // PyModule_GetDict returns a borrowed reference
- libvirt_dict = PyModule_GetDict(getLibvirtModuleObject());
- if (!libvirt_dict) {
- DEBUG("%s Error importing libvirt dictionary\n", __FUNCTION__);
- PyErr_Print();
- return NULL;
- }
-
- Py_INCREF(libvirt_dict);
- return libvirt_dict;
-}
-
-static PyObject *
-getLibvirtDomainClassObject(void) {
- if (libvirt_dom_class)
- return libvirt_dom_class;
-
- // PyDict_GetItemString returns a borrowed reference
- libvirt_dom_class = PyDict_GetItemString(getLibvirtDictObject(),
- "virDomain");
- if (!libvirt_dom_class) {
- DEBUG("%s Error importing virDomain class\n", __FUNCTION__);
- PyErr_Print();
- return NULL;
- }
-
- Py_INCREF(libvirt_dom_class);
- return libvirt_dom_class;
-}
-
-static PyObject *
-libvirt_lookupPythonFunc(const char *funcname)
-{
- PyObject *python_cb;
-
- /* Lookup the python callback */
- python_cb = PyDict_GetItemString(getLibvirtDictObject(), funcname);
-
- if (!python_cb) {
- DEBUG("%s: Error finding %s\n", __FUNCTION__, funcname);
- PyErr_Print();
- PyErr_Clear();
- return NULL;
- }
-
- if (!PyCallable_Check(python_cb)) {
- DEBUG("%s: %s is not callable\n", __FUNCTION__, funcname);
- return NULL;
- }
-
- return python_cb;
-}
-
-/*******************************************
- * Domain Events
- *******************************************/
-
-static int
-libvirt_virConnectDomainEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- int event,
- int detail,
- void *opaque)
-{
- PyObject *pyobj_ret;
-
- PyObject *pyobj_conn_inst = (PyObject*)opaque;
- PyObject *pyobj_dom;
-
- PyObject *pyobj_dom_args;
- PyObject *pyobj_dom_inst;
-
- PyObject *dom_class;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- pyobj_dom_args = PyTuple_New(2);
- if (PyTuple_SetItem(pyobj_dom_args, 0, pyobj_conn_inst) != 0) {
- DEBUG("%s error creating tuple", __FUNCTION__);
- goto cleanup;
- }
- if (PyTuple_SetItem(pyobj_dom_args, 1, pyobj_dom) != 0) {
- DEBUG("%s error creating tuple", __FUNCTION__);
- goto cleanup;
- }
- Py_INCREF(pyobj_conn_inst);
-
- dom_class = getLibvirtDomainClassObject();
- if (!PyClass_Check(dom_class)) {
- DEBUG("%s dom_class is not a class!\n", __FUNCTION__);
- goto cleanup;
- }
-
- pyobj_dom_inst = PyInstance_New(dom_class,
- pyobj_dom_args,
- NULL);
-
- Py_DECREF(pyobj_dom_args);
-
- if (!pyobj_dom_inst) {
- DEBUG("%s Error creating a python instance of virDomain\n",
- __FUNCTION__);
- PyErr_Print();
- goto cleanup;
- }
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn_inst,
- (char*)"_dispatchDomainEventCallbacks",
- (char*)"Oii",
- pyobj_dom_inst,
- event,
- detail);
-
- Py_DECREF(pyobj_dom_inst);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
-
-cleanup:
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventRegister(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- PyObject *py_retval; /* return value */
- PyObject *pyobj_conn; /* virConnectPtr */
- PyObject *pyobj_conn_inst; /* virConnect Python object */
-
- virConnectPtr conn;
- int ret = 0;
-
- if (!PyArg_ParseTuple
- (args, (char *) "OO:virConnectDomainEventRegister",
- &pyobj_conn, &pyobj_conn_inst)) {
- DEBUG("%s failed parsing tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
-
- DEBUG("libvirt_virConnectDomainEventRegister(%p %p) called\n",
- pyobj_conn, pyobj_conn_inst);
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- Py_INCREF(pyobj_conn_inst);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- ret = virConnectDomainEventRegister(conn,
- libvirt_virConnectDomainEventCallback,
- (void *)pyobj_conn_inst, NULL);
-
- LIBVIRT_END_ALLOW_THREADS;
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventDeregister(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- PyObject *py_retval;
- PyObject *pyobj_conn;
- PyObject *pyobj_conn_inst;
-
- virConnectPtr conn;
- int ret = 0;
-
- if (!PyArg_ParseTuple
- (args, (char *) "OO:virConnectDomainEventDeregister",
- &pyobj_conn, &pyobj_conn_inst))
- return NULL;
-
- DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn);
-
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- ret = virConnectDomainEventDeregister(conn, libvirt_virConnectDomainEventCallback);
-
- LIBVIRT_END_ALLOW_THREADS;
-
- Py_DECREF(pyobj_conn_inst);
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-/*******************************************
- * Event Impl
- *******************************************/
-static PyObject *addHandleObj = NULL;
-static char *addHandleName = NULL;
-static PyObject *updateHandleObj = NULL;
-static char *updateHandleName = NULL;
-static PyObject *removeHandleObj = NULL;
-static char *removeHandleName = NULL;
-static PyObject *addTimeoutObj = NULL;
-static char *addTimeoutName = NULL;
-static PyObject *updateTimeoutObj = NULL;
-static char *updateTimeoutName = NULL;
-static PyObject *removeTimeoutObj = NULL;
-static char *removeTimeoutName = NULL;
-
-#define NAME(fn) ( fn ## Name ? fn ## Name : # fn )
-
-static int
-libvirt_virEventAddHandleFunc (int fd,
- int event,
- virEventHandleCallback cb,
- void *opaque,
- virFreeCallback ff)
-{
- PyObject *result;
- PyObject *python_cb;
- PyObject *cb_obj;
- PyObject *ff_obj;
- PyObject *opaque_obj;
- PyObject *cb_args;
- PyObject *pyobj_args;
- int retval = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Lookup the python callback */
- python_cb = libvirt_lookupPythonFunc("_eventInvokeHandleCallback");
- if (!python_cb) {
- goto cleanup;
- }
- Py_INCREF(python_cb);
-
- /* create tuple for cb */
- cb_obj = libvirt_virEventHandleCallbackWrap(cb);
- ff_obj = libvirt_virFreeCallbackWrap(ff);
- opaque_obj = libvirt_virVoidPtrWrap(opaque);
-
- cb_args = PyTuple_New(3);
- PyTuple_SetItem(cb_args, 0, cb_obj);
- PyTuple_SetItem(cb_args, 1, opaque_obj);
- PyTuple_SetItem(cb_args, 2, ff_obj);
-
- pyobj_args = PyTuple_New(4);
- PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(fd));
- PyTuple_SetItem(pyobj_args, 1, libvirt_intWrap(event));
- PyTuple_SetItem(pyobj_args, 2, python_cb);
- PyTuple_SetItem(pyobj_args, 3, cb_args);
-
- result = PyEval_CallObject(addHandleObj, pyobj_args);
- if (!result) {
- PyErr_Print();
- PyErr_Clear();
- } else if (!PyInt_Check(result)) {
- DEBUG("%s: %s should return an int\n", __FUNCTION__, NAME(addHandle));
- } else {
- retval = (int)PyInt_AsLong(result);
- }
-
- Py_XDECREF(result);
- Py_DECREF(pyobj_args);
-
-cleanup:
- LIBVIRT_RELEASE_THREAD_STATE;
-
- return retval;
-}
-
-static void
-libvirt_virEventUpdateHandleFunc(int watch, int event)
-{
- PyObject *result;
- PyObject *pyobj_args;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- pyobj_args = PyTuple_New(2);
- PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(watch));
- PyTuple_SetItem(pyobj_args, 1, libvirt_intWrap(event));
-
- result = PyEval_CallObject(updateHandleObj, pyobj_args);
- if (!result) {
- PyErr_Print();
- PyErr_Clear();
- }
-
- Py_XDECREF(result);
- Py_DECREF(pyobj_args);
-
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-
-static int
-libvirt_virEventRemoveHandleFunc(int watch)
-{
- PyObject *result;
- PyObject *pyobj_args;
- PyObject *opaque;
- PyObject *ff;
- int retval = -1;
- virFreeCallback cff;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- pyobj_args = PyTuple_New(1);
- PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(watch));
-
- result = PyEval_CallObject(removeHandleObj, pyobj_args);
- if (!result) {
- PyErr_Print();
- PyErr_Clear();
- } else if (!PyTuple_Check(result) || PyTuple_Size(result) != 3) {
- DEBUG("%s: %s must return opaque obj registered with %s"
- "to avoid leaking libvirt memory\n",
- __FUNCTION__, NAME(removeHandle), NAME(addHandle));
- } else {
- opaque = PyTuple_GetItem(result, 1);
- ff = PyTuple_GetItem(result, 2);
- cff = PyvirFreeCallback_Get(ff);
- if (cff)
- (*cff)(PyvirVoidPtr_Get(opaque));
- retval = 0;
- }
-
- Py_XDECREF(result);
- Py_DECREF(pyobj_args);
-
- LIBVIRT_RELEASE_THREAD_STATE;
-
- return retval;
-}
-
-
-static int
-libvirt_virEventAddTimeoutFunc(int timeout,
- virEventTimeoutCallback cb,
- void *opaque,
- virFreeCallback ff)
-{
- PyObject *result;
-
- PyObject *python_cb;
-
- PyObject *cb_obj;
- PyObject *ff_obj;
- PyObject *opaque_obj;
- PyObject *cb_args;
- PyObject *pyobj_args;
- int retval = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Lookup the python callback */
- python_cb = libvirt_lookupPythonFunc("_eventInvokeTimeoutCallback");
- if (!python_cb) {
- goto cleanup;
- }
- Py_INCREF(python_cb);
-
- /* create tuple for cb */
- cb_obj = libvirt_virEventTimeoutCallbackWrap(cb);
- ff_obj = libvirt_virFreeCallbackWrap(ff);
- opaque_obj = libvirt_virVoidPtrWrap(opaque);
-
- cb_args = PyTuple_New(3);
- PyTuple_SetItem(cb_args, 0, cb_obj);
- PyTuple_SetItem(cb_args, 1, opaque_obj);
- PyTuple_SetItem(cb_args, 2, ff_obj);
-
- pyobj_args = PyTuple_New(3);
-
- PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(timeout));
- PyTuple_SetItem(pyobj_args, 1, python_cb);
- PyTuple_SetItem(pyobj_args, 2, cb_args);
-
- result = PyEval_CallObject(addTimeoutObj, pyobj_args);
- if (!result) {
- PyErr_Print();
- PyErr_Clear();
- } else if (!PyInt_Check(result)) {
- DEBUG("%s: %s should return an int\n", __FUNCTION__, NAME(addTimeout));
- } else {
- retval = (int)PyInt_AsLong(result);
- }
-
- Py_XDECREF(result);
- Py_DECREF(pyobj_args);
-
-cleanup:
- LIBVIRT_RELEASE_THREAD_STATE;
- return retval;
-}
-
-static void
-libvirt_virEventUpdateTimeoutFunc(int timer, int timeout)
-{
- PyObject *result = NULL;
- PyObject *pyobj_args;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- pyobj_args = PyTuple_New(2);
- PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(timer));
- PyTuple_SetItem(pyobj_args, 1, libvirt_intWrap(timeout));
-
- result = PyEval_CallObject(updateTimeoutObj, pyobj_args);
- if (!result) {
- PyErr_Print();
- PyErr_Clear();
- }
-
- Py_XDECREF(result);
- Py_DECREF(pyobj_args);
-
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static int
-libvirt_virEventRemoveTimeoutFunc(int timer)
-{
- PyObject *result = NULL;
- PyObject *pyobj_args;
- PyObject *opaque;
- PyObject *ff;
- int retval = -1;
- virFreeCallback cff;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- pyobj_args = PyTuple_New(1);
- PyTuple_SetItem(pyobj_args, 0, libvirt_intWrap(timer));
-
- result = PyEval_CallObject(removeTimeoutObj, pyobj_args);
- if (!result) {
- PyErr_Print();
- PyErr_Clear();
- } else if (!PyTuple_Check(result) || PyTuple_Size(result) != 3) {
- DEBUG("%s: %s must return opaque obj registered with %s"
- "to avoid leaking libvirt memory\n",
- __FUNCTION__, NAME(removeTimeout), NAME(addTimeout));
- } else {
- opaque = PyTuple_GetItem(result, 1);
- ff = PyTuple_GetItem(result, 2);
- cff = PyvirFreeCallback_Get(ff);
- if (cff)
- (*cff)(PyvirVoidPtr_Get(opaque));
- retval = 0;
- }
-
- Py_XDECREF(result);
- Py_DECREF(pyobj_args);
-
- LIBVIRT_RELEASE_THREAD_STATE;
-
- return retval;
-}
-
-static PyObject *
-libvirt_virEventRegisterImpl(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- /* Unref the previously-registered impl (if any) */
- Py_XDECREF(addHandleObj);
- Py_XDECREF(updateHandleObj);
- Py_XDECREF(removeHandleObj);
- Py_XDECREF(addTimeoutObj);
- Py_XDECREF(updateTimeoutObj);
- Py_XDECREF(removeTimeoutObj);
-
- /* Parse and check arguments */
- if (!PyArg_ParseTuple(args, (char *) "OOOOOO:virEventRegisterImpl",
- &addHandleObj, &updateHandleObj,
- &removeHandleObj, &addTimeoutObj,
- &updateTimeoutObj, &removeTimeoutObj) ||
- !PyCallable_Check(addHandleObj) ||
- !PyCallable_Check(updateHandleObj) ||
- !PyCallable_Check(removeHandleObj) ||
- !PyCallable_Check(addTimeoutObj) ||
- !PyCallable_Check(updateTimeoutObj) ||
- !PyCallable_Check(removeTimeoutObj))
- return VIR_PY_INT_FAIL;
-
- /* Get argument string representations (for error reporting) */
- addHandleName = py_str(addHandleObj);
- updateHandleName = py_str(updateHandleObj);
- removeHandleName = py_str(removeHandleObj);
- addTimeoutName = py_str(addTimeoutObj);
- updateTimeoutName = py_str(updateTimeoutObj);
- removeTimeoutName = py_str(removeTimeoutObj);
-
- /* Inc refs since we're holding on to these objects until
- * the next call (if any) to this function.
- */
- Py_INCREF(addHandleObj);
- Py_INCREF(updateHandleObj);
- Py_INCREF(removeHandleObj);
- Py_INCREF(addTimeoutObj);
- Py_INCREF(updateTimeoutObj);
- Py_INCREF(removeTimeoutObj);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- /* Now register our C EventImpl, which will dispatch
- * to the Python callbacks passed in as args.
- */
- virEventRegisterImpl(libvirt_virEventAddHandleFunc,
- libvirt_virEventUpdateHandleFunc,
- libvirt_virEventRemoveHandleFunc,
- libvirt_virEventAddTimeoutFunc,
- libvirt_virEventUpdateTimeoutFunc,
- libvirt_virEventRemoveTimeoutFunc);
-
- LIBVIRT_END_ALLOW_THREADS;
-
- return VIR_PY_INT_SUCCESS;
-}
-
-static PyObject *
-libvirt_virEventInvokeHandleCallback(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- int watch, fd, event;
- PyObject *py_f;
- PyObject *py_opaque;
- virEventHandleCallback cb;
- void *opaque;
-
- if (!PyArg_ParseTuple
- (args, (char *) "iiiOO:virEventInvokeHandleCallback",
- &watch, &fd, &event, &py_f, &py_opaque
- ))
- return VIR_PY_INT_FAIL;
-
- cb = (virEventHandleCallback) PyvirEventHandleCallback_Get(py_f);
- opaque = (void *) PyvirVoidPtr_Get(py_opaque);
-
- if (cb) {
- LIBVIRT_BEGIN_ALLOW_THREADS;
- cb(watch, fd, event, opaque);
- LIBVIRT_END_ALLOW_THREADS;
- }
-
- return VIR_PY_INT_SUCCESS;
-}
-
-static PyObject *
-libvirt_virEventInvokeTimeoutCallback(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- int timer;
- PyObject *py_f;
- PyObject *py_opaque;
- virEventTimeoutCallback cb;
- void *opaque;
-
- if (!PyArg_ParseTuple
- (args, (char *) "iOO:virEventInvokeTimeoutCallback",
- &timer, &py_f, &py_opaque
- ))
- return VIR_PY_INT_FAIL;
-
- cb = (virEventTimeoutCallback) PyvirEventTimeoutCallback_Get(py_f);
- opaque = (void *) PyvirVoidPtr_Get(py_opaque);
- if (cb) {
- LIBVIRT_BEGIN_ALLOW_THREADS;
- cb(timer, opaque);
- LIBVIRT_END_ALLOW_THREADS;
- }
-
- return VIR_PY_INT_SUCCESS;
-}
-
-static void
-libvirt_virEventHandleCallback(int watch,
- int fd,
- int events,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject *)opaque;
- PyObject *pyobj_ret;
- PyObject *python_cb;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Lookup the python callback */
- python_cb = libvirt_lookupPythonFunc("_dispatchEventHandleCallback");
- if (!python_cb) {
- goto cleanup;
- }
-
- Py_INCREF(pyobj_cbData);
-
- /* Call the pure python dispatcher */
- pyobj_ret = PyObject_CallFunction(python_cb,
- (char *)"iiiO",
- watch, fd, events, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- }
-
-cleanup:
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virEventAddHandle(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval;
- PyObject *pyobj_cbData;
- virEventHandleCallback cb = libvirt_virEventHandleCallback;
- int events;
- int fd;
- int ret;
-
- if (!PyArg_ParseTuple(args, (char *) "iiO:virEventAddHandle",
- &fd, &events, &pyobj_cbData)) {
- DEBUG("%s failed to parse tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
-
- Py_INCREF(pyobj_cbData);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virEventAddHandle(fd, events, cb, pyobj_cbData, NULL);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (ret < 0) {
- Py_DECREF(pyobj_cbData);
- }
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static void
-libvirt_virEventTimeoutCallback(int timer,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject *)opaque;
- PyObject *pyobj_ret;
- PyObject *python_cb;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Lookup the python callback */
- python_cb = libvirt_lookupPythonFunc("_dispatchEventTimeoutCallback");
- if (!python_cb) {
- goto cleanup;
- }
-
- Py_INCREF(pyobj_cbData);
-
- /* Call the pure python dispatcher */
- pyobj_ret = PyObject_CallFunction(python_cb,
- (char *)"iO",
- timer, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- }
-
-cleanup:
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virEventAddTimeout(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval;
- PyObject *pyobj_cbData;
- virEventTimeoutCallback cb = libvirt_virEventTimeoutCallback;
- int timeout;
- int ret;
-
- if (!PyArg_ParseTuple(args, (char *) "iO:virEventAddTimeout",
- &timeout, &pyobj_cbData)) {
- DEBUG("%s failed to parse tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
-
- Py_INCREF(pyobj_cbData);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virEventAddTimeout(timeout, cb, pyobj_cbData, NULL);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (ret < 0) {
- Py_DECREF(pyobj_cbData);
- }
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static void
-libvirt_virConnectDomainEventFreeFunc(void *opaque)
-{
- PyObject *pyobj_conn = (PyObject*)opaque;
- LIBVIRT_ENSURE_THREAD_STATE;
- Py_DECREF(pyobj_conn);
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static int
-libvirt_virConnectDomainEventLifecycleCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- int event,
- int detail,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventLifecycleCallback",
- (char*)"OiiO",
- pyobj_dom,
- event, detail,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventGenericCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventGenericCallback",
- (char*)"OO",
- pyobj_dom, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventRTCChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- long long utcoffset,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventRTCChangeCallback",
- (char*)"OLO",
- pyobj_dom,
- (PY_LONG_LONG)utcoffset,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventWatchdogCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- int action,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventWatchdogCallback",
- (char*)"OiO",
- pyobj_dom,
- action,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventIOErrorCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- const char *srcPath,
- const char *devAlias,
- int action,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventIOErrorCallback",
- (char*)"OssiO",
- pyobj_dom,
- srcPath, devAlias, action,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventIOErrorReasonCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- const char *srcPath,
- const char *devAlias,
- int action,
- const char *reason,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventIOErrorReasonCallback",
- (char*)"OssisO",
- pyobj_dom,
- srcPath, devAlias, action, reason,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- int phase,
- virDomainEventGraphicsAddressPtr local,
- virDomainEventGraphicsAddressPtr remote,
- const char *authScheme,
- virDomainEventGraphicsSubjectPtr subject,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- PyObject *pyobj_local;
- PyObject *pyobj_remote;
- PyObject *pyobj_subject;
- int ret = -1;
- size_t i;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- pyobj_local = PyDict_New();
- PyDict_SetItem(pyobj_local,
- libvirt_constcharPtrWrap("family"),
- libvirt_intWrap(local->family));
- PyDict_SetItem(pyobj_local,
- libvirt_constcharPtrWrap("node"),
- libvirt_constcharPtrWrap(local->node));
- PyDict_SetItem(pyobj_local,
- libvirt_constcharPtrWrap("service"),
- libvirt_constcharPtrWrap(local->service));
-
- pyobj_remote = PyDict_New();
- PyDict_SetItem(pyobj_remote,
- libvirt_constcharPtrWrap("family"),
- libvirt_intWrap(remote->family));
- PyDict_SetItem(pyobj_remote,
- libvirt_constcharPtrWrap("node"),
- libvirt_constcharPtrWrap(remote->node));
- PyDict_SetItem(pyobj_remote,
- libvirt_constcharPtrWrap("service"),
- libvirt_constcharPtrWrap(remote->service));
-
- pyobj_subject = PyList_New(subject->nidentity);
- for (i = 0; i < subject->nidentity; i++) {
- PyObject *pair = PyTuple_New(2);
- PyTuple_SetItem(pair, 0, libvirt_constcharPtrWrap(subject->identities[i].type));
- PyTuple_SetItem(pair, 1, libvirt_constcharPtrWrap(subject->identities[i].name));
-
- PyList_SetItem(pyobj_subject, i, pair);
- }
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventGraphicsCallback",
- (char*)"OiOOsOO",
- pyobj_dom,
- phase, pyobj_local, pyobj_remote,
- authScheme, pyobj_subject,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventBlockJobCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- const char *path,
- int type,
- int status,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"dispatchDomainEventBlockPullCallback",
- (char*)"OsiiO",
- pyobj_dom, path, type, status, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
-#if DEBUG_ERROR
- printf("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
-#endif
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventDiskChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- const char *oldSrcPath,
- const char *newSrcPath,
- const char *devAlias,
- int reason,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
-
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventDiskChangeCallback",
- (char*)"OsssiO",
- pyobj_dom,
- oldSrcPath, newSrcPath,
- devAlias, reason, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventTrayChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- const char *devAlias,
- int reason,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
-
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventTrayChangeCallback",
- (char*)"OsiO",
- pyobj_dom,
- devAlias, reason, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventPMWakeupCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- int reason,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
-
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventPMWakeupCallback",
- (char*)"OiO",
- pyobj_dom,
- reason,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventPMSuspendCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- int reason,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
-
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventPMSuspendCallback",
- (char*)"OiO",
- pyobj_dom,
- reason,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventBalloonChangeCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- unsigned long long actual,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventBalloonChangeCallback",
- (char*)"OLO",
- pyobj_dom,
- (PY_LONG_LONG)actual,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventPMSuspendDiskCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- int reason,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
-
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventPMSuspendDiskCallback",
- (char*)"OiO",
- pyobj_dom,
- reason,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static int
-libvirt_virConnectDomainEventDeviceRemovedCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
- virDomainPtr dom,
- const char *devAlias,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_dom;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
- int ret = -1;
-
- LIBVIRT_ENSURE_THREAD_STATE;
- /* Create a python instance of this virDomainPtr */
- virDomainRef(dom);
-
- pyobj_dom = libvirt_virDomainPtrWrap(dom);
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchDomainEventDeviceRemovedCallback",
- (char*)"OsO",
- pyobj_dom, devAlias, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
- Py_DECREF(pyobj_dom);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- ret = 0;
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
- return ret;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventRegisterAny(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- PyObject *py_retval; /* return value */
- PyObject *pyobj_conn; /* virConnectPtr */
- PyObject *pyobj_dom;
- PyObject *pyobj_cbData; /* hash of callback data */
- int eventID;
- virConnectPtr conn;
- int ret = 0;
- virConnectDomainEventGenericCallback cb = NULL;
- virDomainPtr dom;
-
- if (!PyArg_ParseTuple
- (args, (char *) "OOiO:virConnectDomainEventRegisterAny",
- &pyobj_conn, &pyobj_dom, &eventID, &pyobj_cbData)) {
- DEBUG("%s failed parsing tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
-
- DEBUG("libvirt_virConnectDomainEventRegister(%p %p %d %p) called\n",
- pyobj_conn, pyobj_dom, eventID, pyobj_cbData);
- conn = PyvirConnect_Get(pyobj_conn);
- if (pyobj_dom == Py_None)
- dom = NULL;
- else
- dom = PyvirDomain_Get(pyobj_dom);
-
- switch ((virDomainEventID) eventID) {
- case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventLifecycleCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_REBOOT:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_RTC_CHANGE:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventRTCChangeCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_WATCHDOG:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventWatchdogCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_IO_ERROR:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventIOErrorReasonCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_GRAPHICS:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGraphicsCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_CONTROL_ERROR:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventGenericCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_BLOCK_JOB:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBlockJobCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_DISK_CHANGE:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDiskChangeCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_TRAY_CHANGE:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventTrayChangeCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_PMWAKEUP:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMWakeupCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_PMSUSPEND:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventBalloonChangeCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_PMSUSPEND_DISK:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventPMSuspendDiskCallback);
- break;
- case VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED:
- cb = VIR_DOMAIN_EVENT_CALLBACK(libvirt_virConnectDomainEventDeviceRemovedCallback);
- break;
-
- case VIR_DOMAIN_EVENT_ID_LAST:
- break;
- }
-
- if (!cb) {
- return VIR_PY_INT_FAIL;
- }
-
- Py_INCREF(pyobj_cbData);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virConnectDomainEventRegisterAny(conn, dom, eventID,
- cb, pyobj_cbData,
- libvirt_virConnectDomainEventFreeFunc);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (ret < 0) {
- Py_DECREF(pyobj_cbData);
- }
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectDomainEventDeregisterAny(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- PyObject *py_retval;
- PyObject *pyobj_conn;
- int callbackID;
- virConnectPtr conn;
- int ret = 0;
-
- if (!PyArg_ParseTuple
- (args, (char *) "Oi:virConnectDomainEventDeregister",
- &pyobj_conn, &callbackID))
- return NULL;
-
- DEBUG("libvirt_virConnectDomainEventDeregister(%p) called\n", pyobj_conn);
-
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- ret = virConnectDomainEventDeregisterAny(conn, callbackID);
-
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-
-static void
-libvirt_virConnectCloseCallbackDispatch(virConnectPtr conn ATTRIBUTE_UNUSED,
- int reason,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject*)opaque;
- PyObject *pyobj_ret;
- PyObject *pyobj_conn;
- PyObject *dictKey;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- Py_INCREF(pyobj_cbData);
-
- dictKey = libvirt_constcharPtrWrap("conn");
- pyobj_conn = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the Callback Dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_conn,
- (char*)"_dispatchCloseCallback",
- (char*)"iO",
- reason,
- pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virConnectRegisterCloseCallback(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- PyObject *py_retval; /* return value */
- PyObject *pyobj_conn; /* virConnectPtr */
- PyObject *pyobj_cbData; /* hash of callback data */
- virConnectPtr conn;
- int ret = 0;
-
- if (!PyArg_ParseTuple
- (args, (char *) "OO:virConnectRegisterCloseCallback",
- &pyobj_conn, &pyobj_cbData)) {
- DEBUG("%s failed parsing tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
-
- DEBUG("libvirt_virConnectRegisterCloseCallback(%p %p) called\n",
- pyobj_conn, pyobj_cbData);
- conn = PyvirConnect_Get(pyobj_conn);
-
- Py_INCREF(pyobj_cbData);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virConnectRegisterCloseCallback(conn,
- libvirt_virConnectCloseCallbackDispatch,
- pyobj_cbData,
- libvirt_virConnectDomainEventFreeFunc);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (ret < 0) {
- Py_DECREF(pyobj_cbData);
- }
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virConnectUnregisterCloseCallback(ATTRIBUTE_UNUSED PyObject * self,
- PyObject * args)
-{
- PyObject *py_retval;
- PyObject *pyobj_conn;
- virConnectPtr conn;
- int ret = 0;
-
- if (!PyArg_ParseTuple
- (args, (char *) "O:virConnectDomainEventUnregister",
- &pyobj_conn))
- return NULL;
-
- DEBUG("libvirt_virConnectDomainEventUnregister(%p) called\n",
- pyobj_conn);
-
- conn = PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
-
- ret = virConnectUnregisterCloseCallback(conn,
- libvirt_virConnectCloseCallbackDispatch);
-
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static void
-libvirt_virStreamEventFreeFunc(void *opaque)
-{
- PyObject *pyobj_stream = (PyObject*)opaque;
- LIBVIRT_ENSURE_THREAD_STATE;
- Py_DECREF(pyobj_stream);
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static void
-libvirt_virStreamEventCallback(virStreamPtr st ATTRIBUTE_UNUSED,
- int events,
- void *opaque)
-{
- PyObject *pyobj_cbData = (PyObject *)opaque;
- PyObject *pyobj_stream;
- PyObject *pyobj_ret;
- PyObject *dictKey;
-
- LIBVIRT_ENSURE_THREAD_STATE;
-
- Py_INCREF(pyobj_cbData);
- dictKey = libvirt_constcharPtrWrap("stream");
- pyobj_stream = PyDict_GetItem(pyobj_cbData, dictKey);
- Py_DECREF(dictKey);
-
- /* Call the pure python dispatcher */
- pyobj_ret = PyObject_CallMethod(pyobj_stream,
- (char *)"_dispatchStreamEventCallback",
- (char *)"iO",
- events, pyobj_cbData);
-
- Py_DECREF(pyobj_cbData);
-
- if (!pyobj_ret) {
- DEBUG("%s - ret:%p\n", __FUNCTION__, pyobj_ret);
- PyErr_Print();
- } else {
- Py_DECREF(pyobj_ret);
- }
-
- LIBVIRT_RELEASE_THREAD_STATE;
-}
-
-static PyObject *
-libvirt_virStreamEventAddCallback(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval;
- PyObject *pyobj_stream;
- PyObject *pyobj_cbData;
- virStreamPtr stream;
- virStreamEventCallback cb = libvirt_virStreamEventCallback;
- int ret;
- int events;
-
- if (!PyArg_ParseTuple(args, (char *) "OiO:virStreamEventAddCallback",
- &pyobj_stream, &events, &pyobj_cbData)) {
- DEBUG("%s failed to parse tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
-
- DEBUG("libvirt_virStreamEventAddCallback(%p, %d, %p) called\n",
- pyobj_stream, events, pyobj_cbData);
- stream = PyvirStream_Get(pyobj_stream);
-
- Py_INCREF(pyobj_cbData);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virStreamEventAddCallback(stream, events, cb, pyobj_cbData,
- libvirt_virStreamEventFreeFunc);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (ret < 0) {
- Py_DECREF(pyobj_cbData);
- }
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virStreamRecv(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_stream;
- virStreamPtr stream;
- char *buf = NULL;
- int ret;
- int nbytes;
-
- if (!PyArg_ParseTuple(args, (char *) "Oi:virStreamRecv",
- &pyobj_stream, &nbytes)) {
- DEBUG("%s failed to parse tuple\n", __FUNCTION__);
- return VIR_PY_NONE;
- }
- stream = PyvirStream_Get(pyobj_stream);
-
- if (VIR_ALLOC_N_QUIET(buf, nbytes+1 > 0 ? nbytes+1 : 1) < 0)
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virStreamRecv(stream, buf, nbytes);
- LIBVIRT_END_ALLOW_THREADS;
-
- buf[ret > -1 ? ret : 0] = '\0';
- DEBUG("StreamRecv ret=%d strlen=%d\n", ret, (int) strlen(buf));
-
- if (ret == -2)
- return libvirt_intWrap(ret);
- if (ret < 0)
- return VIR_PY_NONE;
- return libvirt_charPtrSizeWrap((char *) buf, (Py_ssize_t) ret);
-}
-
-static PyObject *
-libvirt_virStreamSend(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval;
- PyObject *pyobj_stream;
- virStreamPtr stream;
- char *data;
- int datalen;
- int ret;
- int nbytes;
-
- if (!PyArg_ParseTuple(args, (char *) "Oz#i:virStreamRecv",
- &pyobj_stream, &data, &datalen, &nbytes)) {
- DEBUG("%s failed to parse tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
- stream = PyvirStream_Get(pyobj_stream);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virStreamSend(stream, data, nbytes);
- LIBVIRT_END_ALLOW_THREADS;
-
- DEBUG("StreamSend ret=%d\n", ret);
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *py_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *pyobj_list;
- int codeset;
- int holdtime;
- unsigned int flags;
- int ret;
- size_t i;
- unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
- unsigned int nkeycodes;
-
- if (!PyArg_ParseTuple(args, (char *)"OiiOii:virDomainSendKey",
- &pyobj_domain, &codeset, &holdtime, &pyobj_list,
- &nkeycodes, &flags)) {
- DEBUG("%s failed to parse tuple\n", __FUNCTION__);
- return VIR_PY_INT_FAIL;
- }
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (!PyList_Check(pyobj_list)) {
- return VIR_PY_INT_FAIL;
- }
-
- if (nkeycodes != PyList_Size(pyobj_list) ||
- nkeycodes > VIR_DOMAIN_SEND_KEY_MAX_KEYS) {
- return VIR_PY_INT_FAIL;
- }
-
- for (i = 0; i < nkeycodes; i++) {
- keycodes[i] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list, i));
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virDomainSendKey(domain, codeset, holdtime, keycodes, nkeycodes, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- DEBUG("virDomainSendKey ret=%d\n", ret);
-
- py_retval = libvirt_intWrap(ret);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainMigrateGetCompressionCache(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_domain;
- virDomainPtr domain;
- unsigned int flags;
- unsigned long long cacheSize;
- int rc;
-
- if (!PyArg_ParseTuple(args,
- (char *) "Oi:virDomainMigrateGetCompressionCache",
- &pyobj_domain, &flags))
- return VIR_PY_NONE;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- rc = virDomainMigrateGetCompressionCache(domain, &cacheSize, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (rc < 0)
- return VIR_PY_NONE;
-
- return libvirt_ulonglongWrap(cacheSize);
-}
-
-static PyObject *
-libvirt_virDomainMigrateGetMaxSpeed(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval;
- int c_retval;
- unsigned long bandwidth;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- unsigned int flags = 0;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainMigrateGetMaxSpeed",
- &pyobj_domain, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainMigrateGetMaxSpeed(domain, &bandwidth, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_INT_FAIL;
- py_retval = libvirt_ulongWrap(bandwidth);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainMigrate3(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_domain;
- virDomainPtr domain;
- PyObject *pyobj_dconn;
- virConnectPtr dconn;
- PyObject *dict;
- unsigned int flags;
- virTypedParameterPtr params;
- int nparams;
- virDomainPtr ddom = NULL;
-
- if (!PyArg_ParseTuple(args, (char *) "OOOi:virDomainMigrate3",
- &pyobj_domain, &pyobj_dconn, &dict, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
- dconn = (virConnectPtr) PyvirConnect_Get(pyobj_dconn);
-
- if (virPyDictToTypedParams(dict, ¶ms, &nparams, NULL, 0) < 0)
- return NULL;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ddom = virDomainMigrate3(domain, dconn, params, nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- virTypedParamsFree(params, nparams);
- return libvirt_virDomainPtrWrap(ddom);
-}
-
-static PyObject *
-libvirt_virDomainMigrateToURI3(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- PyObject *pyobj_domain;
- virDomainPtr domain;
- char *dconnuri;
- PyObject *dict;
- unsigned int flags;
- virTypedParameterPtr params;
- int nparams;
- int ret = -1;
-
- if (!PyArg_ParseTuple(args, (char *) "OzOi:virDomainMigrate3",
- &pyobj_domain, &dconnuri, &dict, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (virPyDictToTypedParams(dict, ¶ms, &nparams, NULL, 0) < 0)
- return NULL;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- ret = virDomainMigrateToURI3(domain, dconnuri, params, nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- virTypedParamsFree(params, nparams);
- return libvirt_intWrap(ret);
-}
-
-static PyObject *
-libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval = NULL;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- const char *disk;
- unsigned long long offset;
- size_t size;
- char *buf;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"OzLni:virDomainBlockPeek", &pyobj_domain,
- &disk, &offset, &size, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (VIR_ALLOC_N_QUIET(buf, size) < 0)
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainBlockPeek(domain, disk, offset, size, buf, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0) {
- py_retval = VIR_PY_NONE;
- goto cleanup;
- }
-
- py_retval = PyString_FromStringAndSize(buf, size);
-
-cleanup:
- VIR_FREE(buf);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virDomainMemoryPeek(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval = NULL;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- unsigned long long start;
- size_t size;
- char *buf;
- unsigned int flags;
-
- if (!PyArg_ParseTuple(args, (char *)"OLni:virDomainMemoryPeek", &pyobj_domain,
- &start, &size, &flags))
- return NULL;
-
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (VIR_ALLOC_N_QUIET(buf, size) < 0)
- return VIR_PY_NONE;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainMemoryPeek(domain, start, size, buf, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0) {
- py_retval = VIR_PY_NONE;
- goto cleanup;
- }
-
- py_retval = PyString_FromStringAndSize(buf, size);
-
-cleanup:
- VIR_FREE(buf);
- return py_retval;
-}
-
-static PyObject *
-libvirt_virNodeSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virConnectPtr conn;
- PyObject *pyobj_conn, *info;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- Py_ssize_t size = 0;
- unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
-
- if (!PyArg_ParseTuple(args,
- (char *)"OOi:virNodeSetMemoryParameters",
- &pyobj_conn, &info, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- if ((size = PyDict_Size(info)) < 0)
- return NULL;
-
- if (size == 0) {
- PyErr_Format(PyExc_LookupError,
- "Need non-empty dictionary to set attributes");
- return NULL;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeGetMemoryParameters(conn, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_INT_FAIL;
-
- if (nparams == 0) {
- PyErr_Format(PyExc_LookupError,
- "no settable attributes");
- return NULL;
- }
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeGetMemoryParameters(conn, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- new_params = setPyVirTypedParameter(info, params, nparams);
- if (!new_params)
- goto cleanup;
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeSetMemoryParameters(conn, new_params, size, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_INT_FAIL;
- goto cleanup;
- }
-
- ret = VIR_PY_INT_SUCCESS;
-
-cleanup:
- virTypedParamsFree(params, nparams);
- VIR_FREE(new_params);
- return ret;
-}
-
-static PyObject *
-libvirt_virNodeGetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virConnectPtr conn;
- PyObject *pyobj_conn;
- PyObject *ret = NULL;
- int i_retval;
- int nparams = 0;
- unsigned int flags;
- virTypedParameterPtr params;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virNodeGetMemoryParameters",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeGetMemoryParameters(conn, NULL, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if (!nparams)
- return PyDict_New();
-
- if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
- return PyErr_NoMemory();
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeGetMemoryParameters(conn, params, &nparams, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0) {
- ret = VIR_PY_NONE;
- goto cleanup;
- }
-
- ret = getPyVirTypedParameter(params, nparams);
-
-cleanup:
- virTypedParamsFree(params, nparams);
- return ret;
-}
-
-static PyObject *
-libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args)
-{
- virConnectPtr conn;
- PyObject *pyobj_conn;
- PyObject *ret = NULL;
- PyObject *pycpumap = NULL;
- PyObject *pyused = NULL;
- PyObject *pycpunum = NULL;
- PyObject *pyonline = NULL;
- int i_retval;
- unsigned char *cpumap = NULL;
- unsigned int online = 0;
- unsigned int flags;
- size_t i;
-
- if (!PyArg_ParseTuple(args, (char *)"Oi:virNodeGetCPUMap",
- &pyobj_conn, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- i_retval = virNodeGetCPUMap(conn, &cpumap, &online, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (i_retval < 0)
- return VIR_PY_NONE;
-
- if ((ret = PyTuple_New(3)) == NULL)
- goto error;
-
- /* 0: number of CPUs */
- if ((pycpunum = PyLong_FromLong(i_retval)) == NULL ||
- PyTuple_SetItem(ret, 0, pycpunum) < 0)
- goto error;
-
- /* 1: CPU map */
- if ((pycpumap = PyList_New(i_retval)) == NULL)
- goto error;
-
- for (i = 0; i < i_retval; i++) {
- if ((pyused = PyBool_FromLong(VIR_CPU_USED(cpumap, i))) == NULL)
- goto error;
- if (PyList_SetItem(pycpumap, i, pyused) < 0)
- goto error;
- }
-
- if (PyTuple_SetItem(ret, 1, pycpumap) < 0)
- goto error;
-
- /* 2: number of online CPUs */
- if ((pyonline = PyLong_FromLong(online)) == NULL ||
- PyTuple_SetItem(ret, 2, pyonline) < 0)
- goto error;
-
-cleanup:
- VIR_FREE(cpumap);
- return ret;
-error:
- Py_XDECREF(ret);
- Py_XDECREF(pycpumap);
- Py_XDECREF(pyused);
- Py_XDECREF(pycpunum);
- Py_XDECREF(pyonline);
- ret = NULL;
- goto cleanup;
-}
-
-
-static PyObject *
-libvirt_virDomainCreateWithFiles(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval = NULL;
- int c_retval;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- PyObject *pyobj_files;
- unsigned int flags;
- unsigned int nfiles;
- int *files = NULL;
- size_t i;
-
- if (!PyArg_ParseTuple(args, (char *)"OOi:virDomainCreateWithFiles",
- &pyobj_domain, &pyobj_files, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- nfiles = PyList_Size(pyobj_files);
-
- if (VIR_ALLOC_N_QUIET(files, nfiles) < 0)
- return PyErr_NoMemory();
-
- for (i = 0; i < nfiles; i++) {
- PyObject *pyfd;
- int fd;
-
- pyfd = PyList_GetItem(pyobj_files, i);
-
- if (libvirt_intUnwrap(pyfd, &fd) < 0)
- goto cleanup;
-
- files[i] = fd;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainCreateWithFiles(domain, nfiles, files, flags);
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_intWrap((int) c_retval);
-
-cleanup:
- VIR_FREE(files);
- return py_retval;
-}
-
-
-static PyObject *
-libvirt_virDomainCreateXMLWithFiles(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
- PyObject *py_retval = NULL;
- virDomainPtr c_retval;
- virConnectPtr conn;
- PyObject *pyobj_conn;
- char * xmlDesc;
- PyObject *pyobj_files;
- unsigned int flags;
- unsigned int nfiles;
- int *files = NULL;
- size_t i;
-
- if (!PyArg_ParseTuple(args, (char *)"OzOi:virDomainCreateXMLWithFiles",
- &pyobj_conn, &xmlDesc, &pyobj_files, &flags))
- return NULL;
- conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-
- nfiles = PyList_Size(pyobj_files);
-
- if (VIR_ALLOC_N_QUIET(files, nfiles) < 0)
- return PyErr_NoMemory();
-
- for (i = 0; i < nfiles; i++) {
- PyObject *pyfd;
- int fd;
-
- pyfd = PyList_GetItem(pyobj_files, i);
-
- if (libvirt_intUnwrap(pyfd, &fd) < 0)
- goto cleanup;
-
- files[i] = fd;
- }
-
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainCreateXMLWithFiles(conn, xmlDesc, nfiles, files, flags);
- LIBVIRT_END_ALLOW_THREADS;
- py_retval = libvirt_virDomainPtrWrap((virDomainPtr) c_retval);
-
-cleanup:
- VIR_FREE(files);
- return py_retval;
-}
-
-
-/************************************************************************
- * *
- * The registration stuff *
- * *
- ************************************************************************/
-static PyMethodDef libvirtMethods[] = {
-#include "libvirt-export.c"
- {(char *) "virGetVersion", libvirt_virGetVersion, METH_VARARGS, NULL},
- {(char *) "virConnectGetVersion", libvirt_virConnectGetVersion, METH_VARARGS, NULL},
- {(char *) "virConnectGetCPUModelNames", libvirt_virConnectGetCPUModelNames, METH_VARARGS, NULL},
- {(char *) "virConnectGetLibVersion", libvirt_virConnectGetLibVersion, METH_VARARGS, NULL},
- {(char *) "virConnectOpenAuth", libvirt_virConnectOpenAuth, METH_VARARGS, NULL},
- {(char *) "virConnectListDomainsID", libvirt_virConnectListDomainsID, METH_VARARGS, NULL},
- {(char *) "virConnectListDefinedDomains", libvirt_virConnectListDefinedDomains, METH_VARARGS, NULL},
- {(char *) "virConnectListAllDomains", libvirt_virConnectListAllDomains, METH_VARARGS, NULL},
- {(char *) "virConnectDomainEventRegister", libvirt_virConnectDomainEventRegister, METH_VARARGS, NULL},
- {(char *) "virConnectDomainEventDeregister", libvirt_virConnectDomainEventDeregister, METH_VARARGS, NULL},
- {(char *) "virConnectDomainEventRegisterAny", libvirt_virConnectDomainEventRegisterAny, METH_VARARGS, NULL},
- {(char *) "virConnectDomainEventDeregisterAny", libvirt_virConnectDomainEventDeregisterAny, METH_VARARGS, NULL},
- {(char *) "virConnectRegisterCloseCallback", libvirt_virConnectRegisterCloseCallback, METH_VARARGS, NULL},
- {(char *) "virConnectUnregisterCloseCallback", libvirt_virConnectUnregisterCloseCallback, METH_VARARGS, NULL},
- {(char *) "virStreamEventAddCallback", libvirt_virStreamEventAddCallback, METH_VARARGS, NULL},
- {(char *) "virStreamRecv", libvirt_virStreamRecv, METH_VARARGS, NULL},
- {(char *) "virStreamSend", libvirt_virStreamSend, METH_VARARGS, NULL},
- {(char *) "virDomainGetInfo", libvirt_virDomainGetInfo, METH_VARARGS, NULL},
- {(char *) "virDomainGetState", libvirt_virDomainGetState, METH_VARARGS, NULL},
- {(char *) "virDomainGetControlInfo", libvirt_virDomainGetControlInfo, METH_VARARGS, NULL},
- {(char *) "virDomainGetBlockInfo", libvirt_virDomainGetBlockInfo, METH_VARARGS, NULL},
- {(char *) "virNodeGetInfo", libvirt_virNodeGetInfo, METH_VARARGS, NULL},
- {(char *) "virNodeGetCPUStats", libvirt_virNodeGetCPUStats, METH_VARARGS, NULL},
- {(char *) "virNodeGetMemoryStats", libvirt_virNodeGetMemoryStats, METH_VARARGS, NULL},
- {(char *) "virDomainGetUUID", libvirt_virDomainGetUUID, METH_VARARGS, NULL},
- {(char *) "virDomainGetUUIDString", libvirt_virDomainGetUUIDString, METH_VARARGS, NULL},
- {(char *) "virDomainLookupByUUID", libvirt_virDomainLookupByUUID, METH_VARARGS, NULL},
- {(char *) "virRegisterErrorHandler", libvirt_virRegisterErrorHandler, METH_VARARGS, NULL},
- {(char *) "virGetLastError", libvirt_virGetLastError, METH_VARARGS, NULL},
- {(char *) "virConnGetLastError", libvirt_virConnGetLastError, METH_VARARGS, NULL},
- {(char *) "virConnectListNetworks", libvirt_virConnectListNetworks, METH_VARARGS, NULL},
- {(char *) "virConnectListDefinedNetworks", libvirt_virConnectListDefinedNetworks, METH_VARARGS, NULL},
- {(char *) "virConnectListAllNetworks", libvirt_virConnectListAllNetworks, METH_VARARGS, NULL},
- {(char *) "virNetworkGetUUID", libvirt_virNetworkGetUUID, METH_VARARGS, NULL},
- {(char *) "virNetworkGetUUIDString", libvirt_virNetworkGetUUIDString, METH_VARARGS, NULL},
- {(char *) "virNetworkLookupByUUID", libvirt_virNetworkLookupByUUID, METH_VARARGS, NULL},
- {(char *) "virDomainGetAutostart", libvirt_virDomainGetAutostart, METH_VARARGS, NULL},
- {(char *) "virNetworkGetAutostart", libvirt_virNetworkGetAutostart, METH_VARARGS, NULL},
- {(char *) "virDomainBlockStats", libvirt_virDomainBlockStats, METH_VARARGS, NULL},
- {(char *) "virDomainBlockStatsFlags", libvirt_virDomainBlockStatsFlags, METH_VARARGS, NULL},
- {(char *) "virDomainGetCPUStats", libvirt_virDomainGetCPUStats, METH_VARARGS, NULL},
- {(char *) "virDomainInterfaceStats", libvirt_virDomainInterfaceStats, METH_VARARGS, NULL},
- {(char *) "virDomainMemoryStats", libvirt_virDomainMemoryStats, METH_VARARGS, NULL},
- {(char *) "virNodeGetCellsFreeMemory", libvirt_virNodeGetCellsFreeMemory, METH_VARARGS, NULL},
- {(char *) "virDomainGetSchedulerType", libvirt_virDomainGetSchedulerType, METH_VARARGS, NULL},
- {(char *) "virDomainGetSchedulerParameters", libvirt_virDomainGetSchedulerParameters, METH_VARARGS, NULL},
- {(char *) "virDomainGetSchedulerParametersFlags", libvirt_virDomainGetSchedulerParametersFlags, METH_VARARGS, NULL},
- {(char *) "virDomainSetSchedulerParameters", libvirt_virDomainSetSchedulerParameters, METH_VARARGS, NULL},
- {(char *) "virDomainSetSchedulerParametersFlags", libvirt_virDomainSetSchedulerParametersFlags, METH_VARARGS, NULL},
- {(char *) "virDomainSetBlkioParameters", libvirt_virDomainSetBlkioParameters, METH_VARARGS, NULL},
- {(char *) "virDomainGetBlkioParameters", libvirt_virDomainGetBlkioParameters, METH_VARARGS, NULL},
- {(char *) "virDomainSetMemoryParameters", libvirt_virDomainSetMemoryParameters, METH_VARARGS, NULL},
- {(char *) "virDomainGetMemoryParameters", libvirt_virDomainGetMemoryParameters, METH_VARARGS, NULL},
- {(char *) "virDomainSetNumaParameters", libvirt_virDomainSetNumaParameters, METH_VARARGS, NULL},
- {(char *) "virDomainGetNumaParameters", libvirt_virDomainGetNumaParameters, METH_VARARGS, NULL},
- {(char *) "virDomainSetInterfaceParameters", libvirt_virDomainSetInterfaceParameters, METH_VARARGS, NULL},
- {(char *) "virDomainGetInterfaceParameters", libvirt_virDomainGetInterfaceParameters, METH_VARARGS, NULL},
- {(char *) "virDomainGetVcpus", libvirt_virDomainGetVcpus, METH_VARARGS, NULL},
- {(char *) "virDomainPinVcpu", libvirt_virDomainPinVcpu, METH_VARARGS, NULL},
- {(char *) "virDomainPinVcpuFlags", libvirt_virDomainPinVcpuFlags, METH_VARARGS, NULL},
- {(char *) "virDomainGetVcpuPinInfo", libvirt_virDomainGetVcpuPinInfo, METH_VARARGS, NULL},
- {(char *) "virDomainGetEmulatorPinInfo", libvirt_virDomainGetEmulatorPinInfo, METH_VARARGS, NULL},
- {(char *) "virDomainPinEmulator", libvirt_virDomainPinEmulator, METH_VARARGS, NULL},
- {(char *) "virConnectListStoragePools", libvirt_virConnectListStoragePools, METH_VARARGS, NULL},
- {(char *) "virConnectListDefinedStoragePools", libvirt_virConnectListDefinedStoragePools, METH_VARARGS, NULL},
- {(char *) "virConnectListAllStoragePools", libvirt_virConnectListAllStoragePools, METH_VARARGS, NULL},
- {(char *) "virStoragePoolGetAutostart", libvirt_virStoragePoolGetAutostart, METH_VARARGS, NULL},
- {(char *) "virStoragePoolListVolumes", libvirt_virStoragePoolListVolumes, METH_VARARGS, NULL},
- {(char *) "virStoragePoolListAllVolumes", libvirt_virStoragePoolListAllVolumes, METH_VARARGS, NULL},
- {(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo, METH_VARARGS, NULL},
- {(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo, METH_VARARGS, NULL},
- {(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID, METH_VARARGS, NULL},
- {(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString, METH_VARARGS, NULL},
- {(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID, METH_VARARGS, NULL},
- {(char *) "virEventRegisterImpl", libvirt_virEventRegisterImpl, METH_VARARGS, NULL},
- {(char *) "virEventAddHandle", libvirt_virEventAddHandle, METH_VARARGS, NULL},
- {(char *) "virEventAddTimeout", libvirt_virEventAddTimeout, METH_VARARGS, NULL},
- {(char *) "virEventInvokeHandleCallback", libvirt_virEventInvokeHandleCallback, METH_VARARGS, NULL},
- {(char *) "virEventInvokeTimeoutCallback", libvirt_virEventInvokeTimeoutCallback, METH_VARARGS, NULL},
- {(char *) "virNodeListDevices", libvirt_virNodeListDevices, METH_VARARGS, NULL},
- {(char *) "virConnectListAllNodeDevices", libvirt_virConnectListAllNodeDevices, METH_VARARGS, NULL},
- {(char *) "virNodeDeviceListCaps", libvirt_virNodeDeviceListCaps, METH_VARARGS, NULL},
- {(char *) "virSecretGetUUID", libvirt_virSecretGetUUID, METH_VARARGS, NULL},
- {(char *) "virSecretGetUUIDString", libvirt_virSecretGetUUIDString, METH_VARARGS, NULL},
- {(char *) "virSecretLookupByUUID", libvirt_virSecretLookupByUUID, METH_VARARGS, NULL},
- {(char *) "virConnectListSecrets", libvirt_virConnectListSecrets, METH_VARARGS, NULL},
- {(char *) "virConnectListAllSecrets", libvirt_virConnectListAllSecrets, METH_VARARGS, NULL},
- {(char *) "virSecretGetValue", libvirt_virSecretGetValue, METH_VARARGS, NULL},
- {(char *) "virSecretSetValue", libvirt_virSecretSetValue, METH_VARARGS, NULL},
- {(char *) "virNWFilterGetUUID", libvirt_virNWFilterGetUUID, METH_VARARGS, NULL},
- {(char *) "virNWFilterGetUUIDString", libvirt_virNWFilterGetUUIDString, METH_VARARGS, NULL},
- {(char *) "virNWFilterLookupByUUID", libvirt_virNWFilterLookupByUUID, METH_VARARGS, NULL},
- {(char *) "virConnectListNWFilters", libvirt_virConnectListNWFilters, METH_VARARGS, NULL},
- {(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters, METH_VARARGS, NULL},
- {(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces, METH_VARARGS, NULL},
- {(char *) "virConnectListDefinedInterfaces", libvirt_virConnectListDefinedInterfaces, METH_VARARGS, NULL},
- {(char *) "virConnectListAllInterfaces", libvirt_virConnectListAllInterfaces, METH_VARARGS, NULL},
- {(char *) "virConnectBaselineCPU", libvirt_virConnectBaselineCPU, METH_VARARGS, NULL},
- {(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo, METH_VARARGS, NULL},
- {(char *) "virDomainGetJobStats", libvirt_virDomainGetJobStats, METH_VARARGS, NULL},
- {(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL},
- {(char *) "virDomainListAllSnapshots", libvirt_virDomainListAllSnapshots, METH_VARARGS, NULL},
- {(char *) "virDomainSnapshotListChildrenNames", libvirt_virDomainSnapshotListChildrenNames, METH_VARARGS, NULL},
- {(char *) "virDomainSnapshotListAllChildren", libvirt_virDomainSnapshotListAllChildren, METH_VARARGS, NULL},
- {(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL},
- {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL},
- {(char *) "virDomainSetBlockIoTune", libvirt_virDomainSetBlockIoTune, METH_VARARGS, NULL},
- {(char *) "virDomainGetBlockIoTune", libvirt_virDomainGetBlockIoTune, METH_VARARGS, NULL},
- {(char *) "virDomainSendKey", libvirt_virDomainSendKey, METH_VARARGS, NULL},
- {(char *) "virDomainMigrateGetCompressionCache", libvirt_virDomainMigrateGetCompressionCache, METH_VARARGS, NULL},
- {(char *) "virDomainMigrateGetMaxSpeed", libvirt_virDomainMigrateGetMaxSpeed, METH_VARARGS, NULL},
- {(char *) "virDomainMigrate3", libvirt_virDomainMigrate3, METH_VARARGS, NULL},
- {(char *) "virDomainMigrateToURI3", libvirt_virDomainMigrateToURI3, METH_VARARGS, NULL},
- {(char *) "virDomainBlockPeek", libvirt_virDomainBlockPeek, METH_VARARGS, NULL},
- {(char *) "virDomainMemoryPeek", libvirt_virDomainMemoryPeek, METH_VARARGS, NULL},
- {(char *) "virDomainGetDiskErrors", libvirt_virDomainGetDiskErrors, METH_VARARGS, NULL},
- {(char *) "virNodeGetMemoryParameters", libvirt_virNodeGetMemoryParameters, METH_VARARGS, NULL},
- {(char *) "virNodeSetMemoryParameters", libvirt_virNodeSetMemoryParameters, METH_VARARGS, NULL},
- {(char *) "virNodeGetCPUMap", libvirt_virNodeGetCPUMap, METH_VARARGS, NULL},
- {(char *) "virDomainCreateXMLWithFiles", libvirt_virDomainCreateXMLWithFiles, METH_VARARGS, NULL},
- {(char *) "virDomainCreateWithFiles", libvirt_virDomainCreateWithFiles, METH_VARARGS, NULL},
- {NULL, NULL, 0, NULL}
-};
-
-void
-#ifndef __CYGWIN__
-initlibvirtmod
-#else
-initcygvirtmod
-#endif
- (void)
-{
- static int initialized = 0;
-
- if (initialized != 0)
- return;
-
- if (virInitialize() < 0)
- return;
-
- /* initialize the python extension module */
- Py_InitModule((char *)
-#ifndef __CYGWIN__
- "libvirtmod"
-#else
- "cygvirtmod"
-#endif
- , libvirtMethods);
-
- initialized = 1;
-}
diff --git a/python/libvirt-override.py b/python/libvirt-override.py
deleted file mode 100644
index ccfec48..0000000
--- a/python/libvirt-override.py
+++ /dev/null
@@ -1,209 +0,0 @@
-#
-# Manually written part of python bindings for libvirt
-#
-
-# On cygwin, the DLL is called cygvirtmod.dll
-try:
- import libvirtmod
-except ImportError, lib_e:
- try:
- import cygvirtmod as libvirtmod
- except ImportError, cyg_e:
- if str(cyg_e).count("No module named"):
- raise lib_e
-
-import types
-
-# The root of all libvirt errors.
-class libvirtError(Exception):
- def __init__(self, defmsg, conn=None, dom=None, net=None, pool=None, vol=None):
-
- # Never call virConnGetLastError().
- # virGetLastError() is now thread local
- err = virGetLastError()
- if err is None:
- msg = defmsg
- else:
- msg = err[2]
-
- Exception.__init__(self, msg)
-
- self.err = err
-
- def get_error_code(self):
- if self.err is None:
- return None
- return self.err[0]
-
- def get_error_domain(self):
- if self.err is None:
- return None
- return self.err[1]
-
- def get_error_message(self):
- if self.err is None:
- return None
- return self.err[2]
-
- def get_error_level(self):
- if self.err is None:
- return None
- return self.err[3]
-
- def get_str1(self):
- if self.err is None:
- return None
- return self.err[4]
-
- def get_str2(self):
- if self.err is None:
- return None
- return self.err[5]
-
- def get_str3(self):
- if self.err is None:
- return None
- return self.err[6]
-
- def get_int1(self):
- if self.err is None:
- return None
- return self.err[7]
-
- def get_int2(self):
- if self.err is None:
- return None
- return self.err[8]
-
-#
-# register the libvirt global error handler
-#
-def registerErrorHandler(f, ctx):
- """Register a Python function for error reporting.
- The function is called back as f(ctx, error), with error
- being a list of information about the error being raised.
- Returns 1 in case of success."""
- return libvirtmod.virRegisterErrorHandler(f,ctx)
-
-def openAuth(uri, auth, flags=0):
- ret = libvirtmod.virConnectOpenAuth(uri, auth, flags)
- if ret is None:raise libvirtError('virConnectOpenAuth() failed')
- return virConnect(_obj=ret)
-
-
-#
-# Return library version.
-#
-def getVersion (name = None):
- """If no name parameter is passed (or name is None) then the
- version of the libvirt library is returned as an integer.
-
- If a name is passed and it refers to a driver linked to the
- libvirt library, then this returns a tuple of (library version,
- driver version).
-
- If the name passed refers to a non-existent driver, then you
- will get the exception 'no support for hypervisor'.
-
- Versions numbers are integers: 1000000*major + 1000*minor + release."""
- if name is None:
- ret = libvirtmod.virGetVersion ()
- else:
- ret = libvirtmod.virGetVersion (name)
- if ret is None: raise libvirtError ("virGetVersion() failed")
- return ret
-
-
-#
-# Invoke an EventHandle callback
-#
-def _eventInvokeHandleCallback(watch, fd, event, opaque, opaquecompat=None):
- """
- Invoke the Event Impl Handle Callback in C
- """
- # libvirt 0.9.2 and earlier required custom event loops to know
- # that opaque=(cb, original_opaque) and pass the values individually
- # to this wrapper. This should handle the back compat case, and make
- # future invocations match the virEventHandleCallback prototype
- if opaquecompat:
- callback = opaque
- opaque = opaquecompat
- else:
- callback = opaque[0]
- opaque = opaque[1]
-
- libvirtmod.virEventInvokeHandleCallback(watch, fd, event, callback, opaque)
-
-#
-# Invoke an EventTimeout callback
-#
-def _eventInvokeTimeoutCallback(timer, opaque, opaquecompat=None):
- """
- Invoke the Event Impl Timeout Callback in C
- """
- # libvirt 0.9.2 and earlier required custom event loops to know
- # that opaque=(cb, original_opaque) and pass the values individually
- # to this wrapper. This should handle the back compat case, and make
- # future invocations match the virEventTimeoutCallback prototype
- if opaquecompat:
- callback = opaque
- opaque = opaquecompat
- else:
- callback = opaque[0]
- opaque = opaque[1]
-
- libvirtmod.virEventInvokeTimeoutCallback(timer, callback, opaque)
-
-def _dispatchEventHandleCallback(watch, fd, events, cbData):
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(watch, fd, events, opaque)
- return 0
-
-def _dispatchEventTimeoutCallback(timer, cbData):
- cb = cbData["cb"]
- opaque = cbData["opaque"]
-
- cb(timer, opaque)
- return 0
-
-def virEventAddHandle(fd, events, cb, opaque):
- """
- register a callback for monitoring file handle events
-
- @fd: file handle to monitor for events
- @events: bitset of events to watch from virEventHandleType constants
- @cb: callback to invoke when an event occurs
- @opaque: user data to pass to callback
-
- Example callback prototype is:
- def cb(watch, # int id of the handle
- fd, # int file descriptor the event occurred on
- events, # int bitmap of events that have occurred
- opaque): # opaque data passed to eventAddHandle
- """
- cbData = {"cb" : cb, "opaque" : opaque}
- ret = libvirtmod.virEventAddHandle(fd, events, cbData)
- if ret == -1: raise libvirtError ('virEventAddHandle() failed')
- return ret
-
-def virEventAddTimeout(timeout, cb, opaque):
- """
- register a callback for a timer event
-
- @timeout: time between events in milliseconds
- @cb: callback to invoke when an event occurs
- @opaque: user data to pass to callback
-
- Setting timeout to -1 will disable the timer. Setting the timeout
- to zero will cause it to fire on every event loop iteration.
-
- Example callback prototype is:
- def cb(timer, # int id of the timer
- opaque): # opaque data passed to eventAddTimeout
- """
- cbData = {"cb" : cb, "opaque" : opaque}
- ret = libvirtmod.virEventAddTimeout(timeout, cbData)
- if ret == -1: raise libvirtError ('virEventAddTimeout() failed')
- return ret
diff --git a/python/libvirt-qemu-override-api.xml b/python/libvirt-qemu-override-api.xml
deleted file mode 100644
index ca0dae9..0000000
--- a/python/libvirt-qemu-override-api.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0"?>
-<api name='libvir-qemu-python'>
- <symbols>
- <function name='virDomainQemuMonitorCommand' file='python-qemu'>
- <info>Send an arbitrary monitor command through qemu monitor of domain</info>
- <return type='str *' info='the command output or None in case of error'/>
- <arg name='domain' type='virDomainPtr' info='pointer to domain object'/>
- <arg name='cmd' type='const char *' info='the command which will be passed to QEMU monitor'/>
- <arg name='flags' type='unsigned int' info='an OR'ed set of virDomainQemuMonitorCommandFlags'/>
- </function>
- <function name='virDomainQemuAgentCommand' file='python-qemu'>
- <info>Send a Guest Agent command to domain</info>
- <return type='str *' info='the command output'/>
- <arg name='domain' type='virDomainPtr' info='pointer to the domain'/>
- <arg name='cmd' type='const char *' info='guest agent command on domain'/>
- <arg name='timeout' type='int' info='timeout seconds'/>
- <arg name='flags' type='unsigned int' info='execution flags'/>
- </function>
- </symbols>
-</api>
diff --git a/python/libvirt-qemu-override.c b/python/libvirt-qemu-override.c
deleted file mode 100644
index 6249031..0000000
--- a/python/libvirt-qemu-override.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * libvir.c: this modules implements the main part of the glue of the
- * libvir library and the Python interpreter. It provides the
- * entry points where an automatically generated stub is
- * unpractical
- *
- * Copyright (C) 2011-2012 Red Hat, Inc.
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-#include <config.h>
-
-/* Horrible kludge to work around even more horrible name-space pollution
- via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
- which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
-#undef HAVE_PTHREAD_H
-
-#include <Python.h>
-#include <libvirt/libvirt-qemu.h>
-#include <libvirt/virterror.h>
-#include "typewrappers.h"
-#include "libvirt-qemu.h"
-#include "viralloc.h"
-
-#ifndef __CYGWIN__
-extern void initlibvirtmod_qemu(void);
-#else
-extern void initcygvirtmod_qemu(void);
-#endif
-
-#if 0
-# define DEBUG_ERROR 1
-#endif
-
-#if DEBUG_ERROR
-# define DEBUG(fmt, ...) \
- printf(fmt, __VA_ARGS__)
-#else
-# define DEBUG(fmt, ...) \
- do {} while (0)
-#endif
-
-/* The two-statement sequence "Py_INCREF(Py_None); return Py_None;"
- is so common that we encapsulate it here. Now, each use is simply
- return VIR_PY_NONE; */
-#define VIR_PY_NONE (Py_INCREF (Py_None), Py_None)
-#define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
-#define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
-
-/************************************************************************
- * *
- * Statistics *
- * *
- ************************************************************************/
-
-static PyObject *
-libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self ATTRIBUTE_UNUSED,
- PyObject *args) {
- PyObject *py_retval;
- char *result = NULL;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- unsigned int flags;
- char *cmd;
- int c_retval;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainQemuMonitorCommand",
- &pyobj_domain, &cmd, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (domain == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- c_retval = virDomainQemuMonitorCommand(domain, cmd, &result, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (c_retval < 0)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromString(result);
- VIR_FREE(result);
- return py_retval;
-}
-
-static PyObject *
-libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
-{
- PyObject *py_retval;
- char *result = NULL;
- virDomainPtr domain;
- PyObject *pyobj_domain;
- int timeout;
- unsigned int flags;
- char *cmd;
-
- if (!PyArg_ParseTuple(args, (char *)"Ozii:virDomainQemuAgentCommand",
- &pyobj_domain, &cmd, &timeout, &flags))
- return NULL;
- domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
-
- if (domain == NULL)
- return VIR_PY_NONE;
- LIBVIRT_BEGIN_ALLOW_THREADS;
- result = virDomainQemuAgentCommand(domain, cmd, timeout, flags);
- LIBVIRT_END_ALLOW_THREADS;
-
- if (!result)
- return VIR_PY_NONE;
-
- py_retval = PyString_FromString(result);
- VIR_FREE(result);
- return py_retval;
-}
-/************************************************************************
- * *
- * The registration stuff *
- * *
- ************************************************************************/
-static PyMethodDef libvirtQemuMethods[] = {
-#include "libvirt-qemu-export.c"
- {(char *) "virDomainQemuMonitorCommand", libvirt_qemu_virDomainQemuMonitorCommand, METH_VARARGS, NULL},
- {(char *) "virDomainQemuAgentCommand", libvirt_qemu_virDomainQemuAgentCommand, METH_VARARGS, NULL},
- {NULL, NULL, 0, NULL}
-};
-
-void
-#ifndef __CYGWIN__
-initlibvirtmod_qemu
-#else
-initcygvirtmod_qemu
-#endif
- (void)
-{
- static int initialized = 0;
-
- if (initialized != 0)
- return;
-
- if (virInitialize() < 0)
- return;
-
- /* initialize the python extension module */
- Py_InitModule((char *)
-#ifndef __CYGWIN__
- "libvirtmod_qemu"
-#else
- "cygvirtmod_qemu"
-#endif
- , libvirtQemuMethods);
-
- initialized = 1;
-}
diff --git a/python/sanitytest.py b/python/sanitytest.py
deleted file mode 100644
index ace6792..0000000
--- a/python/sanitytest.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/python
-
-import libvirt
-
-globals = dir(libvirt)
-
-# Sanity test that the generator hasn't gone wrong
-
-# Look for core classes
-for clsname in ["virConnect",
- "virDomain",
- "virDomainSnapshot",
- "virInterface",
- "virNWFilter",
- "virNodeDevice",
- "virNetwork",
- "virSecret",
- "virStoragePool",
- "virStorageVol",
- "virStream",
- ]:
- assert(clsname in globals)
- assert(object in getattr(libvirt, clsname).__bases__)
-
-# Constants
-assert("VIR_CONNECT_RO" in globals)
-
-# Error related bits
-assert("libvirtError" in globals)
-assert("VIR_ERR_AUTH_FAILED" in globals)
-assert("virGetLastError" in globals)
-
-# Some misc methods
-assert("virInitialize" in globals)
-assert("virEventAddHandle" in globals)
-assert("virEventRegisterDefaultImpl" in globals)
diff --git a/python/typewrappers.c b/python/typewrappers.c
deleted file mode 100644
index 9ba8790..0000000
--- a/python/typewrappers.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * types.c: converter functions between the internal representation
- * and the Python objects
- *
- * Copyright (C) 2005, 2007, 2012 Red Hat, Inc.
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-#include <config.h>
-
-/* Horrible kludge to work around even more horrible name-space pollution
- * via Python.h. That file includes /usr/include/python2.5/pyconfig*.h,
- * which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
-#undef HAVE_PTHREAD_H
-
-#include "typewrappers.h"
-
-#include "viralloc.h"
-
-#ifndef Py_CAPSULE_H
-typedef void(*PyCapsule_Destructor)(void *, void *);
-#endif
-
-static PyObject *
-libvirt_buildPyObject(void *cobj,
- const char *name,
- PyCapsule_Destructor destr)
-{
- PyObject *ret;
-
-#ifdef Py_CAPSULE_H
- ret = PyCapsule_New(cobj, name, destr);
-#else
- ret = PyCObject_FromVoidPtrAndDesc(cobj, (void *) name, destr);
-#endif /* _TEST_CAPSULE */
-
- return ret;
-}
-
-PyObject *
-libvirt_intWrap(int val)
-{
- PyObject *ret;
- ret = PyInt_FromLong((long) val);
- return ret;
-}
-
-PyObject *
-libvirt_longWrap(long val)
-{
- PyObject *ret;
- ret = PyInt_FromLong(val);
- return ret;
-}
-
-PyObject *
-libvirt_ulongWrap(unsigned long val)
-{
- PyObject *ret;
- ret = PyLong_FromLong(val);
- return ret;
-}
-
-PyObject *
-libvirt_longlongWrap(long long val)
-{
- PyObject *ret;
- ret = PyLong_FromUnsignedLongLong((unsigned long long) val);
- return ret;
-}
-
-PyObject *
-libvirt_ulonglongWrap(unsigned long long val)
-{
- PyObject *ret;
- ret = PyLong_FromUnsignedLongLong(val);
- return ret;
-}
-
-PyObject *
-libvirt_charPtrSizeWrap(char *str, Py_ssize_t size)
-{
- PyObject *ret;
-
- if (str == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- ret = PyString_FromStringAndSize(str, size);
- VIR_FREE(str);
- return ret;
-}
-
-PyObject *
-libvirt_charPtrWrap(char *str)
-{
- PyObject *ret;
-
- if (str == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- ret = PyString_FromString(str);
- VIR_FREE(str);
- return ret;
-}
-
-PyObject *
-libvirt_constcharPtrWrap(const char *str)
-{
- PyObject *ret;
-
- if (str == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- ret = PyString_FromString(str);
- return ret;
-}
-
-int
-libvirt_intUnwrap(PyObject *obj, int *val)
-{
- long long_val;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- /* If obj is type of PyInt_Type, PyInt_AsLong converts it
- * to C long type directly. If it is of PyLong_Type, PyInt_AsLong
- * will call PyLong_AsLong() to deal with it automatically.
- */
- long_val = PyInt_AsLong(obj);
- if ((long_val == -1) && PyErr_Occurred())
- return -1;
-
-#if LONG_MAX != INT_MAX
- if (long_val >= INT_MIN && long_val <= INT_MAX) {
- *val = long_val;
- } else {
- PyErr_SetString(PyExc_OverflowError,
- "Python int too large to convert to C int");
- return -1;
- }
-#else
- *val = long_val;
-#endif
- return 0;
-}
-
-int
-libvirt_uintUnwrap(PyObject *obj, unsigned int *val)
-{
- long long_val;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- long_val = PyInt_AsLong(obj);
- if ((long_val == -1) && PyErr_Occurred())
- return -1;
-
- if (long_val >= 0 && long_val <= UINT_MAX) {
- *val = long_val;
- } else {
- PyErr_SetString(PyExc_OverflowError,
- "Python int too large to convert to C unsigned int");
- return -1;
- }
- return 0;
-}
-
-int
-libvirt_longUnwrap(PyObject *obj, long *val)
-{
- long long_val;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- long_val = PyInt_AsLong(obj);
- if ((long_val == -1) && PyErr_Occurred())
- return -1;
-
- *val = long_val;
- return 0;
-}
-
-int
-libvirt_ulongUnwrap(PyObject *obj, unsigned long *val)
-{
- long long_val;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- long_val = PyInt_AsLong(obj);
- if ((long_val == -1) && PyErr_Occurred())
- return -1;
-
- if (long_val >= 0) {
- *val = long_val;
- } else {
- PyErr_SetString(PyExc_OverflowError,
- "negative Python int cannot be converted to C unsigned long");
- return -1;
- }
- return 0;
-}
-
-int
-libvirt_longlongUnwrap(PyObject *obj, long long *val)
-{
- long long llong_val = -1;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- /* If obj is of PyInt_Type, PyLong_AsLongLong
- * will call PyInt_AsLong() to handle it automatically.
- */
- if (PyInt_Check(obj) || PyLong_Check(obj))
- llong_val = PyLong_AsLongLong(obj);
- else
- PyErr_SetString(PyExc_TypeError, "an integer is required");
-
- if ((llong_val == -1) && PyErr_Occurred())
- return -1;
-
- *val = llong_val;
- return 0;
-}
-
-int
-libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val)
-{
- unsigned long long ullong_val = -1;
- long long llong_val;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- /* The PyLong_AsUnsignedLongLong doesn't check the type of
- * obj, only accept argument of PyLong_Type, so we check it instead.
- */
- if (PyInt_Check(obj)) {
- llong_val = PyInt_AsLong(obj);
- if (llong_val < 0)
- PyErr_SetString(PyExc_OverflowError,
- "negative Python int cannot be converted to C unsigned long long");
- else
- ullong_val = llong_val;
- } else if (PyLong_Check(obj)) {
- ullong_val = PyLong_AsUnsignedLongLong(obj);
- } else {
- PyErr_SetString(PyExc_TypeError, "an integer is required");
- }
-
- if ((ullong_val == -1) && PyErr_Occurred())
- return -1;
-
- *val = ullong_val;
- return 0;
-}
-
-int
-libvirt_doubleUnwrap(PyObject *obj, double *val)
-{
- double double_val;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- double_val = PyFloat_AsDouble(obj);
- if ((double_val == -1) && PyErr_Occurred())
- return -1;
-
- *val = double_val;
- return 0;
-}
-
-int
-libvirt_boolUnwrap(PyObject *obj, bool *val)
-{
- int ret;
-
- if (!obj) {
- PyErr_SetString(PyExc_TypeError, "unexpected type");
- return -1;
- }
-
- if ((ret = PyObject_IsTrue(obj)) < 0)
- return ret;
-
- *val = ret > 0;
- return 0;
-}
-
-PyObject *
-libvirt_virDomainPtrWrap(virDomainPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virDomainPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virNetworkPtrWrap(virNetworkPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virNetworkPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virInterfacePtrWrap(virInterfacePtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virInterfacePtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virStoragePoolPtrWrap(virStoragePoolPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virStoragePoolPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virStorageVolPtrWrap(virStorageVolPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virStorageVolPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virConnectPtrWrap(virConnectPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virConnectPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virNodeDevicePtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virSecretPtrWrap(virSecretPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virSecretPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virNWFilterPtrWrap(virNWFilterPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virNWFilterPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virStreamPtrWrap(virStreamPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virStreamPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virDomainSnapshotPtrWrap(virDomainSnapshotPtr node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virDomainSnapshotPtr", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virEventHandleCallbackWrap(virEventHandleCallback node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- printf("%s: WARNING - Wrapping None\n", __func__);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virEventHandleCallback", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- printf("%s: WARNING - Wrapping None\n", __func__);
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virEventTimeoutCallback", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virFreeCallbackWrap(virFreeCallback node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "virFreeCallback", NULL);
- return ret;
-}
-
-PyObject *
-libvirt_virVoidPtrWrap(void* node)
-{
- PyObject *ret;
-
- if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- ret = libvirt_buildPyObject(node, "void*", NULL);
- return ret;
-}
diff --git a/python/typewrappers.h b/python/typewrappers.h
deleted file mode 100644
index d871d3f..0000000
--- a/python/typewrappers.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * libvirt_wrap.h: type wrappers for libvir python bindings
- *
- * Copyright (C) 2005, 2011-2012 Red Hat, Inc.
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-#include <Python.h>
-#include <stdbool.h>
-#include <libvirt/libvirt.h>
-#include <libvirt/virterror.h>
-
-#ifdef __GNUC__
-# ifdef ATTRIBUTE_UNUSED
-# undef ATTRIBUTE_UNUSED
-# endif
-# ifndef ATTRIBUTE_UNUSED
-# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
-# endif /* ATTRIBUTE_UNUSED */
-#else
-# define ATTRIBUTE_UNUSED
-#endif
-
-/* Work around really old python. */
-#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 5
-typedef ssize_t Py_ssize_t;
-#endif
-
-#define PyvirConnect_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirConnect_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virConnectPtr obj;
-} PyvirConnect_Object;
-
-
-#define PyvirDomain_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirDomain_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virDomainPtr obj;
-} PyvirDomain_Object;
-
-
-#define PyvirNetwork_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirNetwork_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virNetworkPtr obj;
-} PyvirNetwork_Object;
-
-
-#define PyvirInterface_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirInterface_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virInterfacePtr obj;
-} PyvirInterface_Object;
-
-
-#define PyvirStoragePool_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirStoragePool_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virStoragePoolPtr obj;
-} PyvirStoragePool_Object;
-
-
-#define PyvirStorageVol_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirStorageVol_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virStorageVolPtr obj;
-} PyvirStorageVol_Object;
-
-
-#define PyvirNodeDevice_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirNodeDevice_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virNodeDevicePtr obj;
-} PyvirNodeDevice_Object;
-
-#define PyvirSecret_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirSecret_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virSecretPtr obj;
-} PyvirSecret_Object;
-
-#define PyvirNWFilter_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirNWFilter_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virNWFilterPtr obj;
-} PyvirNWFilter_Object;
-
-
-#define PyvirStream_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirStream_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virStreamPtr obj;
-} PyvirStream_Object;
-
-
-#define PyvirDomainSnapshot_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirDomainSnapshot_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virDomainSnapshotPtr obj;
-} PyvirDomainSnapshot_Object;
-
-
-#define PyvirEventHandleCallback_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirEventHandleCallback_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virEventHandleCallback obj;
-} PyvirEventHandleCallback_Object;
-
-#define PyvirEventTimeoutCallback_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirEventTimeoutCallback_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virEventTimeoutCallback obj;
-} PyvirEventTimeoutCallback_Object;
-
-#define PyvirFreeCallback_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirFreeCallback_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- virFreeCallback obj;
-} PyvirFreeCallback_Object;
-
-#define PyvirVoidPtr_Get(v) (((v) == Py_None) ? NULL : \
- (((PyvirVoidPtr_Object *)(v))->obj))
-
-typedef struct {
- PyObject_HEAD
- void* obj;
-} PyvirVoidPtr_Object;
-
-PyObject * libvirt_intWrap(int val);
-PyObject * libvirt_longWrap(long val);
-PyObject * libvirt_ulongWrap(unsigned long val);
-PyObject * libvirt_longlongWrap(long long val);
-PyObject * libvirt_ulonglongWrap(unsigned long long val);
-PyObject * libvirt_charPtrWrap(char *str);
-PyObject * libvirt_charPtrSizeWrap(char *str, Py_ssize_t size);
-PyObject * libvirt_constcharPtrWrap(const char *str);
-int libvirt_intUnwrap(PyObject *obj, int *val);
-int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
-int libvirt_longUnwrap(PyObject *obj, long *val);
-int libvirt_ulongUnwrap(PyObject *obj, unsigned long *val);
-int libvirt_longlongUnwrap(PyObject *obj, long long *val);
-int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val);
-int libvirt_doubleUnwrap(PyObject *obj, double *val);
-int libvirt_boolUnwrap(PyObject *obj, bool *val);
-PyObject * libvirt_virConnectPtrWrap(virConnectPtr node);
-PyObject * libvirt_virDomainPtrWrap(virDomainPtr node);
-PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node);
-PyObject * libvirt_virInterfacePtrWrap(virInterfacePtr node);
-PyObject * libvirt_virStoragePoolPtrWrap(virStoragePoolPtr node);
-PyObject * libvirt_virStorageVolPtrWrap(virStorageVolPtr node);
-PyObject * libvirt_virEventHandleCallbackWrap(virEventHandleCallback node);
-PyObject * libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node);
-PyObject * libvirt_virFreeCallbackWrap(virFreeCallback node);
-PyObject * libvirt_virVoidPtrWrap(void* node);
-PyObject * libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node);
-PyObject * libvirt_virSecretPtrWrap(virSecretPtr node);
-PyObject * libvirt_virNWFilterPtrWrap(virNWFilterPtr node);
-PyObject * libvirt_virStreamPtrWrap(virStreamPtr node);
-PyObject * libvirt_virDomainSnapshotPtrWrap(virDomainSnapshotPtr node);
-
-
-/* Provide simple macro statement wrappers (adapted from GLib, in turn from Perl):
- * LIBVIRT_STMT_START { statements; } LIBVIRT_STMT_END;
- * can be used as a single statement, as in
- * if (x) LIBVIRT_STMT_START { ... } LIBVIRT_STMT_END; else ...
- *
- * When GCC is compiling C code in non-ANSI mode, it will use the
- * compiler __extension__ to wrap the statements within `({' and '})' braces.
- * When compiling on platforms where configure has defined
- * HAVE_DOWHILE_MACROS, statements will be wrapped with `do' and `while (0)'.
- * For any other platforms (SunOS4 is known to have this issue), wrap the
- * statements with `if (1)' and `else (void) 0'.
- */
-#if !(defined (LIBVIRT_STMT_START) && defined (LIBVIRT_STMT_END))
-# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
-# define LIBVIRT_STMT_START (void) __extension__ (
-# define LIBVIRT_STMT_END )
-# else /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
-# if defined (HAVE_DOWHILE_MACROS)
-# define LIBVIRT_STMT_START do
-# define LIBVIRT_STMT_END while (0)
-# else /* !HAVE_DOWHILE_MACROS */
-# define LIBVIRT_STMT_START if (1)
-# define LIBVIRT_STMT_END else (void) 0
-# endif /* !HAVE_DOWHILE_MACROS */
-# endif /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
-#endif
-
-#define LIBVIRT_BEGIN_ALLOW_THREADS \
- LIBVIRT_STMT_START { \
- PyThreadState *_save = NULL; \
- if (PyEval_ThreadsInitialized()) \
- _save = PyEval_SaveThread();
-
-#define LIBVIRT_END_ALLOW_THREADS \
- if (PyEval_ThreadsInitialized()) \
- PyEval_RestoreThread(_save); \
- } LIBVIRT_STMT_END
-
-#define LIBVIRT_ENSURE_THREAD_STATE \
- LIBVIRT_STMT_START { \
- PyGILState_STATE _save = PyGILState_UNLOCKED; \
- if (PyEval_ThreadsInitialized()) \
- _save = PyGILState_Ensure();
-
-#define LIBVIRT_RELEASE_THREAD_STATE \
- if (PyEval_ThreadsInitialized()) \
- PyGILState_Release(_save); \
- } LIBVIRT_STMT_END
diff --git a/run.in b/run.in
index 5d4a04c..2211f24 100644
--- a/run.in
+++ b/run.in
@@ -58,15 +58,6 @@ export LIBVIRT_LOCK_MANAGER_PLUGIN_DIR="$b/src/.libs"
export VIRTLOCKD_PATH="$b/src/virtlockd"
export LIBVIRTD_PATH="$b/daemon/libvirtd"
-# For Python.
-export PYTHON=@PYTHON@
-if [ -z "$PYTHONPATH" ]; then
- PYTHONPATH="$b/python:$b/python/.libs"
-else
- PYTHONPATH="$b/python:$b/python/.libs:$PYTHONPATH"
-fi
-export PYTHONPATH
-
# This is a cheap way to find some use-after-free and uninitialized
# read problems when using glibc.
random_val="$(awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)"
--
1.8.3.1
2
5
We have now pushed the python binding code to its new GIT repository
location. If you intend to work on python bindings, please get yourself
a checkout of the following
http://libvirt.org/git/?p=libvirt-python.git;a=summary
git://libvirt.org/libvirt-python.git
The python binding will generally be released at the same time as major
libvirt releases, if new manually written bindings were required. If
all new APIs were correctly handled by the code generator, we will not
need to do a release.
The minor maint branches will also be separate for libvirt.git vs
libvirt-python.git. It is unlikely we'll need to do maint branches
for the python code most of the time. If we do though, there is no
need to synchronize with libvirt maint releases.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
1
0