|
|
fbe740 |
From 781e82d0330afe60ab1c366e43dfe8292fcf68eb Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <781e82d0330afe60ab1c366e43dfe8292fcf68eb@dist-git>
|
|
|
fbe740 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Date: Tue, 26 May 2020 10:58:53 +0200
|
|
|
fbe740 |
Subject: [PATCH] cpu: Honor check='full' for host-passthrough CPUs
|
|
|
fbe740 |
MIME-Version: 1.0
|
|
|
fbe740 |
Content-Type: text/plain; charset=UTF-8
|
|
|
fbe740 |
Content-Transfer-Encoding: 8bit
|
|
|
fbe740 |
|
|
|
fbe740 |
The check attribute was completely ignored for host-passthrough CPUs
|
|
|
fbe740 |
even if they explicitly requested some features to be enabled. For
|
|
|
fbe740 |
example, a domain with the following CPU definition
|
|
|
fbe740 |
|
|
|
fbe740 |
<cpu mode='host-passthrough' check='full'>
|
|
|
fbe740 |
<feature policy='require' name='svm'/>
|
|
|
fbe740 |
</cpu>
|
|
|
fbe740 |
|
|
|
fbe740 |
would happily start even when 'svm' cannot be enabled.
|
|
|
fbe740 |
|
|
|
fbe740 |
Let's call virCPUArchUpdateLive for host-passthrough CPUs with
|
|
|
fbe740 |
VIR_CPU_CHECK_FULL to make sure the architecture specific code can
|
|
|
fbe740 |
validate the provided virtual CPU against the desired definition.
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1515677
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
(cherry picked from commit ac36a824641862dcac057c6403b27ab1e91874f5)
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1839999
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
Message-Id: <b8d30055a0df31c423d6c1832ca0bfbf3eafd222.1590483392.git.jdenemar@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/cpu/cpu.c | 3 ++-
|
|
|
fbe740 |
src/cpu/cpu_x86.c | 10 +++++++++-
|
|
|
fbe740 |
2 files changed, 11 insertions(+), 2 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
|
|
|
fbe740 |
index 1cb2dd04f4..f2a0f560f6 100644
|
|
|
fbe740 |
--- a/src/cpu/cpu.c
|
|
|
fbe740 |
+++ b/src/cpu/cpu.c
|
|
|
fbe740 |
@@ -647,7 +647,8 @@ virCPUUpdateLive(virArch arch,
|
|
|
fbe740 |
if (!driver->updateLive)
|
|
|
fbe740 |
return 1;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (cpu->mode == VIR_CPU_MODE_CUSTOM) {
|
|
|
fbe740 |
+ if (cpu->mode == VIR_CPU_MODE_CUSTOM ||
|
|
|
fbe740 |
+ cpu->check == VIR_CPU_CHECK_FULL) {
|
|
|
fbe740 |
if (driver->updateLive(cpu, dataEnabled, dataDisabled) < 0)
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
fbe740 |
index 9e686a86d2..8c865bdaa4 100644
|
|
|
fbe740 |
--- a/src/cpu/cpu_x86.c
|
|
|
fbe740 |
+++ b/src/cpu/cpu_x86.c
|
|
|
fbe740 |
@@ -3009,8 +3009,10 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
virCPUDataPtr dataEnabled,
|
|
|
fbe740 |
virCPUDataPtr dataDisabled)
|
|
|
fbe740 |
{
|
|
|
fbe740 |
+ bool hostPassthrough = cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH;
|
|
|
fbe740 |
virCPUx86MapPtr map;
|
|
|
fbe740 |
virCPUx86ModelPtr model = NULL;
|
|
|
fbe740 |
+ virCPUx86ModelPtr modelDisabled = NULL;
|
|
|
fbe740 |
virCPUx86Data enabled = VIR_CPU_X86_DATA_INIT;
|
|
|
fbe740 |
virCPUx86Data disabled = VIR_CPU_X86_DATA_INIT;
|
|
|
fbe740 |
virBuffer bufAdded = VIR_BUFFER_INITIALIZER;
|
|
|
fbe740 |
@@ -3026,6 +3028,10 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
if (!(model = x86ModelFromCPU(cpu, map, -1)))
|
|
|
fbe740 |
goto cleanup;
|
|
|
fbe740 |
|
|
|
fbe740 |
+ if (hostPassthrough &&
|
|
|
fbe740 |
+ !(modelDisabled = x86ModelFromCPU(cpu, map, VIR_CPU_FEATURE_DISABLE)))
|
|
|
fbe740 |
+ goto cleanup;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
if (dataEnabled &&
|
|
|
fbe740 |
x86DataCopy(&enabled, &dataEnabled->data.x86) < 0)
|
|
|
fbe740 |
goto cleanup;
|
|
|
fbe740 |
@@ -3040,7 +3046,8 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
|
|
|
fbe740 |
if (x86DataIsSubset(&model->data, &feature->data))
|
|
|
fbe740 |
expected = VIR_CPU_FEATURE_REQUIRE;
|
|
|
fbe740 |
- else
|
|
|
fbe740 |
+ else if (!hostPassthrough ||
|
|
|
fbe740 |
+ x86DataIsSubset(&modelDisabled->data, &feature->data))
|
|
|
fbe740 |
expected = VIR_CPU_FEATURE_DISABLE;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (expected == VIR_CPU_FEATURE_DISABLE &&
|
|
|
fbe740 |
@@ -3101,6 +3108,7 @@ virCPUx86UpdateLive(virCPUDefPtr cpu,
|
|
|
fbe740 |
|
|
|
fbe740 |
cleanup:
|
|
|
fbe740 |
x86ModelFree(model);
|
|
|
fbe740 |
+ x86ModelFree(modelDisabled);
|
|
|
fbe740 |
virCPUx86DataClear(&enabled);
|
|
|
fbe740 |
virCPUx86DataClear(&disabled);
|
|
|
fbe740 |
VIR_FREE(added);
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.26.2
|
|
|
fbe740 |
|