Set up the types for the domainMemoryStats function and insert it into the
virDriver structure definition. Because of static initializers, update every
driver and set the new field to NULL.
Note: The changes in python/* are to fix compiler errors. The actual python
binding is implemented in a later patch.
Signed-off-by: Adam Litke <agl(a)us.ibm.com>
To: Daniel Veillard <veillard(a)redhat.com>
Cc: Daniel P. Berrange <berrange(a)redhat.com>
Cc: libvirt list <libvir-list(a)redhat.com>
---
include/libvirt/libvirt.h.in | 53 ++++++++++++++++++++++++++++++++++++++++++
python/generator.py | 4 ++-
src/driver.h | 7 +++++
src/esx/esx_driver.c | 1 +
src/lxc/lxc_driver.c | 1 +
src/opennebula/one_driver.c | 1 +
src/openvz/openvz_driver.c | 1 +
src/phyp/phyp_driver.c | 1 +
src/qemu/qemu_driver.c | 1 +
src/remote/remote_driver.c | 1 +
src/test/test_driver.c | 1 +
src/uml/uml_driver.c | 1 +
src/vbox/vbox_tmpl.c | 1 +
src/xen/xen_driver.c | 1 +
14 files changed, 74 insertions(+), 1 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 6c3aded..820bf98 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -333,6 +333,55 @@ struct _virDomainInterfaceStats {
*/
typedef virDomainInterfaceStatsStruct *virDomainInterfaceStatsPtr;
+/**
+ * Memory Statistics Tags:
+ */
+typedef enum {
+ /* The total amount of data read from swap space (in kB). */
+ VIR_DOMAIN_MEMORY_STAT_SWAP_IN = 0,
+ /* The total amount of memory written out to swap space (in kB). */
+ VIR_DOMAIN_MEMORY_STAT_SWAP_OUT = 1,
+
+ /*
+ * Page faults occur when a process makes a valid access to virtual memory
+ * that is not available. When servicing the page fault, if disk IO is
+ * required, it is considered a major fault. If not, it is a minor fault.
+ * These are expressed as the number of faults that have occurred.
+ */
+ VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULT = 2,
+ VIR_DOMAIN_MEMORY_STAT_MINOR_FAULT = 3,
+
+ /*
+ * The amount of memory left completely unused by the system. Memory that
+ * is available but used for reclaimable caches should NOT be reported as
+ * free. This value is expressed in kB.
+ */
+ VIR_DOMAIN_MEMORY_STAT_UNUSED = 4,
+
+ /*
+ * The total amount of usable memory as seen by the domain. This value
+ * may be less than the amount of memory assigned to the domain if a
+ * balloon driver is in use or if the guest OS does not initialize all
+ * assigned pages. This value is expressed in kB.
+ */
+ VIR_DOMAIN_MEMORY_STAT_AVAILABLE = 5,
+
+ /*
+ * The number of statistics supported by this version of the interface.
+ * To add new statistics, add them to the enum and increase this value.
+ */
+ VIR_DOMAIN_MEMORY_STAT_NR = 6,
+} virDomainMemoryStatTags;
+
+typedef struct _virDomainMemoryStat virDomainMemoryStatStruct;
+
+struct _virDomainMemoryStat {
+ int tag;
+ unsigned long long val;
+};
+
+typedef virDomainMemoryStatStruct *virDomainMemoryStatPtr;
+
/* Domain core dump flags. */
typedef enum {
@@ -644,6 +693,10 @@ int virDomainInterfaceStats (virDomainPtr dom,
const char *path,
virDomainInterfaceStatsPtr stats,
size_t size);
+int virDomainMemoryStats (virDomainPtr dom,
+ virDomainMemoryStatPtr stats,
+ unsigned int nr_stats,
+ unsigned int flags);
int virDomainBlockPeek (virDomainPtr dom,
const char *path,
unsigned long long offset,
diff --git a/python/generator.py b/python/generator.py
index 3fd7f90..06f1ff4 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -160,7 +160,8 @@ def enum(type, name, value):
functions_failed = []
functions_skipped = [
- "virConnectListDomains"
+ "virConnectListDomains",
+ "virDomainMemoryStats"
]
skipped_modules = {
@@ -170,6 +171,7 @@ skipped_types = {
# 'int *': "usually a return type",
'virConnectDomainEventCallback': "No function types in python",
'virEventAddHandleFunc': "No function types in python",
+ 'virDomainMemoryStatPtr': "Not implemented yet",
}
#######################################################################
diff --git a/src/driver.h b/src/driver.h
index 09ce8e2..6193e47 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -229,6 +229,12 @@ typedef int
struct _virDomainInterfaceStats *stats);
typedef int
+ (*virDrvDomainMemoryStats)
+ (virDomainPtr domain,
+ struct _virDomainMemoryStat *stats,
+ unsigned int nr_stats);
+
+typedef int
(*virDrvDomainBlockPeek)
(virDomainPtr domain,
const char *path,
@@ -419,6 +425,7 @@ struct _virDriver {
virDrvDomainMigrateFinish domainMigrateFinish;
virDrvDomainBlockStats domainBlockStats;
virDrvDomainInterfaceStats domainInterfaceStats;
+ virDrvDomainMemoryStats domainMemoryStats;
virDrvDomainBlockPeek domainBlockPeek;
virDrvDomainMemoryPeek domainMemoryPeek;
virDrvNodeGetCellsFreeMemory nodeGetCellsFreeMemory;
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index ea464a3..2626162 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3412,6 +3412,7 @@ static virDriver esxDriver = {
esxDomainMigrateFinish, /* domainMigrateFinish */
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
NULL, /* nodeGetCellsFreeMemory */
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c8e2dca..ff998c7 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2438,6 +2438,7 @@ static virDriver lxcDriver = {
NULL, /* domainMigrateFinish */
NULL, /* domainBlockStats */
lxcDomainInterfaceStats, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index a30c110..a4ad31e 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -765,6 +765,7 @@ static virDriver oneDriver = {
NULL, /* domainMigrateFinish */
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
NULL, /* nodeGetCellsFreeMemory */
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 1c0fccc..7acce5b 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1517,6 +1517,7 @@ static virDriver openvzDriver = {
NULL, /* domainMigrateFinish */
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
NULL, /* nodeGetCellsFreeMemory */
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index c4fcfed..07adccb 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1633,6 +1633,7 @@ virDriver phypDriver = {
NULL, /* domainMigrateFinish */
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
NULL, /* nodeGetCellsFreeMemory */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9ef6c35..1ddc23e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7907,6 +7907,7 @@ static virDriver qemuDriver = {
NULL, /* domainMigrateFinish */
qemudDomainBlockStats, /* domainBlockStats */
qemudDomainInterfaceStats, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
qemudDomainBlockPeek, /* domainBlockPeek */
qemudDomainMemoryPeek, /* domainMemoryPeek */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 77962fe..5d32d3b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8814,6 +8814,7 @@ static virDriver remote_driver = {
remoteDomainMigrateFinish, /* domainMigrateFinish */
remoteDomainBlockStats, /* domainBlockStats */
remoteDomainInterfaceStats, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
remoteDomainBlockPeek, /* domainBlockPeek */
remoteDomainMemoryPeek, /* domainMemoryPeek */
remoteNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7db9a4c..21ea491 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5220,6 +5220,7 @@ static virDriver testDriver = {
NULL, /* domainMigrateFinish */
testDomainBlockStats, /* domainBlockStats */
testDomainInterfaceStats, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
testNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 48ef103..035ed0c 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1906,6 +1906,7 @@ static virDriver umlDriver = {
NULL, /* domainMigrateFinish */
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
umlDomainBlockPeek, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index d6b681c..e2e1ce6 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -7028,6 +7028,7 @@ virDriver NAME(Driver) = {
NULL, /* domainMigrateFinish */
NULL, /* domainBlockStats */
NULL, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index ed94bed..e952610 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1844,6 +1844,7 @@ static virDriver xenUnifiedDriver = {
xenUnifiedDomainMigrateFinish, /* domainMigrateFinish */
xenUnifiedDomainBlockStats, /* domainBlockStats */
xenUnifiedDomainInterfaceStats, /* domainInterfaceStats */
+ NULL, /* domainMemoryStats */
xenUnifiedDomainBlockPeek, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
xenUnifiedNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
--
1.6.5