[libvirt PATCH 06/16] qemu: taint the VM if it is using a deprecated machine type

[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 | 16 ++++++++++++++++
 src/qemu/qemu_capabilities.h |  3 +++
 src/qemu/qemu_domain.c       | 20 ++++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f6d7a222c4..b6d4c09e7e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2454,6 +2454,22 @@ virQEMUCapsIsCPUDeprecated(virQEMUCapsPtr qemuCaps,
 }
 
 
+bool
+virQEMUCapsIsMachineDeprecated(virQEMUCapsPtr qemuCaps,
+                               virDomainVirtType type,
+                               const char *machine)
+{
+    virQEMUCapsAccelPtr accel = virQEMUCapsGetAccel(qemuCaps, type);
+    size_t i;
+
+    for (i = 0; i < accel->nmachineTypes; i++) {
+        if (STREQ_NULLABLE(accel->machineTypes[i].name, machine))
+            return accel->machineTypes[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 a6270edb0e..19e2cd1fff 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -689,6 +689,9 @@ const char *virQEMUCapsGetMachineDefaultCPU(virQEMUCapsPtr qemuCaps,
 bool virQEMUCapsIsCPUDeprecated(virQEMUCapsPtr qemuCaps,
                                 virDomainVirtType type,
                                 const char *model);
+bool virQEMUCapsIsMachineDeprecated(virQEMUCapsPtr qemuCaps,
+                                    virDomainVirtType type,
+                                    const char *machine);
 bool virQEMUCapsGetMachineNumaMemSupported(virQEMUCapsPtr qemuCaps,
                                            virDomainVirtType virtType,
                                            const char *name);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ed5fd6aa0d..f00e8d9384 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6243,6 +6243,24 @@ void qemuDomainObjTaintMsg(virQEMUDriverPtr driver,
     virErrorRestore(&orig_err);
 }
 
+static void
+qemuDomainObjCheckMachineTaint(virQEMUDriverPtr driver,
+                               virDomainObjPtr obj,
+                               qemuDomainLogContextPtr logCtxt)
+{
+    qemuDomainObjPrivatePtr priv = obj->privateData;
+    virQEMUCapsPtr qemuCaps = priv->qemuCaps;
+
+    if (virQEMUCapsIsMachineDeprecated(qemuCaps,
+                                       obj->def->virtType,
+                                       obj->def->os.machine)) {
+        qemuDomainObjTaintMsg(driver, obj, VIR_DOMAIN_TAINT_DEPRECATED_CONFIG, logCtxt,
+                              _("machine type '%s'"),
+                              obj->def->os.machine);
+    }
+}
+
+
 static void
 qemuDomainObjCheckCPUTaint(virQEMUDriverPtr driver,
                            virDomainObjPtr obj,
@@ -6307,6 +6325,8 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
                            VIR_DOMAIN_TAINT_CUSTOM_HYPERVISOR_FEATURE, logCtxt);
     }
 
+    qemuDomainObjCheckMachineTaint(driver, obj, logCtxt);
+
     if (obj->def->cpu)
         qemuDomainObjCheckCPUTaint(driver, obj, logCtxt, incomingMigration);
 
-- 
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