a3bc25
From 9d41cae9942d2909be00261b3ae2a2e1ec717808 Mon Sep 17 00:00:00 2001
a3bc25
Message-Id: <9d41cae9942d2909be00261b3ae2a2e1ec717808@dist-git>
a3bc25
From: Jiri Denemark <jdenemar@redhat.com>
a3bc25
Date: Tue, 11 Jul 2017 13:26:12 +0200
a3bc25
Subject: [PATCH] qemu: Add qemuProcessVerifyCPU
a3bc25
a3bc25
Separated from qemuProcessUpdateLiveGuestCPU. The function makes sure
a3bc25
a guest CPU provides all features required by a domain definition.
a3bc25
a3bc25
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a3bc25
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
a3bc25
(cherry picked from commit 5cac2fe108f957b2629a29bea1747fdb3c8d7aa3)
a3bc25
a3bc25
https://bugzilla.redhat.com/show_bug.cgi?id=1470582
a3bc25
a3bc25
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a3bc25
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
a3bc25
---
a3bc25
 src/qemu/qemu_process.c | 35 ++++++++++++++++++++++++++++-------
a3bc25
 1 file changed, 28 insertions(+), 7 deletions(-)
a3bc25
a3bc25
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
a3bc25
index d3fa8ef41e..3f7a9f4c02 100644
a3bc25
--- a/src/qemu/qemu_process.c
a3bc25
+++ b/src/qemu/qemu_process.c
a3bc25
@@ -3946,6 +3946,31 @@ qemuProcessFetchGuestCPU(virQEMUDriverPtr driver,
a3bc25
 
a3bc25
 
a3bc25
 static int
a3bc25
+qemuProcessVerifyCPU(virDomainObjPtr vm,
a3bc25
+                     virCPUDataPtr cpu)
a3bc25
+{
a3bc25
+    virDomainDefPtr def = vm->def;
a3bc25
+
a3bc25
+    if (!cpu)
a3bc25
+        return 0;
a3bc25
+
a3bc25
+    if (qemuProcessVerifyKVMFeatures(def, cpu) < 0 ||
a3bc25
+        qemuProcessVerifyHypervFeatures(def, cpu) < 0)
a3bc25
+        return -1;
a3bc25
+
a3bc25
+    if (!def->cpu ||
a3bc25
+        (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
a3bc25
+         !def->cpu->model))
a3bc25
+        return 0;
a3bc25
+
a3bc25
+    if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
a3bc25
+        return -1;
a3bc25
+
a3bc25
+    return 0;
a3bc25
+}
a3bc25
+
a3bc25
+
a3bc25
+static int
a3bc25
 qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
a3bc25
                               virDomainObjPtr vm,
a3bc25
                               qemuDomainAsyncJob asyncJob)
a3bc25
@@ -3961,11 +3986,10 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
a3bc25
     if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
a3bc25
         goto cleanup;
a3bc25
 
a3bc25
-    if (cpu) {
a3bc25
-        if (qemuProcessVerifyKVMFeatures(def, cpu) < 0 ||
a3bc25
-            qemuProcessVerifyHypervFeatures(def, cpu) < 0)
a3bc25
-            goto cleanup;
a3bc25
+    if (qemuProcessVerifyCPU(vm, cpu) < 0)
a3bc25
+        goto cleanup;
a3bc25
 
a3bc25
+    if (cpu) {
a3bc25
         if (!def->cpu ||
a3bc25
             (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
a3bc25
              !def->cpu->model)) {
a3bc25
@@ -3973,9 +3997,6 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
a3bc25
             goto cleanup;
a3bc25
         }
a3bc25
 
a3bc25
-        if (qemuProcessVerifyCPUFeatures(def, cpu) < 0)
a3bc25
-            goto cleanup;
a3bc25
-
a3bc25
         if (!(orig = virCPUDefCopy(def->cpu)))
a3bc25
             goto cleanup;
a3bc25
 
a3bc25
-- 
a3bc25
2.13.2
a3bc25