]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add new API virDomainMemoryStats to header and drivers
authorAdam Litke <agl@us.ibm.com>
Sun, 20 Dec 2009 12:28:42 +0000 (13:28 +0100)
committerDaniel Veillard <veillard@redhat.com>
Sun, 20 Dec 2009 12:28:42 +0000 (13:28 +0100)
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.

* include/libvirt/libvirt.h.in: new API
* src/driver.h src/*/*_driver.c src/vbox/vbox_tmpl.c: add the new
  entry to the driver structure
* python/generator.py: fix compiler errors, the actual python binding is
  implemented later

14 files changed:
include/libvirt/libvirt.h.in
python/generator.py
src/driver.h
src/esx/esx_driver.c
src/lxc/lxc_driver.c
src/opennebula/one_driver.c
src/openvz/openvz_driver.c
src/phyp/phyp_driver.c
src/qemu/qemu_driver.c
src/remote/remote_driver.c
src/test/test_driver.c
src/uml/uml_driver.c
src/vbox/vbox_tmpl.c
src/xen/xen_driver.c

index 2046f3886884f2dd5cc3776c232512930f4bd270..f192fb1680a9610b1c2f186ffdbaa2cd2b2ff281 100644 (file)
@@ -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,
index 3fd7f90f8e7cd5cd646199ec852de633ee980ef7..06f1ff4a12bcd0463488374357049962955046b6 100755 (executable)
@@ -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",
 }
 
 #######################################################################
index 5a9ae4b24e8f1512bb2b54c32fc6491211338ba5..c7e4fbf24cc2fb876effc7f40732bc8951ef78f8 100644 (file)
@@ -228,6 +228,12 @@ typedef int
                      const char *path,
                      struct _virDomainInterfaceStats *stats);
 
+typedef int
+    (*virDrvDomainMemoryStats)
+                    (virDomainPtr domain,
+                     struct _virDomainMemoryStat *stats,
+                     unsigned int nr_stats);
+
 typedef int
     (*virDrvDomainBlockPeek)
                     (virDomainPtr domain,
@@ -424,6 +430,7 @@ struct _virDriver {
     virDrvDomainMigrateFinish  domainMigrateFinish;
     virDrvDomainBlockStats      domainBlockStats;
     virDrvDomainInterfaceStats  domainInterfaceStats;
+    virDrvDomainMemoryStats     domainMemoryStats;
     virDrvDomainBlockPeek      domainBlockPeek;
     virDrvDomainMemoryPeek      domainMemoryPeek;
     virDrvNodeGetCellsFreeMemory       nodeGetCellsFreeMemory;
index c0754f58fb56f08638c3771336970add45c0e7e2..5cdadfd6ecef317e9c4409591c9ab116406036c6 100644 (file)
@@ -3437,6 +3437,7 @@ static virDriver esxDriver = {
     esxDomainMigrateFinish,          /* domainMigrateFinish */
     NULL,                            /* domainBlockStats */
     NULL,                            /* domainInterfaceStats */
+    NULL,                            /* domainMemoryStats */
     NULL,                            /* domainBlockPeek */
     NULL,                            /* domainMemoryPeek */
     NULL,                            /* nodeGetCellsFreeMemory */
