1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

xenconfig: do not override def->cpu if already set elsewhere

This will help with adding cpuid support.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Marek Marczykowski-Górecki 2018-04-12 03:03:23 +02:00 committed by Jim Fehlig
parent c686f67f9c
commit 69eded56b8

View File

@ -170,17 +170,8 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
if (xenConfigGetBool(conf, "nestedhvm", &val, -1) < 0)
return -1;
if (val == 1) {
virCPUDefPtr cpu;
if (VIR_ALLOC(cpu) < 0)
return -1;
cpu->mode = VIR_CPU_MODE_HOST_PASSTHROUGH;
cpu->type = VIR_CPU_TYPE_GUEST;
def->cpu = cpu;
} else if (val == 0) {
const char *vtfeature = NULL;
if (val != -1) {
const char *vtfeature = "vmx";
if (caps && caps->host.cpu && ARCH_IS_X86(def->os.arch)) {
if (virCPUCheckFeature(caps->host.arch, caps->host.cpu, "vmx"))
@ -189,28 +180,24 @@ xenParseXLOS(virConfPtr conf, virDomainDefPtr def, virCapsPtr caps)
vtfeature = "svm";
}
if (vtfeature) {
if (!def->cpu) {
virCPUDefPtr cpu;
if (VIR_ALLOC(cpu) < 0)
return -1;
if (VIR_ALLOC(cpu->features) < 0) {
VIR_FREE(cpu);
return -1;
}
if (VIR_STRDUP(cpu->features->name, vtfeature) < 0) {
VIR_FREE(cpu->features);
VIR_FREE(cpu);
return -1;
}
cpu->features->policy = VIR_CPU_FEATURE_DISABLE;
cpu->nfeatures = cpu->nfeatures_max = 1;
cpu->mode = VIR_CPU_MODE_HOST_PASSTHROUGH;
cpu->type = VIR_CPU_TYPE_GUEST;
cpu->nfeatures = 0;
cpu->nfeatures_max = 0;
def->cpu = cpu;
}
if (val == 0) {
if (virCPUDefAddFeature(def->cpu,
vtfeature,
VIR_CPU_FEATURE_DISABLE) < 0)
return -1;
}
}
} else {
if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0)