Message ID | 407cb2b56fea2a9621e5dbabe38fdb45764eb691.1556196423.git.crobinso@redhat.com |
---|---|
State | New |
Headers | show |
Series | test: Use nodeInfo content for virNodeGetCPUMap | expand |
On 4/25/19 2:57 PM, Cole Robinson wrote: > Right now the test driver implementation of virNodeGetCPUMap uses > hardcoded data. Instead use cpu data from our nodeInfo, which can be > overridden with input test XML. This helps to emulate some virsh > commands (vcpupin, hostcpumap) with a large number of host cpus. [1] > > The content reported for test:///default is now slightly different: > previously it would report 8 total cpus with 0,2,4 online. Now it > reports 16 cpus with all online, which is the pre-existing nodeInfo > default. > > [1] https://www.redhat.com/archives/libvir-list/2019-March/msg02042.html > > Signed-off-by: Cole Robinson <crobinso@redhat.com> > --- > John, in trying to understand and test your bitmap patch, I added > this to the test driver. I think there's a bigger issue at play > but I'm still trying to work it out, I'll send a follow up email > when I've collected my thoughts > > src/test/test_driver.c | 35 +++++++++++++++++++++++++++++------ > 1 file changed, 29 insertions(+), 6 deletions(-) ACK Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d5eecf4b7f..f00b6eb1c8 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5811,23 +5811,46 @@ static int testConnectListAllDomains(virConnectPtr conn, } static int -testNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED, +testNodeGetCPUMap(virConnectPtr conn, unsigned char **cpumap, unsigned int *online, unsigned int flags) { + testDriverPtr privconn = conn->privateData; + int maxcpus = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo); + virBitmapPtr cpus = NULL; + int ret = -1; + int dummy; + size_t i; + virCheckFlags(0, -1); + if (!cpumap && !online) + return maxcpus; + + if (!(cpus = virBitmapNew(maxcpus))) + goto cleanup; + if (cpumap) { - if (VIR_ALLOC_N(*cpumap, 1) < 0) - return -1; - *cpumap[0] = 0x15; + for (i = 0; i < privconn->nodeInfo.cpus; i++) { + if (virBitmapSetBit(cpus, i) < 0) + goto cleanup; + } + + if (virBitmapToData(cpus, cpumap, &dummy) < 0) + goto cleanup; } if (online) - *online = 3; + *online = privconn->nodeInfo.cpus; - return 8; + ret = maxcpus; + + cleanup: + if (ret < 0 && cpumap) + VIR_FREE(*cpumap); + VIR_FREE(cpus); + return ret; } static char *
Right now the test driver implementation of virNodeGetCPUMap uses hardcoded data. Instead use cpu data from our nodeInfo, which can be overridden with input test XML. This helps to emulate some virsh commands (vcpupin, hostcpumap) with a large number of host cpus. [1] The content reported for test:///default is now slightly different: previously it would report 8 total cpus with 0,2,4 online. Now it reports 16 cpus with all online, which is the pre-existing nodeInfo default. [1] https://www.redhat.com/archives/libvir-list/2019-March/msg02042.html Signed-off-by: Cole Robinson <crobinso@redhat.com> --- John, in trying to understand and test your bitmap patch, I added this to the test driver. I think there's a bigger issue at play but I'm still trying to work it out, I'll send a follow up email when I've collected my thoughts src/test/test_driver.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list