--- /dev/null
+<capabilities>
+
+ <host>
+ <cpu>
+ <arch>aarch64</arch>
+ </cpu>
+ <power_management/>
+ <migration_features>
+ </migration_features>
+ <topology>
+ <cells num='4'>
+ <cell id='0'>
+ <memory unit='KiB'>1048576</memory>
+ <pages unit='KiB' size='4'>2048</pages>
+ <pages unit='KiB' size='2048'>4096</pages>
+ <pages unit='KiB' size='1048576'>6144</pages>
+ <cpus num='4'>
+ <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
+ <cpu id='1' socket_id='0' core_id='1' siblings='1'/>
+ <cpu id='2' socket_id='0' core_id='2' siblings='2'/>
+ <cpu id='3' socket_id='0' core_id='3' siblings='3'/>
+ </cpus>
+ </cell>
+ <cell id='1'>
+ <memory unit='KiB'>2097152</memory>
+ <pages unit='KiB' size='4'>4096</pages>
+ <pages unit='KiB' size='2048'>6144</pages>
+ <pages unit='KiB' size='1048576'>8192</pages>
+ <cpus num='4'>
+ <cpu id='4' socket_id='1' core_id='4' siblings='4'/>
+ <cpu id='5' socket_id='1' core_id='5' siblings='5'/>
+ <cpu id='6' socket_id='1' core_id='6' siblings='6'/>
+ <cpu id='7' socket_id='1' core_id='7' siblings='7'/>
+ </cpus>
+ </cell>
+ <cell id='2'>
+ <memory unit='KiB'>3145728</memory>
+ <pages unit='KiB' size='4'>6144</pages>
+ <pages unit='KiB' size='2048'>8192</pages>
+ <pages unit='KiB' size='1048576'>10240</pages>
+ <cpus num='4'>
+ <cpu id='8' socket_id='2' core_id='8' siblings='8'/>
+ <cpu id='9' socket_id='2' core_id='9' siblings='9'/>
+ <cpu id='10' socket_id='2' core_id='10' siblings='10'/>
+ <cpu id='11' socket_id='2' core_id='11' siblings='11'/>
+ </cpus>
+ </cell>
+ <cell id='3'>
+ <memory unit='KiB'>4194304</memory>
+ <pages unit='KiB' size='4'>8192</pages>
+ <pages unit='KiB' size='2048'>10240</pages>
+ <pages unit='KiB' size='1048576'>12288</pages>
+ <cpus num='4'>
+ <cpu id='12' socket_id='3' core_id='12' siblings='12'/>
+ <cpu id='13' socket_id='3' core_id='13' siblings='13'/>
+ <cpu id='14' socket_id='3' core_id='14' siblings='14'/>
+ <cpu id='15' socket_id='3' core_id='15' siblings='15'/>
+ </cpus>
+ </cell>
+ </cells>
+ </topology>
+ </host>
+
+</capabilities>
+++ /dev/null
-<capabilities>
-
- <host>
- <cpu>
- <arch>x86_64</arch>
- </cpu>
- <power_management/>
- <topology>
- <cells num='4'>
- <cell id='0'>
- <memory unit='KiB'>2097152</memory>
- <distances>
- <sibling id='0' value='10'/>
- <sibling id='1' value='20'/>
- <sibling id='2' value='20'/>
- <sibling id='3' value='20'/>
- </distances>
- <cpus num='4'>
- <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
- <cpu id='0' socket_id='0' core_id='1' siblings='0'/>
- <cpu id='0' socket_id='0' core_id='2' siblings='0'/>
- <cpu id='0' socket_id='0' core_id='3' siblings='0'/>
- </cpus>
- </cell>
- <cell id='1'>
- <memory unit='KiB'>2097152</memory>
- <distances>
- <sibling id='0' value='20'/>
- <sibling id='1' value='10'/>
- <sibling id='2' value='20'/>
- <sibling id='3' value='20'/>
- </distances>
- <cpus num='4'>
- <cpu id='1' socket_id='1' core_id='1' siblings='1'/>
- <cpu id='1' socket_id='1' core_id='2' siblings='1'/>
- <cpu id='1' socket_id='1' core_id='3' siblings='1'/>
- <cpu id='1' socket_id='1' core_id='4' siblings='1'/>
- </cpus>
- </cell>
- <cell id='2'>
- <memory unit='KiB'>2097152</memory>
- <distances>
- <sibling id='0' value='20'/>
- <sibling id='1' value='20'/>
- <sibling id='2' value='10'/>
- <sibling id='3' value='20'/>
- </distances>
- <cpus num='4'>
- <cpu id='2' socket_id='2' core_id='2' siblings='2'/>
- <cpu id='2' socket_id='2' core_id='3' siblings='2'/>
- <cpu id='2' socket_id='2' core_id='4' siblings='2'/>
- <cpu id='2' socket_id='2' core_id='5' siblings='2'/>
- </cpus>
- </cell>
- <cell id='3'>
- <memory unit='KiB'>2097152</memory>
- <distances>
- <sibling id='0' value='20'/>
- <sibling id='1' value='20'/>
- <sibling id='2' value='20'/>
- <sibling id='3' value='10'/>
- </distances>
- <cpus num='4'>
- <cpu id='3' socket_id='3' core_id='3' siblings='3'/>
- <cpu id='3' socket_id='3' core_id='4' siblings='3'/>
- <cpu id='3' socket_id='3' core_id='5' siblings='3'/>
- <cpu id='3' socket_id='3' core_id='6' siblings='3'/>
- </cpus>
- </cell>
- </cells>
- </topology>
- </host>
-
-</capabilities>
--- /dev/null
+<capabilities>
+
+ <host>
+ <cpu>
+ <arch>x86_64</arch>
+ </cpu>
+ <power_management/>
+ <topology>
+ <cells num='4'>
+ <cell id='0'>
+ <memory unit='KiB'>1048576</memory>
+ <pages unit='KiB' size='4'>2048</pages>
+ <pages unit='KiB' size='2048'>4096</pages>
+ <pages unit='KiB' size='1048576'>6144</pages>
+ <cpus num='4'>
+ <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
+ <cpu id='1' socket_id='0' core_id='1' siblings='1'/>
+ <cpu id='2' socket_id='0' core_id='2' siblings='2'/>
+ <cpu id='3' socket_id='0' core_id='3' siblings='3'/>
+ </cpus>
+ </cell>
+ <cell id='1'>
+ <memory unit='KiB'>2097152</memory>
+ <pages unit='KiB' size='4'>4096</pages>
+ <pages unit='KiB' size='2048'>6144</pages>
+ <pages unit='KiB' size='1048576'>8192</pages>
+ <cpus num='4'>
+ <cpu id='4' socket_id='1' core_id='4' siblings='4'/>
+ <cpu id='5' socket_id='1' core_id='5' siblings='5'/>
+ <cpu id='6' socket_id='1' core_id='6' siblings='6'/>
+ <cpu id='7' socket_id='1' core_id='7' siblings='7'/>
+ </cpus>
+ </cell>
+ <cell id='2'>
+ <memory unit='KiB'>3145728</memory>
+ <pages unit='KiB' size='4'>6144</pages>
+ <pages unit='KiB' size='2048'>8192</pages>
+ <pages unit='KiB' size='1048576'>10240</pages>
+ <cpus num='4'>
+ <cpu id='8' socket_id='2' core_id='8' siblings='8'/>
+ <cpu id='9' socket_id='2' core_id='9' siblings='9'/>
+ <cpu id='10' socket_id='2' core_id='10' siblings='10'/>
+ <cpu id='11' socket_id='2' core_id='11' siblings='11'/>
+ </cpus>
+ </cell>
+ <cell id='3'>
+ <memory unit='KiB'>4194304</memory>
+ <pages unit='KiB' size='4'>8192</pages>
+ <pages unit='KiB' size='2048'>10240</pages>
+ <pages unit='KiB' size='1048576'>12288</pages>
+ <cpus num='4'>
+ <cpu id='12' socket_id='3' core_id='12' siblings='12'/>
+ <cpu id='13' socket_id='3' core_id='13' siblings='13'/>
+ <cpu id='14' socket_id='3' core_id='14' siblings='14'/>
+ <cpu id='15' socket_id='3' core_id='15' siblings='15'/>
+ </cpus>
+ </cell>
+ </cells>
+ </topology>
+ </host>
+
+</capabilities>
--- /dev/null
+<capabilities>
+
+ <host>
+ <cpu>
+ <arch>x86_64</arch>
+ </cpu>
+ <power_management/>
+ <migration_features>
+ <live/>
+ </migration_features>
+ <topology>
+ <cells num='1'>
+ <cell id='0'>
+ <memory unit='KiB'>1048576</memory>
+ <pages unit='KiB' size='4'>2048</pages>
+ <pages unit='KiB' size='2048'>4096</pages>
+ <pages unit='KiB' size='1048576'>6144</pages>
+ <cpus num='8'>
+ <cpu id='0' socket_id='0' core_id='0' siblings='0,4'/>
+ <cpu id='1' socket_id='0' core_id='1' siblings='1,5'/>
+ <cpu id='2' socket_id='0' core_id='2' siblings='2,6'/>
+ <cpu id='3' socket_id='0' core_id='3' siblings='3,7'/>
+ <cpu id='4' socket_id='0' core_id='0' siblings='0,4'/>
+ <cpu id='5' socket_id='0' core_id='1' siblings='1,5'/>
+ <cpu id='6' socket_id='0' core_id='2' siblings='2,6'/>
+ <cpu id='7' socket_id='0' core_id='3' siblings='3,7'/>
+ </cpus>
+ </cell>
+ </cells>
+ </topology>
+ </host>
+
+</capabilities>
#include "testutils.h"
#include "capabilities.h"
#include "virbitmap.h"
+#include "virsysfspriv.h"
#define VIR_FROM_THIS VIR_FROM_NONE
-static virCapsPtr
-buildVirCapabilities(int max_cells,
- int max_cpus_in_cell,
- int max_mem_in_cell)
-{
- virCapsPtr caps;
- virCapsHostNUMACellCPUPtr cell_cpus = NULL;
- virCapsHostNUMACellSiblingInfoPtr siblings = NULL;
- int core_id, cell_id, nsiblings;
- int id;
- size_t i;
-
- if ((caps = virCapabilitiesNew(VIR_ARCH_X86_64, false, false)) == NULL)
- goto error;
-
- id = 0;
- for (cell_id = 0; cell_id < max_cells; cell_id++) {
- if (VIR_ALLOC_N(cell_cpus, max_cpus_in_cell) < 0)
- goto error;
-
- for (core_id = 0; core_id < max_cpus_in_cell; core_id++) {
- cell_cpus[core_id].id = id;
- cell_cpus[core_id].socket_id = cell_id;
- cell_cpus[core_id].core_id = id + core_id;
- if (!(cell_cpus[core_id].siblings =
- virBitmapNew(max_cpus_in_cell)))
- goto error;
- ignore_value(virBitmapSetBit(cell_cpus[core_id].siblings, id));
- }
- id++;
-
- if (VIR_ALLOC_N(siblings, max_cells) < 0)
- goto error;
- nsiblings = max_cells;
-
- for (i = 0; i < nsiblings; i++) {
- siblings[i].node = i;
- /* Some magical constants, see virNumaGetDistances()
- * for their description. */
- siblings[i].distance = cell_id == i ? 10 : 20;
- }
-
- if (virCapabilitiesAddHostNUMACell(caps, cell_id,
- max_mem_in_cell,
- max_cpus_in_cell, cell_cpus,
- nsiblings, siblings,
- 0, NULL) < 0)
- goto error;
-
- cell_cpus = NULL;
- siblings = NULL;
- }
-
- return caps;
-
- error:
- virCapabilitiesClearHostNUMACellCPUTopology(cell_cpus, max_cpus_in_cell);
- VIR_FREE(cell_cpus);
- VIR_FREE(siblings);
- virObjectUnref(caps);
- return NULL;
-}
+#ifdef __linux__
-
-struct virCapabilitiesFormatData {
+struct virCapabilitiesData {
const char *filename;
- int max_cells;
- int max_cpus_in_cell;
- int max_mem_in_cell;
+ virArch arch;
+ bool offlineMigrate;
+ bool liveMigrate;
};
static int
-test_virCapabilitiesFormat(const void *opaque)
+test_virCapabilities(const void *opaque)
{
- struct virCapabilitiesFormatData *data = (struct virCapabilitiesFormatData *) opaque;
+ struct virCapabilitiesData *data = (struct virCapabilitiesData *) opaque;
+ const char *archStr = virArchToString(data->arch);
virCapsPtr caps = NULL;
char *capsXML = NULL;
char *path = NULL;
+ char *dir = NULL;
int ret = -1;
- if (!(caps = buildVirCapabilities(data->max_cells, data->max_cpus_in_cell,
- data->max_mem_in_cell)))
+ if (virAsprintf(&dir, "%s/vircaps2xmldata/linux-%s",
+ abs_srcdir, data->filename) < 0)
+ goto cleanup;
+
+ virSysfsSetSystemPath(dir);
+ caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate);
+
+ if (!caps)
+ goto cleanup;
+
+ if (virCapabilitiesInitNUMA(caps) < 0)
goto cleanup;
+ virSysfsSetSystemPath(NULL);
+
if (!(capsXML = virCapabilitiesFormatXML(caps)))
goto cleanup;
- if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s.xml",
- abs_srcdir, data->filename) < 0)
+ if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s-%s.xml",
+ abs_srcdir, archStr, data->filename) < 0)
goto cleanup;
if (virTestCompareToFile(capsXML, path) < 0)
ret = 0;
cleanup:
+ VIR_FREE(dir);
VIR_FREE(path);
VIR_FREE(capsXML);
virObjectUnref(caps);
{
int ret = 0;
-#define DO_TEST(filename, max_cells, \
- max_cpus_in_cell, max_mem_in_cell) \
- do { \
- struct virCapabilitiesFormatData data = {filename, max_cells, \
- max_cpus_in_cell, \
- max_mem_in_cell}; \
- if (virTestRun(filename, test_virCapabilitiesFormat, &data) < 0) \
- ret = -1; \
+# define DO_TEST_FULL(filename, arch, offlineMigrate, liveMigrate) \
+ do { \
+ struct virCapabilitiesData data = {filename, arch, \
+ offlineMigrate, \
+ liveMigrate}; \
+ if (virTestRun(filename, test_virCapabilities, &data) < 0) \
+ ret = -1; \
} while (0)
- DO_TEST("basic-4-4-2G", 4, 4, 2*1024*1024);
+# define DO_TEST(filename, arch) DO_TEST_FULL(filename, arch, true, true)
+
+ DO_TEST_FULL("basic", VIR_ARCH_X86_64, false, false);
+ DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false);
+
+ DO_TEST("caches", VIR_ARCH_X86_64);
return ret;
}
-VIRT_TEST_MAIN(mymain)
+VIRT_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virnumamock.so")
+
+#else /* !__linux__ */
+
+int
+main(void)
+{
+ return EXIT_AM_SKIP;
+}
+
+#endif /* !__linux__ */