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