[libvirt PATCH 05/16] qemu: taint the VM if it is using a deprecated CPU model

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 17 +++++++++++++++++
 src/qemu/qemu_capabilities.h |  3 +++
 src/qemu/qemu_domain.c       | 37 ++++++++++++++++++++++++++++++++----
 3 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e3d1de0779..f6d7a222c4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2437,6 +2437,23 @@ virQEMUCapsGetMachineDefaultCPU(virQEMUCapsPtr qemuCaps,
 }
 
 
+bool
+virQEMUCapsIsCPUDeprecated(virQEMUCapsPtr qemuCaps,
+                           virDomainVirtType type,
+                           const char *model)
+{
+    virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, type);
+    qemuMonitorCPUDefsPtr defs = accel->cpuModels;
+    size_t i;
+
+    for (i = 0; i < defs->ncpus; i++) {
+        if (STREQ_NULLABLE(defs->cpus[i].name, model))
+            return defs->cpus[i].deprecated;
+    }
+    return false;
+}
+
+
 bool
 virQEMUCapsGetMachineNumaMemSupported(virQEMUCapsPtr qemuCaps,
                                       virDomainVirtType virtType,
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index a14a78f959..a6270edb0e 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -686,6 +686,9 @@ bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
 const char *virQEMUCapsGetMachineDefaultCPU(virQEMUCapsPtr qemuCaps,
                                             const char *name,
                                             virDomainVirtType type);
+bool virQEMUCapsIsCPUDeprecated(virQEMUCapsPtr qemuCaps,
+                                virDomainVirtType type,
+                                const char *model);
 bool virQEMUCapsGetMachineNumaMemSupported(virQEMUCapsPtr qemuCaps,
                                            virDomainVirtType virtType,
                                            const char *name);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e63bea8b32..ed5fd6aa0d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6243,6 +6243,37 @@ void qemuDomainObjTaintMsg(virQEMUDriverPtr driver,
     virErrorRestore(&orig_err);
 }
 
+static void
+qemuDomainObjCheckCPUTaint(virQEMUDriverPtr driver,
+                           virDomainObjPtr obj,
+                           qemuDomainLogContextPtr logCtxt,
+                           bool incomingMigration)
+{
+    qemuDomainObjPrivatePtr priv = obj->privateData;
+    virQEMUCapsPtr qemuCaps = priv->qemuCaps;
+
+    switch (obj->def->cpu->mode) {
+    case VIR_CPU_MODE_HOST_PASSTHROUGH:
+        if (incomingMigration)
+            qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HOST_CPU, logCtxt);
+        break;
+    case VIR_CPU_MODE_CUSTOM:
+        if (obj->def->cpu->model &&
+            virQEMUCapsIsCPUDeprecated(qemuCaps,
+                                       obj->def->virtType,
+                                       obj->def->cpu->model)) {
+            qemuDomainObjTaintMsg(driver, obj, VIR_DOMAIN_TAINT_DEPRECATED_CONFIG, logCtxt,
+                                  _("CPU model '%s'"),
+                                  obj->def->cpu->model);
+        }
+        break;
+    case VIR_CPU_MODE_HOST_MODEL:
+    case VIR_CPU_MODE_LAST:
+    default:
+        break;
+    }
+}
+
 
 void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
                              virDomainObjPtr obj,
@@ -6276,10 +6307,8 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
                            VIR_DOMAIN_TAINT_CUSTOM_HYPERVISOR_FEATURE, logCtxt);
     }
 
-    if (obj->def->cpu &&
-        obj->def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH &&
-        incomingMigration)
-        qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HOST_CPU, logCtxt);
+    if (obj->def->cpu)
+        qemuDomainObjCheckCPUTaint(driver, obj, logCtxt, incomingMigration);
 
     for (i = 0; i < obj->def->ndisks; i++)
         qemuDomainObjCheckDiskTaint(driver, obj, obj->def->disks[i], logCtxt);
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux