Add a new function 'virDomainMemStats' to the libvirt API. Export it via libvirt_public.syms Signed-off-by: Adam Litke <agl@xxxxxxxxxx> To: libvirt list <libvir-list@xxxxxxxxxx> --- src/libvirt.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index b14942d..d632bd7 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -4045,6 +4045,56 @@ error: } /** + * virDomainMemStats: + * @dom: pointer to the domain object + * @stats: memory stats structure (returned) + * @size: size of memory stats structure + * + * This function returns memory statistics for the domain. + * + * Individual fields within the stats structure may be returned + * as -1, which indicates that the hypervisor or guest does not + * support that particular statistic. + * + * Returns: 0 in case of success or -1 in case of failure. + */ +int +virDomainMemStats (virDomainPtr dom, virDomainMemStatsPtr stats, + size_t size) +{ + virConnectPtr conn; + struct _virDomainMemStats stats2 = { -1, -1, -1, -1, -1, -1 }; + DEBUG("domain=%p, stats=%p, size=%zi", dom, stats, size); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN (dom)) { + virLibDomainError (NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + return -1; + } + if (!stats || size > sizeof stats2) { + virLibDomainError (dom, VIR_ERR_INVALID_ARG, __FUNCTION__); + goto error; + } + conn = dom->conn; + + if (conn->driver->domainMemStats) { + if (conn->driver->domainMemStats (dom, &stats2) == -1) + goto error; + + memcpy (stats, &stats2, size); + return 0; + } + + virLibDomainError (dom, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + /* Copy to connection error object for back compatability */ + virSetConnError(dom->conn); + return -1; +} + +/** * virDomainBlockPeek: * @dom: pointer to the domain object * @path: path to the block device diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 8921c1a..009c0ba 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -327,6 +327,7 @@ LIBVIRT_0.7.2 { virStreamAbort; virStreamFree; virDomainMigrateToURI; + virDomainMemStats; } LIBVIRT_0.7.1; # .... define new API here using predicted next version number .... -- 1.6.5 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list