summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Litke <agl@us.ibm.com>2011-07-22 13:43:53 +0800
committerDaniel Veillard <veillard@redhat.com>2011-07-22 13:43:53 +0800
commit3d3872d29da204cdf8e9503f090029e8b5aa88ba (patch)
tree31e3d2d72e2a25bb027a796857ce2bd2ff855d8c
parent384d3ae35bb6c4ee90730bd273922447700bea82 (diff)
Enable virDomainBlockPull in the python API
virDomainGetBlockJobInfo requires manual override since it returns a custom type. * python/generator.py: reenable bindings for this entry point * python/libvirt-override-api.xml python/libvirt-override.c: manual overrides
-rwxr-xr-xgenerator.py2
-rw-r--r--libvirt-override-api.xml7
-rw-r--r--libvirt-override.c39
3 files changed, 47 insertions, 1 deletions
diff --git a/generator.py b/generator.py
index b25c74e..d0d3ae6 100755
--- a/generator.py
+++ b/generator.py
@@ -186,7 +186,6 @@ def enum(type, name, value):
functions_failed = []
functions_skipped = [
"virConnectListDomains",
- 'virDomainGetBlockJobInfo',
]
skipped_modules = {
@@ -370,6 +369,7 @@ skip_impl = (
'virDomainSendKey',
'virNodeGetCPUStats',
'virNodeGetMemoryStats',
+ 'virDomainGetBlockJobInfo',
)
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 01207d6..268f897 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -320,5 +320,12 @@
<arg name='flags' type='unsigned int' info='flags, curently unused'/>
<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='virDomainBlockJobInfo' info='A dictionary containing job information.' />
+ </function>
</symbols>
</api>
diff --git a/libvirt-override.c b/libvirt-override.c
index b713b6a..e89bc97 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -2413,6 +2413,44 @@ libvirt_virDomainGetJobInfo(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
return(py_retval);
}
+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 *ret;
+
+ if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainGetBlockJobInfo",
+ &pyobj_domain, &path, &flags))
+ return(NULL);
+ domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
+
+LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_ret = virDomainGetBlockJobInfo(domain, path, &info, flags);
+LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_ret != 1)
+ return VIR_PY_NONE;
+
+ if ((ret = PyDict_New()) == NULL)
+ return VIR_PY_NONE;
+
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("type"),
+ libvirt_intWrap(info.type));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("bandwidth"),
+ libvirt_ulongWrap(info.bandwidth));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("cur"),
+ libvirt_ulonglongWrap(info.cur));
+ PyDict_SetItem(ret, libvirt_constcharPtrWrap("end"),
+ libvirt_ulonglongWrap(info.end));
+
+ return ret;
+}
/*******************************************
* Helper functions to avoid importing modules
@@ -3872,6 +3910,7 @@ static PyMethodDef libvirtMethods[] = {
{(char *) "virDomainGetJobInfo", libvirt_virDomainGetJobInfo, METH_VARARGS, NULL},
{(char *) "virDomainSnapshotListNames", libvirt_virDomainSnapshotListNames, METH_VARARGS, NULL},
{(char *) "virDomainRevertToSnapshot", libvirt_virDomainRevertToSnapshot, METH_VARARGS, NULL},
+ {(char *) "virDomainGetBlockJobInfo", libvirt_virDomainGetBlockJobInfo, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
n>access (cfPath, os.R_OK): self.perms = os.stat(cfPath)[0] & 0777 os.rename(cfPath, cfPath + '.rpmsave') # Now we're going to create and populate cfPath. f = open (cfPath, 'w+') f.write ("# aboot default configurations\n") if bootnotroot: f.write ("# NOTICE: You have a /boot partition. This means that\n") f.write ("# all kernel paths are relative to /boot/\n") # bpn is the boot partition number. bpn = self.partitionNum(bootDevice.path) lines = 0 # We write entries line using the following format: # <line><bpn><kernel-name> root=<rootdev> [options] # We get all the kernels we need to know about in kernelList. for (kernel, tag, version) in kernelList: kernelTag = "-" + version kernelFile = "%svmlinuz%s" %(kernelPath, kernelTag) f.write("%d:%d%s" %(lines, bpn, kernelFile)) # See if we can come up with an initrd argument that exists initrd = self.makeInitrd(kernelTag) if os.path.isfile(instRoot + initrd): f.write(" initrd=%sinitrd%s.img" %(kernelPath, kernelTag)) realroot = rootDevice.fstabSpec f.write(" root=%s" %(realroot,)) args = self.args.get() if args: f.write(" %s" %(args,)) f.write("\n") lines = lines + 1 # We're done writing the file f.close () del f if not justConfig: # Now we're ready to write the relevant boot information. wbd # is the whole boot device, bdpn is the boot device partition # number. wbd = self.wholeDevice (bootDevice.path) bdpn = self.partitionNum (bootDevice.path) # Calling swriteboot. The first argument is the disk to write # to and the second argument is a path to the bootstrap loader # file. args = [("/dev/%s" % wbd), "/boot/bootlx"] rc = iutil.execWithRedirect ('/sbin/swriteboot', args, root = instRoot, stdout = "/dev/tty5", stderr = "/dev/tty5") if rc: return rc # Calling abootconf to configure the installed aboot. The # first argument is the disk to use, the second argument is # the number of the partition on which aboot.conf resides. # It's always the boot partition whether it's / or /boot (with # the mount point being omitted.) args = [("/dev/%s" % wbd), str (bdpn)] rc = iutil.execWithRedirect ('/sbin/abootconf', args, root = instRoot, stdout = "/dev/tty5", stderr = "/dev/tty5") if rc: return rc return 0 def write(self, instRoot, bl, kernelList, chainList, defaultDev, justConfig): if len(kernelList) < 1: raise BootyNoKernelWarning return self.writeAboot(instRoot, bl, kernelList, chainList, defaultDev, justConfig) def __init__(self, instData): bootloaderInfo.__init__(self, instData) self.useGrubVal = 0 self.configfile = "/etc/aboot.conf" # self.kernelLocation is already set to what we need. self.password = None self.pure = None