Signed-off-by: Roland Schulz <schullzroll@gmail.com>
---
src/test/test_driver.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 467587b19..3fe0c2831 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -322,30 +322,34 @@ 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, 4) < 0)
goto error;
caps->host.pagesSize[caps->host.nPagesSize++] = 4;
+ caps->host.pagesSize[caps->host.nPagesSize++] = 8;
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 - 1;
if (VIR_ALLOC_N(cpu_cells, privconn->cells[i].numCpus) < 0 ||
- VIR_ALLOC_N(pages, caps->host.nPagesSize) < 0) {
+ VIR_ALLOC_N(pages, caps->host.nPagesSize - 1) < 0) {
VIR_FREE(cpu_cells);
goto error;
}
-
- nPages = caps->host.nPagesSize;
+ if (i == 1)
+ pages[0].size = caps->host.pagesSize[0];
+ else
+ pages[0].size = caps->host.pagesSize[1];
memcpy(cpu_cells, privconn->cells[i].cpus,
sizeof(*cpu_cells) * privconn->cells[i].numCpus);
- for (j = 0; j < nPages; j++)
- pages[j].size = caps->host.pagesSize[j];
+ for (j = 1; j < nPages; j++)
+ pages[j].size = caps->host.pagesSize[j+1];
pages[0].avail = privconn->cells[i].mem / pages[0].size;
--
2.17.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 05/23/2018 02:40 PM, Roland Schulz wrote: > Signed-off-by: Roland Schulz <schullzroll@gmail.com> > --- > src/test/test_driver.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) In the $SUBJ I'd add the prefix "test driver:" to tell explicitly what part of code this commit touches. > > diff --git a/src/test/test_driver.c b/src/test/test_driver.c > index 467587b19..3fe0c2831 100644 > --- a/src/test/test_driver.c > +++ b/src/test/test_driver.c > @@ -322,30 +322,34 @@ 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, 4) < 0) > goto error; > > caps->host.pagesSize[caps->host.nPagesSize++] = 4; > + caps->host.pagesSize[caps->host.nPagesSize++] = 8; > 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 - 1; > > if (VIR_ALLOC_N(cpu_cells, privconn->cells[i].numCpus) < 0 || > - VIR_ALLOC_N(pages, caps->host.nPagesSize) < 0) { > + VIR_ALLOC_N(pages, caps->host.nPagesSize - 1) < 0) { or s/caps->host.nPagesSize - 1/nPages/ since they will always have the same value. > VIR_FREE(cpu_cells); > goto error; > } > - > - nPages = caps->host.nPagesSize; > + if (i == 1) > + pages[0].size = caps->host.pagesSize[0]; > + else > + pages[0].size = caps->host.pagesSize[1]; I'd move this after the memcpy so that pages[] initialization is kept together with the for() loop below the memcpy(). IOW, memcpy should be moved before this if() statement. > > memcpy(cpu_cells, privconn->cells[i].cpus, > sizeof(*cpu_cells) * privconn->cells[i].numCpus); > > - for (j = 0; j < nPages; j++) > - pages[j].size = caps->host.pagesSize[j]; > + for (j = 1; j < nPages; j++) > + pages[j].size = caps->host.pagesSize[j+1]; Too much spaces ;-) Also, "j + 1" instead of "j+1". Fixing all the issues, ACKing and pushing. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Signed-off-by: Roland Schulz <schullzroll@gmail.com>
---
tools/virsh-completer.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 1435d1d4c..c72f3bcad 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -576,6 +576,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
virshControlPtr priv = ctl->privData;
unsigned int npages = 0;
xmlNodePtr *pages = NULL;
+ xmlDocPtr doc = NULL;
double size = 0;
size_t i = 0;
const char *suffix = NULL;
@@ -595,7 +596,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
goto error;
- if (!(virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
+ if ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)) == NULL)
goto error;
if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) > 0) {
@@ -631,12 +632,11 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
cleanup:
xmlXPathFreeContext(ctxt);
- for (i = 0; i < npages; i++)
- VIR_FREE(pages[i]);
VIR_FREE(pages);
- VIR_FREE(cap_xml);
+ xmlFreeDoc(doc);
VIR_FREE(path);
VIR_FREE(pagesize);
+ VIR_FREE(cap_xml);
VIR_FREE(unit);
return ret;
--
2.17.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 05/23/2018 02:40 PM, Roland Schulz wrote: > Signed-off-by: Roland Schulz <schullzroll@gmail.com> > --- > tools/virsh-completer.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c > index 1435d1d4c..c72f3bcad 100644 > --- a/tools/virsh-completer.c > +++ b/tools/virsh-completer.c > @@ -576,6 +576,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, > virshControlPtr priv = ctl->privData; > unsigned int npages = 0; > xmlNodePtr *pages = NULL; > + xmlDocPtr doc = NULL; > double size = 0; > size_t i = 0; > const char *suffix = NULL; > @@ -595,7 +596,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, > if (!(cap_xml = virConnectGetCapabilities(priv->conn))) > goto error; > > - if (!(virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt))) > + if ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)) == NULL) > goto error; You can keep the !ptr comparison just like @cap_xml is tested a few lines above. > > if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) > 0) { > @@ -631,12 +632,11 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl, > > cleanup: > xmlXPathFreeContext(ctxt); > - for (i = 0; i < npages; i++) > - VIR_FREE(pages[i]); > VIR_FREE(pages); > - VIR_FREE(cap_xml); > + xmlFreeDoc(doc); > VIR_FREE(path); > VIR_FREE(pagesize); > + VIR_FREE(cap_xml); > VIR_FREE(unit); > > return ret; > ACKed and pushed. Thank you for addressing all the points I raised. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.