[libvirt] [PATCH 2/2] Edit test capabilities to contain different cell pagesizes.

Roland Schulz posted 2 patches 6 years, 11 months ago
[libvirt] [PATCH 2/2] Edit test capabilities to contain different cell pagesizes.
Posted by Roland Schulz 6 years, 11 months ago
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
---
 src/test/test_driver.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 467587b19..40c366cb8 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -322,24 +322,27 @@ testBuildCapabilities(virConnectPtr conn)
     if (virCapabilitiesAddHostFeature(caps, "nonpae") < 0)
         goto error;
 
-    if (VIR_ALLOC_N(caps->host.pagesSize, 2) < 0)
+    if (VIR_ALLOC_N(caps->host.pagesSize, 3) < 0)
         goto error;
 
     caps->host.pagesSize[caps->host.nPagesSize++] = 4;
     caps->host.pagesSize[caps->host.nPagesSize++] = 2048;
+    caps->host.pagesSize[caps->host.nPagesSize++] = 1024 * 1024;
 
     for (i = 0; i < privconn->numCells; i++) {
         virCapsHostNUMACellCPUPtr cpu_cells;
         virCapsHostNUMACellPageInfoPtr pages;
-        size_t nPages;
+        size_t nPages = caps->host.nPagesSize;
 
         if (VIR_ALLOC_N(cpu_cells, privconn->cells[i].numCpus) < 0 ||
             VIR_ALLOC_N(pages, caps->host.nPagesSize) < 0) {
                 VIR_FREE(cpu_cells);
                 goto error;
             }
-
-        nPages = caps->host.nPagesSize;
+        if (i == 1) {
+            nPages--;
+            caps->host.pagesSize[caps->host.nPagesSize - 3] = 8;
+        }
 
         memcpy(cpu_cells, privconn->cells[i].cpus,
                sizeof(*cpu_cells) * privconn->cells[i].numCpus);
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] Edit test capabilities to contain different cell pagesizes.
Posted by Michal Privoznik 6 years, 11 months ago
On 05/22/2018 11:54 AM, Roland Schulz wrote:
> Signed-off-by: Roland Schulz <schullzroll@gmail.com>
> ---
>  src/test/test_driver.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 

This one is a bit tricky.

> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 467587b19..40c366cb8 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -322,24 +322,27 @@ testBuildCapabilities(virConnectPtr conn)
>      if (virCapabilitiesAddHostFeature(caps, "nonpae") < 0)
>          goto error;
>  
> -    if (VIR_ALLOC_N(caps->host.pagesSize, 2) < 0)
> +    if (VIR_ALLOC_N(caps->host.pagesSize, 3) < 0)
>          goto error;
>  
>      caps->host.pagesSize[caps->host.nPagesSize++] = 4;
>      caps->host.pagesSize[caps->host.nPagesSize++] = 2048;
> +    caps->host.pagesSize[caps->host.nPagesSize++] = 1024 * 1024;

So numa node 1 supports 8K pages but not 4K. Okay, but in this case the
overall @caps should report all 4K, 8K, 2M and 1G.

>  
>      for (i = 0; i < privconn->numCells; i++) {
>          virCapsHostNUMACellCPUPtr cpu_cells;
>          virCapsHostNUMACellPageInfoPtr pages;
> -        size_t nPages;
> +        size_t nPages = caps->host.nPagesSize;
>  
>          if (VIR_ALLOC_N(cpu_cells, privconn->cells[i].numCpus) < 0 ||
>              VIR_ALLOC_N(pages, caps->host.nPagesSize) < 0) {
>                  VIR_FREE(cpu_cells);
>                  goto error;
>              }
> -
> -        nPages = caps->host.nPagesSize;
> +        if (i == 1) {
> +            nPages--;
> +            caps->host.pagesSize[caps->host.nPagesSize - 3] = 8;

This makes capabilities report 8K, 2M and 1G. No 4K. That doesn't look
right. What we want is a bit more complicated.

Let's have any node but #1 support 4K, 2M and 1G, and node #1 support
8K, 2M, and 1G. The code will have to look slightly different in that case.

Looking forward to v2.

Michal

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