[libvirt] [PATCH V2 1/2] util: Add more virsysfs functions for handling resctrl sysfs

Extended /sys/fs/resctrl sysfs handling. Signed-off-by: Eli Qiao <liyong.qiao@intel.com> --- src/libvirt_private.syms | 11 ++++- src/util/virsysfs.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++- src/util/virsysfs.h | 16 ++++++++ src/util/virsysfspriv.h | 1 + 4 files changed, 128 insertions(+), 2 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b551cb8..b03ad5b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2388,6 +2388,10 @@ virRandomGenerateWWN; virRandomInt; +# util/virresctrl.h +virResCtrlAvailable; +virResCtrlInit; + # util/virrotatingfile.h virRotatingFileReaderConsume; virRotatingFileReaderFree; @@ -2626,13 +2630,18 @@ virSysfsGetCpuValueString; virSysfsGetCpuValueUint; virSysfsGetNodeValueBitmap; virSysfsGetNodeValueString; +virSysfsGetResctrlInfoString; +virSysfsGetResctrlInfoUint; +virSysfsGetResctrlPath; +virSysfsGetResctrlString; +virSysfsGetResctrlUint; virSysfsGetSystemPath; virSysfsGetValueBitmap; virSysfsGetValueInt; virSysfsGetValueString; +virSysfsSetResctrlPath; virSysfsSetSystemPath; - # util/virsysinfo.h virSysinfoBaseBoardDefClear; virSysinfoBIOSDefFree; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 7a98b48..97808be 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c @@ -36,8 +36,10 @@ VIR_LOG_INIT("util.sysfs"); #define VIR_SYSFS_VALUE_MAXLEN 8192 #define SYSFS_SYSTEM_PATH "/sys/devices/system" +#define SYSFS_RESCTRL_PATH "/sys/fs/resctrl" static const char *sysfs_system_path = SYSFS_SYSTEM_PATH; +static const char *sysfs_resctrl_path = SYSFS_RESCTRL_PATH; void virSysfsSetSystemPath(const char *path) @@ -48,13 +50,26 @@ void virSysfsSetSystemPath(const char *path) sysfs_system_path = SYSFS_SYSTEM_PATH; } - const char * virSysfsGetSystemPath(void) { return sysfs_system_path; } +void virSysfsSetResctrlPath(const char *path) +{ + if (path) + sysfs_resctrl_path = path; + else + sysfs_resctrl_path = SYSFS_RESCTRL_PATH; +} + +const char * +virSysfsGetResctrlPath(void) +{ + return sysfs_resctrl_path; +} + int virSysfsGetValueInt(const char *file, int *value) @@ -227,3 +242,88 @@ virSysfsGetNodeValueBitmap(unsigned int node, VIR_FREE(path); return ret; } + +int +virSysfsGetResctrlString(const char* file, + char **value) +{ + char *path = NULL; + int ret = -1; + if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0) + return -1; + + if (!virFileExists(path)) { + ret = -2; + goto cleanup; + } + + if (virFileReadAll(path, VIR_SYSFS_VALUE_MAXLEN, value) < 0) + goto cleanup; + + ret = 0; + + cleanup: + VIR_FREE(path); + return ret; +} + +int +virSysfsGetResctrlUint(const char* file, + unsigned int *value) +{ + char *path = NULL; + int ret = -1; + if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0) + return -1; + + if (!virFileExists(path)) { + ret = -2; + goto cleanup; + } + + ret = virFileReadValueUint(path, value); + + cleanup: + VIR_FREE(path); + return ret; +} + +int +virSysfsGetResctrlInfoString(const char* file, + char **value) +{ + char *path = NULL; + int ret = -1; + if (virAsprintf(&path, "%s/info/%s", sysfs_resctrl_path, file) < 0) + return -1; + + if (!virFileExists(path)) { + ret = -2; + goto cleanup; + } + + if (virFileReadAll(path, VIR_SYSFS_VALUE_MAXLEN, value) < 0) + goto cleanup; + + ret = 0; + + cleanup: + VIR_FREE(path); + return ret; +} + +int +virSysfsGetResctrlInfoUint(const char *file, + unsigned int *value) +{ + char *path = NULL; + int ret = -1; + + if (virAsprintf(&path, "%s/info/%s", sysfs_resctrl_path, file) < 0) + return -1; + + ret = virFileReadValueUint(path, value); + + VIR_FREE(path); + return ret; +} diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h index cd871ff..af1e786 100644 --- a/src/util/virsysfs.h +++ b/src/util/virsysfs.h @@ -25,6 +25,7 @@ # include "virbitmap.h" const char * virSysfsGetSystemPath(void); +const char * virSysfsGetResctrlPath(void); int virSysfsGetValueInt(const char *file, @@ -67,4 +68,19 @@ virSysfsGetNodeValueBitmap(unsigned int cpu, const char *file, virBitmapPtr *value); +int +virSysfsGetResctrlString(const char* file, + char **value); + +int +virSysfsGetResctrlUint(const char* file, + unsigned int *value); + +int +virSysfsGetResctrlInfoString(const char* file, + char **value); + +int +virSysfsGetResctrlInfoUint(const char *file, + unsigned int *value); #endif /* __VIR_SYSFS_H__*/ diff --git a/src/util/virsysfspriv.h b/src/util/virsysfspriv.h index ae9f54a..bf36082 100644 --- a/src/util/virsysfspriv.h +++ b/src/util/virsysfspriv.h @@ -24,5 +24,6 @@ # include "virsysfs.h" void virSysfsSetSystemPath(const char *path); +void virSysfsSetResctrlPath(const char *path); #endif /* __VIR_SYSFS_PRIV_H__*/ -- 1.9.1

