[PATCH v2 7/7] nodeinfo: Implement nodeGetFreePages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And add stubs to other drivers like: lxc, qemu, uml and vbox.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/lxc/lxc_driver.c     | 19 +++++++++++++++++++
 src/nodeinfo.c           | 34 ++++++++++++++++++++++++++++++++++
 src/nodeinfo.h           |  5 +++++
 src/qemu/qemu_driver.c   | 19 +++++++++++++++++++
 src/uml/uml_driver.c     | 19 +++++++++++++++++++
 src/vbox/vbox_tmpl.c     | 16 ++++++++++++++++
 7 files changed, 113 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a7834ed..865919c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -875,6 +875,7 @@ nodeGetCPUBitmap;
 nodeGetCPUCount;
 nodeGetCPUMap;
 nodeGetCPUStats;
+nodeGetFreePages;
 nodeGetInfo;
 nodeGetMemory;
 nodeGetMemoryParameters;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index ab227d0..9380e8d 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -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 = {
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index b55d77e..dbfbf54 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -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;
+}
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index e7ec144..0896c6c 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -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__*/
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 88051c9..ce84df4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16876,6 +16876,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,
@@ -17070,6 +17088,7 @@ static virDriver qemuDriver = {
     .domainFSThaw = qemuDomainFSThaw, /* 1.2.5 */
     .domainGetTime = qemuDomainGetTime, /* 1.2.5 */
     .domainSetTime = qemuDomainSetTime, /* 1.2.5 */
+    .nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
 };
 
 
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index a5e9ea8..5ccd443 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -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 = {
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 66e933a..e4440dd 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -11475,6 +11475,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
  */
@@ -11556,6 +11571,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) = {
-- 
1.8.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]