Skip to contentSkip to conversation

Fix RAPL MSR support in staging

PATCH New Anthony Harivel 1 participant 3 messages Jul 26, 2024

lore
Share & tools
lore
#0 lore raw

cover Fix RAPL MSR support in staging

Hi Paolo,

RAPL MSR has landed in staging with few scratches.

Here a couple of patches to solves CID 1558553 and 1558557.

Anthony

Anthony Harivel (2):
target/i386: Fix typo that assign same value twice target/i386: Clean output of vmsr_read_thread_stat()

 target/i386/kvm/kvm.c         | 4 ++--
 target/i386/kvm/vmsr_energy.c | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/2 target/i386: Fix typo that assign same value twice

Should fix: CID 1558553

---
 target/i386/kvm/kvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/kvm/kvm.c +2 -2
index b4aab9a410b5..31f149c9902c 100644
@@ -2694,8 +2694,8 @@ static void *kvm_msr_energy_thread(void *data)
 
     while (true) {
         /* Get all qemu threads id */
-        g_autofree pid_t *thread_ids =
-            thread_ids = vmsr_get_thread_ids(vmsr->pid, &num_threads);
+        g_autofree pid_t *thread_ids
+            = vmsr_get_thread_ids(vmsr->pid, &num_threads);
 
         if (thread_ids == NULL) {
             goto clean;
Signature · 1 line
2.45.2
#2 lore raw

PATCH 2/2 target/i386: Clean output of vmsr_read_thread_stat()

In reply to Anthony Harivel

Fix leaking memory of file handle in case of error Erase unused "pid = -1"
Add clearer error_report

Should fix: CID 1558557

---
 target/i386/kvm/vmsr_energy.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/kvm/vmsr_energy.c +3 -2
index a1d78f2f2aee..7e064c5aef30 100644
@@ -270,7 +270,7 @@ void vmsr_read_thread_stat(pid_t pid,
 
     FILE *file = fopen(path, "r");
     if (file == NULL) {
-        pid = -1;
+        error_report("Error opening %s", path_name);
         return;
     }
 
@@ -279,7 +279,8 @@ void vmsr_read_thread_stat(pid_t pid,
         " %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %*u %*u %u",
            utime, stime, cpu_id) != 3)
     {
-        pid = -1;
+        fclose(file);
+        error_report("Error fscanf did not report the right amount of items");
         return;
     }
 
Signature · 1 line
2.45.2