mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-12-16 12:24:29 +03:00
snapshot: new virDomainSnapshotListChildrenNames API
The previous API addition allowed traversal up the hierarchy; this one makes it easier to traverse down the hierarchy. In the python bindings, virDomainSnapshotNumChildren can be generated, but virDomainSnapshotListChildrenNames had to copy from the hand-written example of virDomainSnapshotListNames. * include/libvirt/libvirt.h.in (virDomainSnapshotNumChildren) (virDomainSnapshotListChildrenNames): New prototypes. (VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS): New flag alias. * src/libvirt.c (virDomainSnapshotNumChildren) (virDomainSnapshotListChildrenNames): New functions. * src/libvirt_public.syms: Export them. * src/driver.h (virDrvDomainSnapshotNumChildren) (virDrvDomainSnapshotListChildrenNames): New callbacks. * python/generator.py (skip_impl, nameFixup): Update lists. * python/libvirt-override-api.xml: Likewise. * python/libvirt-override.c (libvirt_virDomainSnapshotListChildrenNames): New wrapper function.
This commit is contained in:
@@ -1726,6 +1726,51 @@ libvirt_virDomainSnapshotListNames(PyObject *self ATTRIBUTE_UNUSED,
|
||||
return(py_retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
libvirt_virDomainSnapshotListChildrenNames(PyObject *self ATTRIBUTE_UNUSED,
|
||||
PyObject *args) {
|
||||
PyObject *py_retval;
|
||||
char **names = NULL;
|
||||
int c_retval, 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) {
|
||||
names = malloc(sizeof(*names) * c_retval);
|
||||
if (!names)
|
||||
return VIR_PY_NONE;
|
||||
LIBVIRT_BEGIN_ALLOW_THREADS;
|
||||
c_retval = virDomainSnapshotListChildrenNames(snap, names, c_retval, flags);
|
||||
LIBVIRT_END_ALLOW_THREADS;
|
||||
if (c_retval < 0) {
|
||||
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]));
|
||||
free(names[i]);
|
||||
}
|
||||
free(names);
|
||||
}
|
||||
|
||||
return(py_retval);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
libvirt_virDomainRevertToSnapshot(PyObject *self ATTRIBUTE_UNUSED,
|
||||
PyObject *args) {
|
||||
|
||||
Reference in New Issue
Block a user