]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodeinfo: Implement nodeGetFreePages
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 10 Jun 2014 14:16:44 +0000 (16:16 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 19 Jun 2014 13:10:50 +0000 (15:10 +0200)
And add stubs to other drivers like: lxc, qemu, uml and vbox.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/libvirt_private.syms
src/lxc/lxc_driver.c
src/nodeinfo.c
src/nodeinfo.h
src/qemu/qemu_driver.c
src/uml/uml_driver.c
src/vbox/vbox_tmpl.c

index 3c412f99e1e71c6d60c67170d0d32db88b98bce1..46c0f029f53a628cf82d02fc34e71900bd5ec7a6 100644 (file)
@@ -877,6 +877,7 @@ nodeGetCPUBitmap;
 nodeGetCPUCount;
 nodeGetCPUMap;
 nodeGetCPUStats;
+nodeGetFreePages;
 nodeGetInfo;
 nodeGetMemory;
 nodeGetMemoryParameters;
index ab227d0d0fa5a1e2464aaa9c9732003f20a7b29e..9380e8de6648c54c7d9ff863b62df3187d73c568 100644 (file)
@@ -5656,6 +5656,24 @@ lxcDomainGetCPUStats(virDomainPtr dom,
 }
 
 
+static int
+lxcNodeGetFreePages(virConnectPtr conn,
+                    unsigned int npages,
+                    unsigned int *pages,
+                    int startCell,
+                    unsigned int cellCount,
+                    unsigned long long *counts,
+                    unsigned int flags)
+{
+    virCheckFlags(0, -1);
+
+    if (virNodeGetFreePagesEnsureACL(conn) < 0)
+        return -1;
+
+    return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
+}
+
+
 /* Function Tables */
 static virDriver lxcDriver = {
     .no = VIR_DRV_LXC,
@@ -5745,6 +5763,7 @@ static virDriver lxcDriver = {
     .domainShutdownFlags = lxcDomainShutdownFlags, /* 1.0.1 */
     .domainReboot = lxcDomainReboot, /* 1.0.1 */
     .domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
+    .nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
 };
 
 static virStateDriver lxcStateDriver = {
index b55d77e5016fbe3f486012ec1dc87395f7a121a6..dbfbf5449a9389eecbc17d450845332caf8a7df1 100644 (file)
@@ -2018,3 +2018,37 @@ nodeGetMemory(unsigned long long *mem,
 
     return 0;
 }
+
+int
+nodeGetFreePages(unsigned int npages,
+                 unsigned int *pages,
+                 int startCell,
+                 unsigned int cellCount,
+                 unsigned long long *counts)
+{
+    int ret = -1;
+    int cell;
+    size_t i, ncounts = 0;
+
+    for (cell = startCell; cell < (int) (startCell + cellCount); cell++) {
+        for (i = 0; i < npages; i++) {
+            unsigned int page_size = pages[i];
+            unsigned int page_free;
+
+            if (virNumaGetPageInfo(cell, page_size, NULL, &page_free) < 0)
+                goto cleanup;
+
+            counts[ncounts++] = page_free;
+        }
+    }
+
+    if (!ncounts) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("no suitable info found"));
+        goto cleanup;
+    }
+
+    ret = ncounts;
+ cleanup:
+    return ret;
+}
index e7ec144f214f6d889a8276ddf2dea40f80652184..0896c6c7675547204d1274da92f93c2fa8ea3239 100644 (file)
@@ -58,4 +58,9 @@ int nodeGetCPUMap(unsigned char **cpumap,
                   unsigned int *online,
                   unsigned int flags);
 
+int nodeGetFreePages(unsigned int npages,
+                     unsigned int *pages,
+                     int startCell,
+                     unsigned int cellCount,
+                     unsigned long long *counts);
 #endif /* __VIR_NODEINFO_H__*/
index f359d8fd35ac63c761ecf6bdffba1960c5be41ff..9a733a04f50d83d5a41c29ac605974c3e3c4511f 100644 (file)
@@ -16879,6 +16879,24 @@ qemuDomainFSThaw(virDomainPtr dom,
 }
 
 
+static int
+qemuNodeGetFreePages(virConnectPtr conn,
+                     unsigned int npages,
+                     unsigned int *pages,
+                     int startCell,
+                     unsigned int cellCount,
+                     unsigned long long *counts,
+                     unsigned int flags)
+{
+    virCheckFlags(0, -1);
+
+    if (virNodeGetFreePagesEnsureACL(conn) < 0)
+        return -1;
+
+    return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
+}
+
+
 static virDriver qemuDriver = {
     .no = VIR_DRV_QEMU,
     .name = QEMU_DRIVER_NAME,
@@ -17073,6 +17091,7 @@ static virDriver qemuDriver = {
     .domainFSThaw = qemuDomainFSThaw, /* 1.2.5 */
     .domainGetTime = qemuDomainGetTime, /* 1.2.5 */
     .domainSetTime = qemuDomainSetTime, /* 1.2.5 */
+    .nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
 };
 
 
index a5e9ea8b0f10582c25eb642ee04a37ea4a3ac618..5ccd44387e0aedbd550773429b8dc6ccffc37e8e 100644 (file)
@@ -2870,6 +2870,24 @@ umlNodeSuspendForDuration(virConnectPtr conn,
 }
 
 
+static int
+umlNodeGetFreePages(virConnectPtr conn,
+                    unsigned int npages,
+                    unsigned int *pages,
+                    int startCell,
+                    unsigned int cellCount,
+                    unsigned long long *counts,
+                    unsigned int flags)
+{
+    virCheckFlags(0, -1);
+
+    if (virNodeGetFreePagesEnsureACL(conn) < 0)
+        return -1;
+
+    return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
+}
+
+
 static virDriver umlDriver = {
     .no = VIR_DRV_UML,
     .name = "UML",
@@ -2931,6 +2949,7 @@ static virDriver umlDriver = {
     .nodeSuspendForDuration = umlNodeSuspendForDuration, /* 0.9.8 */
     .nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
     .nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
+    .nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
 };
 
 static virStateDriver umlStateDriver = {
index a80da69617c969e158076114233756329d25bfeb..4ba9ad7cecd5a3af5d7e287dc5ee98e9839440e7 100644 (file)
@@ -11483,6 +11483,21 @@ vboxNodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
 }
 
 
+static int
+vboxNodeGetFreePages(virConnectPtr conn ATTRIBUTE_UNUSED,
+                     unsigned int npages,
+                     unsigned int *pages,
+                     int startCell,
+                     unsigned int cellCount,
+                     unsigned long long *counts,
+                     unsigned int flags)
+{
+    virCheckFlags(0, -1);
+
+    return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
+}
+
+
 /**
  * Function Tables
  */
@@ -11564,6 +11579,7 @@ virDriver NAME(Driver) = {
     .domainRevertToSnapshot = vboxDomainRevertToSnapshot, /* 0.8.0 */
     .domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
     .connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
+    .nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
 };
 
 virNetworkDriver NAME(NetworkDriver) = {