cpu_x86: Introduce virCPUx86DataAddMSR

This just makes the relevant part of virCPUx86GetHost reusable in other
places.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Jiri Denemark committed 2026-06-02 13:45:26 +02:00
1 parent 3184289356
commit a8952076d8
3 files changed
+33 -12

No files matched your search

+28 -12
View File
@@ -2911,18 +2911,8 @@ virCPUx86GetHost(virCPUDef *cpu,
/* This is best effort since there might be no way to read the MSR
* when we are not running as root. */
for (i = 0; i < nmsrs; i++) {
if (virHostCPUGetMSR(msrs[i], &msr) == 0) {
virCPUx86DataItem item = {
.type = VIR_CPU_X86_DATA_MSR,
.data.msr = {
.index = msrs[i],
.eax = msr & 0xffffffff,
.edx = msr >> 32,
},
};
virCPUx86DataAdd(cpuData, &item);
}
if (virHostCPUGetMSR(msrs[i], &msr) == 0)
virCPUx86DataAddMSR(cpuData, msrs[i], msr);
}
ret = x86DecodeCPUData(cpu, cpuData, models);
@@ -3460,6 +3450,32 @@ virCPUx86DataAdd(virCPUData *cpuData,
}
/**
* virCPUx86DataAddMSR:
* @cpuData: CPU data to update
* @index: MSR index
* @value: content of the @index MSR
*
* Adds the specified MSR content to CPU data.
*/
void
virCPUx86DataAddMSR(virCPUData *cpuData,
uint32_t index,
uint64_t value)
{
virCPUx86DataItem item = {
.type = VIR_CPU_X86_DATA_MSR,
.data.msr = {
.index = index,
.eax = value & 0xffffffff,
.edx = value >> 32,
},
};
virCPUx86DataAdd(cpuData, &item);
}
void
virCPUx86DataSetSignature(virCPUData *cpuData,
unsigned int family,
+4
View File
@@ -28,6 +28,10 @@ extern struct cpuArchDriver cpuDriverX86;
void virCPUx86DataAdd(virCPUData *cpuData,
const virCPUx86DataItem *cpuid);
void virCPUx86DataAddMSR(virCPUData *cpuData,
uint32_t index,
uint64_t value);
void virCPUx86DataSetSignature(virCPUData *cpuData,
unsigned int family,
unsigned int model,
+1
View File
@@ -1599,6 +1599,7 @@ virCPUValidateFeatures;
# cpu/cpu_x86.h
virCPUx86DataAdd;
virCPUx86DataAddMSR;
virCPUx86DataGetSignature;
virCPUx86DataSetSignature;
virCPUx86DataSetVendor;