mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
cpu_x86: Implement virCPUDataGetHost for x86
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
19b52d952b
commit
773e956c2f
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#if WITH_LINUX_KVM_H
|
||||||
|
# include <linux/kvm.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "virlog.h"
|
#include "virlog.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
@ -3408,6 +3411,38 @@ virCPUx86DataIsIdentical(const virCPUData *a,
|
|||||||
return VIR_CPU_COMPARE_IDENTICAL;
|
return VIR_CPU_COMPARE_IDENTICAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WITH_LINUX_KVM_H && defined(KVM_GET_MSRS) && \
|
||||||
|
(defined(__i386__) || defined(__x86_64__)) && \
|
||||||
|
(defined(__linux__) || defined(__FreeBSD__))
|
||||||
|
static virCPUData *
|
||||||
|
virCPUx86DataGetHost(void)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
virCPUData *cpuid;
|
||||||
|
g_autofree struct kvm_cpuid2 *kvm_cpuid = NULL;
|
||||||
|
|
||||||
|
if ((kvm_cpuid = virHostCPUGetCPUID()) == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cpuid = virCPUDataNew(virArchFromHost());
|
||||||
|
cpuid->data.x86.len = kvm_cpuid->nent;
|
||||||
|
cpuid->data.x86.items = g_new0(virCPUx86DataItem, kvm_cpuid->nent);
|
||||||
|
|
||||||
|
for (i = 0; i < kvm_cpuid->nent; ++i) {
|
||||||
|
virCPUx86DataItem *item = &cpuid->data.x86.items[i];
|
||||||
|
item->type = VIR_CPU_X86_DATA_CPUID;
|
||||||
|
item->data.cpuid.eax_in = kvm_cpuid->entries[i].function;
|
||||||
|
item->data.cpuid.ecx_in = kvm_cpuid->entries[i].index;
|
||||||
|
item->data.cpuid.eax = kvm_cpuid->entries[i].eax;
|
||||||
|
item->data.cpuid.ebx = kvm_cpuid->entries[i].ebx;
|
||||||
|
item->data.cpuid.ecx = kvm_cpuid->entries[i].ecx;
|
||||||
|
item->data.cpuid.edx = kvm_cpuid->entries[i].edx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cpuid;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
virCPUx86FeatureIsMSR(const char *name)
|
virCPUx86FeatureIsMSR(const char *name)
|
||||||
{
|
{
|
||||||
@ -3493,4 +3528,9 @@ struct cpuArchDriver cpuDriverX86 = {
|
|||||||
.validateFeatures = virCPUx86ValidateFeatures,
|
.validateFeatures = virCPUx86ValidateFeatures,
|
||||||
.dataAddFeature = virCPUx86DataAddFeature,
|
.dataAddFeature = virCPUx86DataAddFeature,
|
||||||
.dataIsIdentical = virCPUx86DataIsIdentical,
|
.dataIsIdentical = virCPUx86DataIsIdentical,
|
||||||
|
#if WITH_LINUX_KVM_H && defined(KVM_GET_MSRS) && \
|
||||||
|
(defined(__i386__) || defined(__x86_64__)) && \
|
||||||
|
(defined(__linux__) || defined(__FreeBSD__))
|
||||||
|
.dataGetHost = virCPUx86DataGetHost,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user