index 1ce7ad6b6e0883a20bbd386d94f51f1dae48fa68..86606c742779565da2a74673d0eb82e934ddaa4f 100644 (file)
@@ -2438,6 +2438,7 @@ static virDriver lxcDriver = {
     NULL, /* domainMigrateFinish */
     NULL, /* domainBlockStats */
     lxcDomainInterfaceStats, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     NULL, /* domainBlockPeek */
     NULL, /* domainMemoryPeek */
     nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
index 3de97b0d3f89d15736b0c1f25b2ff9c045e5316e..ad7faca223b56d870d478dab23614045f03f0bc4 100644 (file)
@@ -765,6 +765,7 @@ static virDriver oneDriver = {
     NULL, /* domainMigrateFinish */
     NULL, /* domainBlockStats */
     NULL, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     NULL, /* domainBlockPeek */
     NULL, /* domainMemoryPeek */
     NULL, /* nodeGetCellsFreeMemory */
index b62070f1a9ac0e8742e0b13b2404cc3106b7e3a4..196fd8c1ed88f9e897cc58e40831d0fdc010d81f 100644 (file)
@@ -1517,6 +1517,7 @@ static virDriver openvzDriver = {
     NULL, /* domainMigrateFinish */
     NULL, /* domainBlockStats */
     NULL, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     NULL, /* domainBlockPeek */
     NULL, /* domainMemoryPeek */
     NULL, /* nodeGetCellsFreeMemory */
index 1863425bbafb5093ad0e89dcad1bf75ae5d9976b..bd5cfc7b3796a0a57ff24061b30190269143078d 100644 (file)
@@ -1633,6 +1633,7 @@ virDriver phypDriver = {
     NULL,                       /* domainMigrateFinish */
     NULL,                       /* domainBlockStats */
     NULL,                       /* domainInterfaceStats */
+    NULL,                       /* domainMemoryStats */
     NULL,                       /* domainBlockPeek */
     NULL,                       /* domainMemoryPeek */
     NULL,                       /* nodeGetCellsFreeMemory */
index 242045670baa54f3b7eb30d22d4f7237aafb0ce2..6355385f9bf7494c82b4c4699a1f40b8ef640038 100644 (file)
@@ -7930,6 +7930,7 @@ static virDriver qemuDriver = {
     NULL, /* domainMigrateFinish */
     qemudDomainBlockStats, /* domainBlockStats */
     qemudDomainInterfaceStats, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     qemudDomainBlockPeek, /* domainBlockPeek */
     qemudDomainMemoryPeek, /* domainMemoryPeek */
     nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
index b5b786162ca79268cecb7db1e2e7cfb6fd3f46b2..7ed74a5bc51f5ea880c086765fa8a8dec6c9a34c 100644 (file)
@@ -8841,6 +8841,7 @@ static virDriver remote_driver = {
     remoteDomainMigrateFinish, /* domainMigrateFinish */
     remoteDomainBlockStats, /* domainBlockStats */
     remoteDomainInterfaceStats, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     remoteDomainBlockPeek, /* domainBlockPeek */
     remoteDomainMemoryPeek, /* domainMemoryPeek */
     remoteNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
index 5c61f246212cfa2c300c5d467b8a61a11a1c69ca..2122a1b68623b35977d8c18b2a9dc07471eeeab5 100644 (file)
@@ -5220,6 +5220,7 @@ static virDriver testDriver = {
     NULL, /* domainMigrateFinish */
     testDomainBlockStats, /* domainBlockStats */
     testDomainInterfaceStats, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     NULL, /* domainBlockPeek */
     NULL, /* domainMemoryPeek */
     testNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
index e6ba773c2e6040f77f798d12432cf4587fc21834..b8080909b5a1811096cbd473cd5b9eb4ed875c25 100644 (file)
@@ -1906,6 +1906,7 @@ static virDriver umlDriver = {
     NULL, /* domainMigrateFinish */
     NULL, /* domainBlockStats */
     NULL, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     umlDomainBlockPeek, /* domainBlockPeek */
     NULL, /* domainMemoryPeek */
     nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
index bede574dbb996e886e777822edcc53829561b41a..5a1d8dcbb771422dc4253f4c2309c0972af01e91 100644 (file)
@@ -7028,6 +7028,7 @@ virDriver NAME(Driver) = {
     NULL, /* domainMigrateFinish */
     NULL, /* domainBlockStats */
     NULL, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     NULL, /* domainBlockPeek */
     NULL, /* domainMemoryPeek */
     nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
index 066436591aa02d1969e6b621e3b2edc9d65f5e7e..4911c9ed11a4f5b79eb1c6300cf536ef9578824f 100644 (file)
@@ -1844,6 +1844,7 @@ static virDriver xenUnifiedDriver = {
     xenUnifiedDomainMigrateFinish, /* domainMigrateFinish */
     xenUnifiedDomainBlockStats, /* domainBlockStats */
     xenUnifiedDomainInterfaceStats, /* domainInterfaceStats */
+    NULL, /* domainMemoryStats */
     xenUnifiedDomainBlockPeek, /* domainBlockPeek */
     NULL, /* domainMemoryPeek */
     xenUnifiedNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */