1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00
libvirt/tests/vircaps2xmltest.c
Wang Huaqiang 6af8417415 conf: Introduce RDT monitor host capability
This patch is introducing cache monitor(CMT) to cache and
memory bandwidth monitor(MBM) for monitoring CPU memory
bandwidth.

The host capability of the two monitors is also introduced
in this patch.

For CMT, the host capability is shown like:
  <host>
  ...
    <cache>
      <bank id='0' level='3' type='both' size='15' unit='MiB' cpus='0-5'>
        <control granularity='768' min='1536' unit='KiB' type='both' maxAllocs='4'/>
      </bank>
      <monitor level='3' 'reuseThreshold'='270336' maxMonitors='176'>
        <feature name='llc_occupancy'/>
      </monitor>
    </cache>
    ...
  </host>

For MBM, the capability is shown like this:
  <host>
    ...
    <memory_bandwidth>
      <node id='1' cpus='6-11'>
        <control granularity='10' min ='10' maxAllocs='4'/>
      </node>
      <monitor maxMonitors='176'>
        <feature name='mbm_total_bytes'/>
        <feature name='mbm_local_bytes'/>
      </monitor>
    </memory_bandwidth>
    ...
  </host>

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-20 13:06:02 -04:00

123 lines
3.5 KiB
C

/*
* Copyright (C) Red Hat, Inc. 2014
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
* Authors:
* Michal Privoznik <mprivozn@redhat.com>
*/
#include <config.h>
#include "testutils.h"
#include "capabilities.h"
#include "virbitmap.h"
#include "virfilewrapper.h"
#define VIR_FROM_THIS VIR_FROM_NONE
struct virCapabilitiesData {
const char *filename;
virArch arch;
bool offlineMigrate;
bool liveMigrate;
};
static int
test_virCapabilities(const void *opaque)
{
struct virCapabilitiesData *data = (struct virCapabilitiesData *) opaque;
const char *archStr = virArchToString(data->arch);
virCapsPtr caps = NULL;
char *capsXML = NULL;
char *path = NULL;
char *system = NULL;
char *resctrl = NULL;
int ret = -1;
if (virAsprintf(&system, "%s/vircaps2xmldata/linux-%s/system",
abs_srcdir, data->filename) < 0)
goto cleanup;
if (virAsprintf(&resctrl, "%s/vircaps2xmldata/linux-%s/resctrl",
abs_srcdir, data->filename) < 0)
goto cleanup;
virFileWrapperAddPrefix("/sys/devices/system", system);
virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl);
caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate);
if (!caps)
goto cleanup;
if (virCapabilitiesInitNUMA(caps) < 0 ||
virCapabilitiesInitCaches(caps) < 0)
goto cleanup;
virFileWrapperClearPrefixes();
if (!(capsXML = virCapabilitiesFormatXML(caps)))
goto cleanup;
if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s-%s.xml",
abs_srcdir, archStr, data->filename) < 0)
goto cleanup;
if (virTestCompareToFile(capsXML, path) < 0)
goto cleanup;
ret = 0;
cleanup:
VIR_FREE(system);
VIR_FREE(resctrl);
VIR_FREE(path);
VIR_FREE(capsXML);
virObjectUnref(caps);
return ret;
}
static int
mymain(void)
{
int ret = 0;
#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_FULL("basic", VIR_ARCH_X86_64, false, false);
DO_TEST_FULL("basic", VIR_ARCH_AARCH64, true, false);
DO_TEST_FULL("caches", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-cmt", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-skx", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-skx-twocaches", VIR_ARCH_X86_64, true, true);
DO_TEST_FULL("resctrl-fake-feature", VIR_ARCH_X86_64, true, true);
return ret;
}
VIR_TEST_MAIN_PRELOAD(mymain, abs_builddir "/.libs/virnumamock.so")