Added fake cpu cache id and resctrl file Signed-off-by: Eli Qiao <liyong.qiao@intel.com> --- tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id | 1 + tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id | 1 + tests/vircaps2xmldata/linux-resctrl/cpus | 1 + tests/vircaps2xmldata/linux-resctrl/info/L3/cbm_mask | 1 + tests/vircaps2xmldata/linux-resctrl/info/L3/min_cbm_bits | 1 + tests/vircaps2xmldata/linux-resctrl/info/L3/num_closids | 1 + tests/vircaps2xmldata/linux-resctrl/schemata | 1 + tests/vircaps2xmldata/linux-resctrl/tasks | 2 ++ 38 files changed, 39 insertions(+) create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id create mode 100644 tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id create mode 100644 tests/vircaps2xmldata/linux-resctrl/cpus create mode 100644 tests/vircaps2xmldata/linux-resctrl/info/L3/cbm_mask create mode 100644 tests/vircaps2xmldata/linux-resctrl/info/L3/min_cbm_bits create mode 100644 tests/vircaps2xmldata/linux-resctrl/info/L3/num_closids create mode 100644 tests/vircaps2xmldata/linux-resctrl/schemata create mode 100644 tests/vircaps2xmldata/linux-resctrl/tasks diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index0/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index1/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index2/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu0/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index0/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index1/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index2/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu1/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index0/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index1/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index2/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu2/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index0/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index1/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index2/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu3/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index0/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index1/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index2/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu4/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index0/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index1/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index2/id @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu5/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index0/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index1/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index2/id @@ -0,0 +1 @@ +2 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu6/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index0/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index1/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index2/id @@ -0,0 +1 @@ +3 diff --git a/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/vircaps2xmldata/linux-caches/cpu/cpu7/cache/index3/id @@ -0,0 +1 @@ +0 diff --git a/tests/vircaps2xmldata/linux-resctrl/cpus b/tests/vircaps2xmldata/linux-resctrl/cpus new file mode 100644 index 0000000..b3a79aa --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl/cpus @@ -0,0 +1 @@ +ffffff,ffffffff,ffffffff diff --git a/tests/vircaps2xmldata/linux-resctrl/info/L3/cbm_mask b/tests/vircaps2xmldata/linux-resctrl/info/L3/cbm_mask new file mode 100644 index 0000000..78031da --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl/info/L3/cbm_mask @@ -0,0 +1 @@ +fffff diff --git a/tests/vircaps2xmldata/linux-resctrl/info/L3/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl/info/L3/min_cbm_bits new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl/info/L3/min_cbm_bits @@ -0,0 +1 @@ +1 diff --git a/tests/vircaps2xmldata/linux-resctrl/info/L3/num_closids b/tests/vircaps2xmldata/linux-resctrl/info/L3/num_closids new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl/info/L3/num_closids @@ -0,0 +1 @@ +16 diff --git a/tests/vircaps2xmldata/linux-resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl/schemata new file mode 100644 index 0000000..95bf1be --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl/schemata @@ -0,0 +1 @@ +L3:0=fffff;1=fffff diff --git a/tests/vircaps2xmldata/linux-resctrl/tasks b/tests/vircaps2xmldata/linux-resctrl/tasks new file mode 100644 index 0000000..1191247 --- /dev/null +++ b/tests/vircaps2xmldata/linux-resctrl/tasks @@ -0,0 +1,2 @@ +1 +2 -- 1.9.1

