|
|
0a7476 |
From dc61761ead7f2a196b97a36a51076a953461838f Mon Sep 17 00:00:00 2001
|
|
|
0a7476 |
Message-Id: <dc61761ead7f2a196b97a36a51076a953461838f@dist-git>
|
|
|
0a7476 |
From: Bing Niu <bing.niu@intel.com>
|
|
|
0a7476 |
Date: Mon, 15 Apr 2019 17:32:45 +0200
|
|
|
0a7476 |
Subject: [PATCH] util: Refactor virResctrlGetInfo in virresctrl
|
|
|
0a7476 |
MIME-Version: 1.0
|
|
|
0a7476 |
Content-Type: text/plain; charset=UTF-8
|
|
|
0a7476 |
Content-Transfer-Encoding: 8bit
|
|
|
0a7476 |
|
|
|
0a7476 |
Separate resctrl common information parts from CAT specific parts,
|
|
|
0a7476 |
so that common information parts can be reused among different
|
|
|
0a7476 |
resource allocation technologies.
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Bing Niu <bing.niu@intel.com>
|
|
|
0a7476 |
Reviewed-by: John Ferlan <jferlan@redhat.com>
|
|
|
0a7476 |
(cherry picked from commit 3a1356d461d6ad6ac2a0371827ceaba7de5f12c5)
|
|
|
0a7476 |
|
|
|
0a7476 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1468650
|
|
|
0a7476 |
|
|
|
0a7476 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
0a7476 |
Message-Id: <04b97c88620bd7f690d697932b2ff88af1f8e325.1555342313.git.phrdina@redhat.com>
|
|
|
0a7476 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
0a7476 |
---
|
|
|
0a7476 |
src/util/virresctrl.c | 32 +++++++++++++++++++++++---------
|
|
|
0a7476 |
1 file changed, 23 insertions(+), 9 deletions(-)
|
|
|
0a7476 |
|
|
|
0a7476 |
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
|
|
|
0a7476 |
index 6d69c8d4e2..313f964f21 100644
|
|
|
0a7476 |
--- a/src/util/virresctrl.c
|
|
|
0a7476 |
+++ b/src/util/virresctrl.c
|
|
|
0a7476 |
@@ -318,9 +318,9 @@ virResctrlUnlock(int fd)
|
|
|
0a7476 |
|
|
|
0a7476 |
/* virResctrlInfo-related definitions */
|
|
|
0a7476 |
static int
|
|
|
0a7476 |
-virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
|
|
0a7476 |
+virResctrlGetCacheInfo(virResctrlInfoPtr resctrl,
|
|
|
0a7476 |
+ DIR *dirp)
|
|
|
0a7476 |
{
|
|
|
0a7476 |
- DIR *dirp = NULL;
|
|
|
0a7476 |
char *endptr = NULL;
|
|
|
0a7476 |
char *tmp_str = NULL;
|
|
|
0a7476 |
int ret = -1;
|
|
|
0a7476 |
@@ -332,12 +332,6 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
|
|
0a7476 |
virResctrlInfoPerLevelPtr i_level = NULL;
|
|
|
0a7476 |
virResctrlInfoPerTypePtr i_type = NULL;
|
|
|
0a7476 |
|
|
|
0a7476 |
- rv = virDirOpenIfExists(&dirp, SYSFS_RESCTRL_PATH "/info");
|
|
|
0a7476 |
- if (rv <= 0) {
|
|
|
0a7476 |
- ret = rv;
|
|
|
0a7476 |
- goto cleanup;
|
|
|
0a7476 |
- }
|
|
|
0a7476 |
-
|
|
|
0a7476 |
while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
|
|
|
0a7476 |
VIR_DEBUG("Parsing info type '%s'", ent->d_name);
|
|
|
0a7476 |
if (ent->d_name[0] != 'L')
|
|
|
0a7476 |
@@ -443,12 +437,32 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
|
|
0a7476 |
|
|
|
0a7476 |
ret = 0;
|
|
|
0a7476 |
cleanup:
|
|
|
0a7476 |
- VIR_DIR_CLOSE(dirp);
|
|
|
0a7476 |
VIR_FREE(i_type);
|
|
|
0a7476 |
return ret;
|
|
|
0a7476 |
}
|
|
|
0a7476 |
|
|
|
0a7476 |
|
|
|
0a7476 |
+static int
|
|
|
0a7476 |
+virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
|
|
0a7476 |
+{
|
|
|
0a7476 |
+ DIR *dirp = NULL;
|
|
|
0a7476 |
+ int ret = -1;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ ret = virDirOpenIfExists(&dirp, SYSFS_RESCTRL_PATH "/info");
|
|
|
0a7476 |
+ if (ret <= 0)
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ ret = virResctrlGetCacheInfo(resctrl, dirp);
|
|
|
0a7476 |
+ if (ret < 0)
|
|
|
0a7476 |
+ goto cleanup;
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+ ret = 0;
|
|
|
0a7476 |
+ cleanup:
|
|
|
0a7476 |
+ VIR_DIR_CLOSE(dirp);
|
|
|
0a7476 |
+ return ret;
|
|
|
0a7476 |
+}
|
|
|
0a7476 |
+
|
|
|
0a7476 |
+
|
|
|
0a7476 |
virResctrlInfoPtr
|
|
|
0a7476 |
virResctrlInfoNew(void)
|
|
|
0a7476 |
{
|
|
|
0a7476 |
--
|
|
|
0a7476 |
2.21.0
|
|
|
0a7476 |
|