mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 10:52:22 +00:00
virCapabilitiesHostNUMAAddCell: Take double pointer
What this function really does it takes ownership of all pointers passed (well, except for the first one - caps - to which it registers new NUMA node). But since all info is passed as a single pointer it's hard to tell (and use g_auto*). Let's use double pointers to make the ownership transfer obvious. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
26a24a702c
commit
83253ff091
@ -330,36 +330,45 @@ virCapabilitiesSetNetPrefix(virCaps *caps,
|
||||
* @num: ID number of NUMA cell
|
||||
* @mem: Total size of memory in the NUMA node (in KiB)
|
||||
* @ncpus: number of CPUs in cell
|
||||
* @cpus: array of CPU definition structures, the pointer is stolen
|
||||
* @cpus: array of CPU definition structures
|
||||
* @nsiblings: number of sibling NUMA nodes
|
||||
* @siblings: info on sibling NUMA nodes
|
||||
* @npageinfo: number of pages at node @num
|
||||
* @pageinfo: info on each single memory page
|
||||
*
|
||||
* Registers a new NUMA cell for a host, passing in a
|
||||
* array of CPU IDs belonging to the cell
|
||||
* Registers a new NUMA cell for a host, passing in a array of
|
||||
* CPU IDs belonging to the cell, distances to other NUMA nodes
|
||||
* and info on hugepages on the node.
|
||||
*
|
||||
* All pointers are stolen.
|
||||
*/
|
||||
void
|
||||
virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
|
||||
int num,
|
||||
unsigned long long mem,
|
||||
int ncpus,
|
||||
virCapsHostNUMACellCPU *cpus,
|
||||
virCapsHostNUMACellCPU **cpus,
|
||||
int nsiblings,
|
||||
virCapsHostNUMACellSiblingInfo *siblings,
|
||||
virCapsHostNUMACellSiblingInfo **siblings,
|
||||
int npageinfo,
|
||||
virCapsHostNUMACellPageInfo *pageinfo)
|
||||
virCapsHostNUMACellPageInfo **pageinfo)
|
||||
{
|
||||
virCapsHostNUMACell *cell = g_new0(virCapsHostNUMACell, 1);
|
||||
|
||||
cell->num = num;
|
||||
cell->mem = mem;
|
||||
cell->ncpus = ncpus;
|
||||
cell->cpus = cpus;
|
||||
cell->nsiblings = nsiblings;
|
||||
cell->siblings = siblings;
|
||||
cell->npageinfo = npageinfo;
|
||||
cell->pageinfo = pageinfo;
|
||||
if (cpus) {
|
||||
cell->ncpus = ncpus;
|
||||
cell->cpus = g_steal_pointer(cpus);
|
||||
}
|
||||
if (siblings) {
|
||||
cell->nsiblings = nsiblings;
|
||||
cell->siblings = g_steal_pointer(siblings);
|
||||
}
|
||||
if (pageinfo) {
|
||||
cell->npageinfo = npageinfo;
|
||||
cell->pageinfo = g_steal_pointer(pageinfo);
|
||||
}
|
||||
|
||||
g_ptr_array_add(caps->cells, cell);
|
||||
}
|
||||
@ -1568,7 +1577,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMA *caps)
|
||||
|
||||
virCapabilitiesHostNUMAAddCell(caps, 0,
|
||||
nodeinfo.memory,
|
||||
cid, cpus,
|
||||
cid, &cpus,
|
||||
0, NULL,
|
||||
0, NULL);
|
||||
}
|
||||
@ -1633,13 +1642,9 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMA *caps)
|
||||
memory >>= 10;
|
||||
|
||||
virCapabilitiesHostNUMAAddCell(caps, n, memory,
|
||||
ncpus, cpus,
|
||||
nsiblings, siblings,
|
||||
npageinfo, pageinfo);
|
||||
|
||||
cpus = NULL;
|
||||
siblings = NULL;
|
||||
pageinfo = NULL;
|
||||
ncpus, &cpus,
|
||||
nsiblings, &siblings,
|
||||
npageinfo, &pageinfo);
|
||||
virBitmapFree(cpumap);
|
||||
cpumap = NULL;
|
||||
}
|
||||
|
@ -254,11 +254,11 @@ virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
|
||||
int num,
|
||||
unsigned long long mem,
|
||||
int ncpus,
|
||||
virCapsHostNUMACellCPU *cpus,
|
||||
virCapsHostNUMACellCPU **cpus,
|
||||
int nsiblings,
|
||||
virCapsHostNUMACellSiblingInfo *siblings,
|
||||
virCapsHostNUMACellSiblingInfo **siblings,
|
||||
int npageinfo,
|
||||
virCapsHostNUMACellPageInfo *pageinfo);
|
||||
virCapsHostNUMACellPageInfo **pageinfo);
|
||||
|
||||
virCapsGuestMachine **
|
||||
virCapabilitiesAllocMachines(const char *const *names,
|
||||
|
@ -330,8 +330,8 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCaps *caps)
|
||||
|
||||
virCapabilitiesHostNUMAAddCell(caps->host.numa, i,
|
||||
numa_info[i].size / 1024,
|
||||
nr_cpus_node[i], cpus[i],
|
||||
nr_siblings, siblings,
|
||||
nr_cpus_node[i], &cpus[i],
|
||||
nr_siblings, &siblings,
|
||||
0, NULL);
|
||||
|
||||
/* This is safe, as the CPU list is now stored in the NUMA cell */
|
||||
|
@ -329,8 +329,9 @@ testBuildCapabilities(virConnectPtr conn)
|
||||
|
||||
virCapabilitiesHostNUMAAddCell(caps->host.numa,
|
||||
i, privconn->cells[i].mem,
|
||||
privconn->cells[i].numCpus,
|
||||
cpu_cells, 0, NULL, nPages, pages);
|
||||
privconn->cells[i].numCpus, &cpu_cells,
|
||||
0, NULL,
|
||||
nPages, &pages);
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(guest_types); i++) {
|
||||
|
@ -935,9 +935,9 @@ virTestCapsBuildNUMATopology(int seq)
|
||||
|
||||
virCapabilitiesHostNUMAAddCell(caps, cell_id + seq,
|
||||
MAX_MEM_IN_CELL,
|
||||
MAX_CPUS_IN_CELL, cell_cpus,
|
||||
VIR_ARCH_NONE, NULL,
|
||||
VIR_ARCH_NONE, NULL);
|
||||
MAX_CPUS_IN_CELL, &cell_cpus,
|
||||
0, NULL,
|
||||
0, NULL);
|
||||
|
||||
cell_cpus = NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user