From: Jiri Denemark <[email protected]> This just makes the relevant part of virCPUx86GetHost reusable in other places.
Signed-off-by: Jiri Denemark <[email protected]> --- src/cpu/cpu_x86.c | 31 +++++++++++++++++++------------ src/cpu/cpu_x86.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 3a18d859dc..93f1427e36 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -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,23 @@ virCPUx86DataAdd(virCPUData *cpuData, } +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, diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h index 2cd965fea4..bbc2a16447 100644 --- a/src/cpu/cpu_x86.h +++ b/src/cpu/cpu_x86.h @@ -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, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 3653459ef1..9d5e927b8a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1598,6 +1598,7 @@ virCPUValidateFeatures; # cpu/cpu_x86.h virCPUx86DataAdd; +virCPUx86DataAddMSR; virCPUx86DataGetSignature; virCPUx86DataSetSignature; virCPUx86DataSetVendor; -- 2.54.0
