]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
nodeinfo: Implement nodeAllocPages
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 18 Sep 2014 07:47:07 +0000 (09:47 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 25 Sep 2014 08:24:45 +0000 (10:24 +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_common.c

index 6657d3d42e36b65a00093bdc8307e0e908627baa..2019ef52d05b9f3877a94355a28d952063e2af65 100644 (file)
@@ -893,6 +893,7 @@ virLockManagerRelease;
 
 
 # nodeinfo.h
+nodeAllocPages;
 nodeCapsInitNUMA;
 nodeGetCellsFreeMemory;
 nodeGetCPUBitmap;
index c3cd62c04847af6d23215a9bb76925fedb453334..38763de1c4e2f51db39d003c2b5cec8a336a4dcd 100644 (file)
@@ -5685,6 +5685,27 @@ lxcNodeGetFreePages(virConnectPtr conn,
 }
 
 
+static int
+lxcNodeAllocPages(virConnectPtr conn,
+                  unsigned int npages,
+                  unsigned int *pageSizes,
+                  unsigned long long *pageCounts,
+                  int startCell,
+                  unsigned int cellCount,
+                  unsigned int flags)
+{
+    bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
+
+    virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
+
+    if (virNodeAllocPagesEnsureACL(conn) < 0)
+        return -1;
+
+    return nodeAllocPages(npages, pageSizes, pageCounts,
+                          startCell, cellCount, add);
+}
+
+
 /* Function Tables */
 static virDriver lxcDriver = {
     .no = VIR_DRV_LXC,
@@ -5776,6 +5797,7 @@ static virDriver lxcDriver = {
     .domainReboot = lxcDomainReboot, /* 1.0.1 */
     .domainLxcOpenNamespace = lxcDomainLxcOpenNamespace, /* 1.0.2 */
     .nodeGetFreePages = lxcNodeGetFreePages, /* 1.2.6 */
+    .nodeAllocPages = lxcNodeAllocPages, /* 1.2.8 */
 };
 
 static virStateDriver lxcStateDriver = {
index 3bc0c3cc475d8abb584c0a6e27df26a2ec45be73..2e2fffac1155eac8a78aef5ce8d357c3f77d3df0 100644 (file)
@@ -2065,3 +2065,44 @@ nodeGetFreePages(unsigned int npages,
  cleanup:
     return ret;
 }
+
+int
+nodeAllocPages(unsigned int npages,
+               unsigned int *pageSizes,
+               unsigned long long *pageCounts,
+               int startCell,
+               unsigned int cellCount,
+               bool add)
+{
+    int ret = -1;
+    int cell, lastCell;
+    size_t i, ncounts = 0;
+
+    if ((lastCell = virNumaGetMaxNode()) < 0)
+        return 0;
+
+    if (startCell > lastCell) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("start cell %d out of range (0-%d)"),
+                       startCell, lastCell);
+        goto cleanup;
+    }
+
+    lastCell = MIN(lastCell, startCell + (int) cellCount - 1);
+
+    for (cell = startCell; cell <= lastCell; cell++) {
+        for (i = 0; i < npages; i++) {
+            unsigned int page_size = pageSizes[i];
+            unsigned long long page_count = pageCounts[i];
+
+            if (virNumaSetPagePoolSize(cell, page_size, page_count, add) < 0)
+                goto cleanup;
+
+            ncounts++;
+        }
+    }
+
+    ret = ncounts;
+ cleanup:
+    return ret;
+}
index 0896c6c7675547204d1274da92f93c2fa8ea3239..a993c6367d058c25c42c26949bc86c3ec7ffe18e 100644 (file)
@@ -63,4 +63,11 @@ int nodeGetFreePages(unsigned int npages,
                      int startCell,
                      unsigned int cellCount,
                      unsigned long long *counts);
+
+int nodeAllocPages(unsigned int npages,
+                   unsigned int *pageSizes,
+                   unsigned long long *pageCounts,
+                   int startCell,
+                   unsigned int cellCount,
+                   bool add);
 #endif /* __VIR_NODEINFO_H__*/
index 543de79e0f3ba0ed091772a649668b28feaa93ce..4afd06620508832c97520d32764a4a5825971d6b 100644 (file)
@@ -18142,6 +18142,27 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
 }
 
 
+static int
+qemuNodeAllocPages(virConnectPtr conn,
+                   unsigned int npages,
+                   unsigned int *pageSizes,
+                   unsigned long long *pageCounts,
+                   int startCell,
+                   unsigned int cellCount,
+                   unsigned int flags)
+{
+    bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
+
+    virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
+
+    if (virNodeAllocPagesEnsureACL(conn) < 0)
+        return -1;
+
+    return nodeAllocPages(npages, pageSizes, pageCounts,
+                          startCell, cellCount, add);
+}
+
+
 static virDriver qemuDriver = {
     .no = VIR_DRV_QEMU,
     .name = QEMU_DRIVER_NAME,
@@ -18341,6 +18362,7 @@ static virDriver qemuDriver = {
     .nodeGetFreePages = qemuNodeGetFreePages, /* 1.2.6 */
     .connectGetDomainCapabilities = qemuConnectGetDomainCapabilities, /* 1.2.7 */
     .connectGetAllDomainStats = qemuConnectGetAllDomainStats, /* 1.2.8 */
+    .nodeAllocPages = qemuNodeAllocPages, /* 1.2.8 */
 };
 
 
index 12b0ba72da08b05005360a7e48b3678cbcd27d61..c255c07c166e418e36b39bbc276355d4625b4ad9 100644 (file)
@@ -2897,6 +2897,27 @@ umlNodeGetFreePages(virConnectPtr conn,
 }
 
 
+static int
+umlNodeAllocPages(virConnectPtr conn,
+                  unsigned int npages,
+                  unsigned int *pageSizes,
+                  unsigned long long *pageCounts,
+                  int startCell,
+                  unsigned int cellCount,
+                  unsigned int flags)
+{
+    bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
+
+    virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
+
+    if (virNodeAllocPagesEnsureACL(conn) < 0)
+        return -1;
+
+    return nodeAllocPages(npages, pageSizes, pageCounts,
+                          startCell, cellCount, add);
+}
+
+
 static virDriver umlDriver = {
     .no = VIR_DRV_UML,
     .name = "UML",
@@ -2959,6 +2980,7 @@ static virDriver umlDriver = {
     .nodeGetMemoryParameters = umlNodeGetMemoryParameters, /* 0.10.2 */
     .nodeSetMemoryParameters = umlNodeSetMemoryParameters, /* 0.10.2 */
     .nodeGetFreePages = umlNodeGetFreePages, /* 1.2.6 */
+    .nodeAllocPages = umlNodeAllocPages, /* 1.2.8 */
 };
 
 static virStateDriver umlStateDriver = {
index 7ff0761f5e2a83d93e81f2a9cec2973267e11e99..e831255b0382e552b387c5043d8062c0c9a7d03c 100644 (file)
@@ -7462,6 +7462,24 @@ vboxNodeGetFreePages(virConnectPtr conn ATTRIBUTE_UNUSED,
     return nodeGetFreePages(npages, pages, startCell, cellCount, counts);
 }
 
+static int
+vboxNodeAllocPages(virConnectPtr conn ATTRIBUTE_UNUSED,
+                   unsigned int npages,
+                   unsigned int *pageSizes,
+                   unsigned long long *pageCounts,
+                   int startCell,
+                   unsigned int cellCount,
+                   unsigned int flags)
+{
+    bool add = !(flags & VIR_NODE_ALLOC_PAGES_SET);
+
+    virCheckFlags(VIR_NODE_ALLOC_PAGES_SET, -1);
+
+    return nodeAllocPages(npages, pageSizes, pageCounts,
+                          startCell, cellCount, add);
+}
+
+
 /**
  * Function Tables
  */
@@ -7533,6 +7551,7 @@ virDriver vboxCommonDriver = {
     .domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
     .connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
     .nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
+    .nodeAllocPages = vboxNodeAllocPages, /* 1.2.8 */
 };
 
 static void updateDriver(void)