1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

snapshot: new APIs for inspecting snapshot object

These functions access internals of the opaque object, and do
not need any rpc counterpart.  It could be argued that we should
have provided these when snapshot objects were first introduced,
since all the other vir*Ptr objects have at least a GetName accessor.

* include/libvirt/libvirt.h.in (virDomainSnapshotGetName)
(virDomainSnapshotGetDomain, virDomainSnapshotGetConnect): Declare.
* src/libvirt.c (virDomainSnapshotGetName)
(virDomainSnapshotGetDomain, virDomainSnapshotGetConnect): New
functions.
* src/libvirt_public.syms: Export them.
This commit is contained in:
Eric Blake 2011-09-08 12:19:25 +01:00
parent 9c7283166f
commit 6c14439e51
3 changed files with 81 additions and 1 deletions

View File

@ -2656,6 +2656,10 @@ typedef struct _virDomainSnapshot virDomainSnapshot;
*/
typedef virDomainSnapshot *virDomainSnapshotPtr;
const char *virDomainSnapshotGetName(virDomainSnapshotPtr snapshot);
virDomainPtr virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot);
virConnectPtr virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot);
typedef enum {
VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE = (1 << 0), /* Restore or alter
metadata */

View File

@ -15664,6 +15664,79 @@ error:
return -1;
}
/**
* virDomainSnapshotGetName:
* @snapshot: a snapshot object
*
* Get the public name for that snapshot
*
* Returns a pointer to the name or NULL, the string need not be deallocated
* as its lifetime will be the same as the snapshot object.
*/
const char *
virDomainSnapshotGetName(virDomainSnapshotPtr snapshot)
{
VIR_DEBUG("snapshot=%p", snapshot);
virResetLastError();
if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT,
__FUNCTION__);
virDispatchError(NULL);
return NULL;
}
return snapshot->name;
}
/**
* virDomainSnapshotGetDomain:
* @snapshot: a snapshot object
*
* Get the domain that a snapshot was created for
*
* Returns the domain or NULL.
*/
virDomainPtr
virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot)
{
VIR_DEBUG("snapshot=%p", snapshot);
virResetLastError();
if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT,
__FUNCTION__);
virDispatchError(NULL);
return NULL;
}
return snapshot->domain;
}
/**
* virDomainSnapshotGetConnect:
* @snapshot: a snapshot object
*
* Get the connection that owns the domain that a snapshot was created for
*
* Returns the connection or NULL.
*/
virConnectPtr
virDomainSnapshotGetConnect(virDomainSnapshotPtr snapshot)
{
VIR_DEBUG("snapshot=%p", snapshot);
virResetLastError();
if (!VIR_IS_DOMAIN_SNAPSHOT(snapshot)) {
virLibDomainSnapshotError(VIR_ERR_INVALID_DOMAIN_SNAPSHOT,
__FUNCTION__);
virDispatchError(NULL);
return NULL;
}
return snapshot->domain->conn;
}
/**
* virDomainSnapshotCreateXML:
* @domain: a domain object

View File

@ -482,8 +482,11 @@ LIBVIRT_0.9.4 {
LIBVIRT_0.9.5 {
global:
virDomainMigrateGetMaxSpeed;
virDomainBlockStatsFlags;
virDomainMigrateGetMaxSpeed;
virDomainSnapshotGetConnect;
virDomainSnapshotGetDomain;
virDomainSnapshotGetName;
} LIBVIRT_0.9.4;
# .... define new API here using predicted next version number ....