On Thu, Mar 30, 2017 at 04:07:11PM +0800, Eli Qiao wrote:
Extended /sys/fs/resctrl sysfs handling.
Signed-off-by: Eli Qiao <liyong.qiao@intel.com> --- src/libvirt_private.syms | 11 ++++- src/util/virsysfs.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++- src/util/virsysfs.h | 16 ++++++++ src/util/virsysfspriv.h | 1 + 4 files changed, 128 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b551cb8..b03ad5b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2388,6 +2388,10 @@ virRandomGenerateWWN; virRandomInt;
+# util/virresctrl.h +virResCtrlAvailable; +virResCtrlInit; +
This has nothing to do in the patch
# util/virrotatingfile.h virRotatingFileReaderConsume; virRotatingFileReaderFree; @@ -2626,13 +2630,18 @@ virSysfsGetCpuValueString; virSysfsGetCpuValueUint; virSysfsGetNodeValueBitmap; virSysfsGetNodeValueString; +virSysfsGetResctrlInfoString; +virSysfsGetResctrlInfoUint; +virSysfsGetResctrlPath; +virSysfsGetResctrlString; +virSysfsGetResctrlUint; virSysfsGetSystemPath; virSysfsGetValueBitmap; virSysfsGetValueInt; virSysfsGetValueString; +virSysfsSetResctrlPath; virSysfsSetSystemPath;
-
Don't remove the line. Every time you are doing a change in the code (and I mean any code), try being consistent. If the code follows some style, don't fight it, but go with it. Not everything can be written in the coding style. As you can see here, all files are separated by two lines. When you remove this, you make the file inconsistent. Also, I mentioned many times before that you should run make check and make syntax-check between patches, and I'm sure our contribution guidelines mention that make check must pass between patches. This change should not pass the checks. It's fine every now and then, we all forget, but I'm trying to run make check and make syntax-check after each patch before sending it. Useful command to use from your topic branch is something along the lines of: git rebase -ix 'make -j9 check && make -j9 syntax-check' master (written by hand from memory, there might be typo, I have a script and bunch of aliases for that)
# util/virsysinfo.h virSysinfoBaseBoardDefClear; virSysinfoBIOSDefFree; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 7a98b48..97808be 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c
[...]
@@ -227,3 +242,88 @@ virSysfsGetNodeValueBitmap(unsigned int node, VIR_FREE(path); return ret; } + +int +virSysfsGetResctrlString(const char* file,
'char *file' instead of 'char* file'
+ char **value) +{ + char *path = NULL; + int ret = -1; + if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0) + return -1; + + if (!virFileExists(path)) { + ret = -2; + goto cleanup; + } +
Now the question is; is it possible for some file to be missing there? I mean some file we'd expect? For the system path, the -2 return value is there because we need to work on older systems with older kernels and the files were being added in multiple releases. If there is no need for distinguishing that, then there is no point in explicitly checking for the file to be existing. And that leads me to another point. Since this patch is by itself, it's not visible how it is used. It looks good (not considering the things pointed out above), but there is no point in merging it until there is a value added. It's just added dead code. But it's something that we'll use, surely. Martin P.S.: I just sent [1] the next couple of patches (again, first ones are just fixing some bullocks I found out that were left in the code -- that just happens when you're working on a codebase with lots of legacy code), but it adds host cache information to the capabilities. If you have a minute or two, feel free to check it out and let me know what you think. [1] https://www.redhat.com/archives/libvir-list/2017-March/msg01592.html

