render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From ed1ef3fb4a2a5f3b710e2f4e215e8e5b45db6558 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <ed1ef3fb4a2a5f3b710e2f4e215e8e5b45db6558.1383922565.git.jdenemar@redhat.com>
43fe83
From: Peter Krempa <pkrempa@redhat.com>
43fe83
Date: Fri, 8 Nov 2013 12:33:14 +0100
43fe83
Subject: [PATCH] conf: Do better job when comparing features ABI compatibility
43fe83
43fe83
https://bugzilla.redhat.com/show_bug.cgi?id=1008989
43fe83
43fe83
The ABI compatibility check for domain features didn't check the
43fe83
expanded HyperV and APIC EOI values, thus possibly allowing change in
43fe83
guest ABI.
43fe83
43fe83
Add the check and use typecasted switch statement to warn developers
43fe83
when adding a new HyperV feature.
43fe83
43fe83
(cherry picked from commit 5702c014b2b1feba7329e8b3dcc3a6be7cb4a88e)
43fe83
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/conf/domain_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++----
43fe83
 1 file changed, 67 insertions(+), 5 deletions(-)
43fe83
43fe83
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
43fe83
index dea8130..a1d7385 100644
43fe83
--- a/src/conf/domain_conf.c
43fe83
+++ b/src/conf/domain_conf.c
43fe83
@@ -13315,6 +13315,72 @@ virDomainRedirFilterDefCheckABIStability(virDomainRedirFilterDefPtr src,
43fe83
     return true;
43fe83
 }
43fe83
 
43fe83
+
43fe83
+static bool
43fe83
+virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
43fe83
+                                      virDomainDefPtr dst)
43fe83
+{
43fe83
+    size_t i;
43fe83
+
43fe83
+    /* basic check */
43fe83
+    if (src->features != dst->features) {
43fe83
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
43fe83
+                       _("Target domain features %d does not match source %d"),
43fe83
+                       dst->features, src->features);
43fe83
+        return false;
43fe83
+    }
43fe83
+
43fe83
+    /* APIC EOI */
43fe83
+    if (src->apic_eoi != dst->apic_eoi) {
43fe83
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
43fe83
+                       _("State of APIC EOI differs: "
43fe83
+                         "source: '%s', destination: '%s'"),
43fe83
+                       virDomainFeatureStateTypeToString(src->apic_eoi),
43fe83
+                       virDomainFeatureStateTypeToString(dst->apic_eoi));
43fe83
+        return false;
43fe83
+    }
43fe83
+
43fe83
+    /* hyperv */
43fe83
+    if (src->features & (1 << VIR_DOMAIN_FEATURE_HYPERV)) {
43fe83
+        for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
43fe83
+            switch ((enum virDomainHyperv) i) {
43fe83
+            case VIR_DOMAIN_HYPERV_RELAXED:
43fe83
+            case VIR_DOMAIN_HYPERV_VAPIC:
43fe83
+                if (src->hyperv_features[i] != dst->hyperv_features[i]) {
43fe83
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
43fe83
+                                   _("State of HyperV enlightenment "
43fe83
+                                     "feature '%s' differs: "
43fe83
+                                     "source: '%s', destination: '%s'"),
43fe83
+                                   virDomainHypervTypeToString(i),
43fe83
+                                   virDomainFeatureStateTypeToString(src->hyperv_features[i]),
43fe83
+                                   virDomainFeatureStateTypeToString(dst->hyperv_features[i]));
43fe83
+                    return false;
43fe83
+                }
43fe83
+
43fe83
+                break;
43fe83
+
43fe83
+            case VIR_DOMAIN_HYPERV_SPINLOCKS:
43fe83
+                /* spinlock count matters! */
43fe83
+                if (src->hyperv_spinlocks != dst->hyperv_spinlocks) {
43fe83
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
43fe83
+                                   _("HyperV spinlock retry count differs: "
43fe83
+                                     "source: '%u', destination: '%u'"),
43fe83
+                                   src->hyperv_spinlocks,
43fe83
+                                   dst->hyperv_spinlocks);
43fe83
+                    return false;
43fe83
+                }
43fe83
+                break;
43fe83
+
43fe83
+            case VIR_DOMAIN_HYPERV_LAST:
43fe83
+                break;
43fe83
+            }
43fe83
+        }
43fe83
+    }
43fe83
+
43fe83
+    return true;
43fe83
+}
43fe83
+
43fe83
+
43fe83
 /* This compares two configurations and looks for any differences
43fe83
  * which will affect the guest ABI. This is primarily to allow
43fe83
  * validation of custom XML config passed in during migration
43fe83
@@ -13416,12 +13482,8 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
43fe83
         return false;
43fe83
     }
43fe83
 
43fe83
-    if (src->features != dst->features) {
43fe83
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
43fe83
-                       _("Target domain features %d does not match source %d"),
43fe83
-                       dst->features, src->features);
43fe83
+    if (!virDomainDefFeaturesCheckABIStability(src, dst))
43fe83
         return false;
43fe83
-    }
43fe83
 
43fe83
     if (src->clock.ntimers != dst->clock.ntimers) {
43fe83
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
43fe83
-- 
43fe83
1.8.4.2
43fe83