+# util/virresctrl.h +virResCtrlAvailable; +virResCtrlInit; +
This has nothing to do in the patch
Okay, this should be involved by mistake while rebasing.
# util/virrotatingfile.h virRotatingFileReaderConsume; virRotatingFileReaderFree; @@ -2626,13 +2630,18 @@ virSysfsGetCpuValueString; virSysfsGetCpuValueUint; virSysfsGetNodeValueBitmap; virSysfsGetNodeValueString; +virSysfsGetResctrlInfoString; +virSysfsGetResctrlInfoUint; +virSysfsGetResctrlPath; +virSysfsGetResctrlString; +virSysfsGetResctrlUint; virSysfsGetSystemPath; virSysfsGetValueBitmap; virSysfsGetValueInt; virSysfsGetValueString; +virSysfsSetResctrlPath; virSysfsSetSystemPath;
-
Don't remove the line. Every time you are doing a change in the code (and I mean any code), try being consistent. If the code follows some style, don't fight it, but go with it. Not everything can be written in the coding style. As you can see here, all files are separated by two lines. When you remove this, you make the file inconsistent.
Also, I mentioned many times before that you should run make check and make syntax-check between patches, and I'm sure our contribution guidelines mention that make check must pass between patches. This change should not pass the checks. It's fine every now and then, we all forget, but I'm trying to run make check and make syntax-check after each patch before sending it. Useful command to use from your topic branch is something along the lines of:
git rebase -ix 'make -j9 check && make -j9 syntax-check' master (written by hand from memory, there might be typo, I have a script and bunch of aliases for that)
Sure, Daniel had reminded me before, I missed it this time, will keep in mind next path.
# util/virsysinfo.h virSysinfoBaseBoardDefClear; virSysinfoBIOSDefFree; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 7a98b48..97808be 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c
[...]
@@ -227,3 +242,88 @@ virSysfsGetNodeValueBitmap(unsigned int node, VIR_FREE(path); return ret; } + +int +virSysfsGetResctrlString(const char* file,
'char *file' instead of 'char* file'
+ char **value) +{ + char *path = NULL; + int ret = -1; + if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0) + return -1; + + if (!virFileExists(path)) { + ret = -2; + goto cleanup; + } +
Now the question is; is it possible for some file to be missing there? I mean some file we'd expect? For the system path, the -2 return value is there because we need to work on older systems with older kernels and the files were being added in multiple releases. If there is no need for distinguishing that, then there is no point in explicitly checking for the file to be existing.
No, we won’t expect file doesn’t existed. I will remove this checking
And that leads me to another point. Since this patch is by itself, it's not visible how it is used. It looks good (not considering the things pointed out above), but there is no point in merging it until there is a value added. It's just added dead code. But it's something that we'll use, surely.
Okay, I can add this patch to CAT supporting patch set as the first patch.
Martin
P.S.: I just sent [1] the next couple of patches (again, first ones are just fixing some bullocks I found out that were left in the code -- that just happens when you're working on a codebase with lots of legacy code), but it adds host cache information to the capabilities. If you have a minute or two, feel free to check it out and let me know what you think.
Sure, I see you have added fake cache id, that’s good, I can drop it.
[1] https://www.redhat.com/archives/libvir-list/2017-March/msg01592.html
I have one propose, not sure it’s a good or bad one: I would like to suggest that let the developer keep focus on adding features, then refactor some uitls functions later, developers won’t have all knowledge for what’s the function should be go into which utils, and this will bring time wasting on keeping rebasing rebasing …… - Eli
-- libvir-list mailing list libvir-list@redhat.com (mailto:libvir-list@redhat.com) https://www.redhat.com/mailman/listinfo/libvir-list

On Fri, Mar 31, 2017 at 09:26:34AM +0800, Eli Qiao wrote:
+# util/virresctrl.h +virResCtrlAvailable; +virResCtrlInit; +
This has nothing to do in the patch
Okay, this should be involved by mistake while rebasing.
# util/virrotatingfile.h virRotatingFileReaderConsume; virRotatingFileReaderFree; @@ -2626,13 +2630,18 @@ virSysfsGetCpuValueString; virSysfsGetCpuValueUint; virSysfsGetNodeValueBitmap; virSysfsGetNodeValueString; +virSysfsGetResctrlInfoString; +virSysfsGetResctrlInfoUint; +virSysfsGetResctrlPath; +virSysfsGetResctrlString; +virSysfsGetResctrlUint; virSysfsGetSystemPath; virSysfsGetValueBitmap; virSysfsGetValueInt; virSysfsGetValueString; +virSysfsSetResctrlPath; virSysfsSetSystemPath;
-
Don't remove the line. Every time you are doing a change in the code (and I mean any code), try being consistent. If the code follows some style, don't fight it, but go with it. Not everything can be written in the coding style. As you can see here, all files are separated by two lines. When you remove this, you make the file inconsistent.
Also, I mentioned many times before that you should run make check and make syntax-check between patches, and I'm sure our contribution guidelines mention that make check must pass between patches. This change should not pass the checks. It's fine every now and then, we all forget, but I'm trying to run make check and make syntax-check after each patch before sending it. Useful command to use from your topic branch is something along the lines of:
git rebase -ix 'make -j9 check && make -j9 syntax-check' master (written by hand from memory, there might be typo, I have a script and bunch of aliases for that)
Sure, Daniel had reminded me before, I missed it this time, will keep in mind next path.
# util/virsysinfo.h virSysinfoBaseBoardDefClear; virSysinfoBIOSDefFree; diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c index 7a98b48..97808be 100644 --- a/src/util/virsysfs.c +++ b/src/util/virsysfs.c
[...]
@@ -227,3 +242,88 @@ virSysfsGetNodeValueBitmap(unsigned int node, VIR_FREE(path); return ret; } + +int +virSysfsGetResctrlString(const char* file,
'char *file' instead of 'char* file'
+ char **value) +{ + char *path = NULL; + int ret = -1; + if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0) + return -1; + + if (!virFileExists(path)) { + ret = -2; + goto cleanup; + } +
Now the question is; is it possible for some file to be missing there? I mean some file we'd expect? For the system path, the -2 return value is there because we need to work on older systems with older kernels and the files were being added in multiple releases. If there is no need for distinguishing that, then there is no point in explicitly checking for the file to be existing.
No, we won’t expect file doesn’t existed. I will remove this checking
And that leads me to another point. Since this patch is by itself, it's not visible how it is used. It looks good (not considering the things pointed out above), but there is no point in merging it until there is a value added. It's just added dead code. But it's something that we'll use, surely.
Okay, I can add this patch to CAT supporting patch set as the first patch.
Martin
P.S.: I just sent [1] the next couple of patches (again, first ones are just fixing some bullocks I found out that were left in the code -- that just happens when you're working on a codebase with lots of legacy code), but it adds host cache information to the capabilities. If you have a minute or two, feel free to check it out and let me know what you think.
Sure, I see you have added fake cache id, that’s good, I can drop it.
[1] https://www.redhat.com/archives/libvir-list/2017-March/msg01592.html
I have one propose, not sure it’s a good or bad one:
I would like to suggest that let the developer keep focus on adding features, then refactor some uitls functions later, developers won’t have all knowledge for what’s the function should be go into which utils, and this will bring time wasting on keeping rebasing rebasing ……
I'm not sure I understand the whole sentence (paragraph). Everyone can add functionality, but not many people re refactor code. And if we only add functionality, the code will become unreadable and unbearable to work with. I can skip the trivial patches on top, but I can also just push them as trivial. Maybe I misunderstood what you were saying, please explain what you mean in case I misunderstood.
- Eli
-- libvir-list mailing list libvir-list@redhat.com (mailto:libvir-list@redhat.com) https://www.redhat.com/mailman/listinfo/libvir-list
participants (3)
-
Eli Qiao
-
Eli Qiao
-
Martin Kletzander