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

[libvirt] [PATCH v2 1/3] virDomainDefCheckABIStabilityFlags: move memtune checks into a separate function



The checks are scattered all over the place. Move them into a
single function.

Signed-off-by: Michal Privoznik <mprivozn redhat com>
---
 src/conf/domain_conf.c | 74 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 48 insertions(+), 26 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 32234e8a5..ef5b9d7f4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19803,6 +19803,53 @@ virDomainTPMDefCheckABIStability(virDomainTPMDefPtr src,
     return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info);
 }
 
+
+static bool
+virDomainMemtuneCheckABIStability(const virDomainDef *src,
+                                  const virDomainDef *dst,
+                                  unsigned int flags)
+{
+    if (virDomainDefGetMemoryInitial(src) != virDomainDefGetMemoryInitial(dst)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Target domain max memory %lld "
+                         "does not match source %lld"),
+                       virDomainDefGetMemoryInitial(dst),
+                       virDomainDefGetMemoryInitial(src));
+        return false;
+    }
+
+    if (!(flags & VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE) &&
+        src->mem.cur_balloon != dst->mem.cur_balloon) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Target domain current memory %lld "
+                         "does not match source %lld"),
+                       dst->mem.cur_balloon,
+                       src->mem.cur_balloon);
+        return false;
+    }
+
+    if (src->mem.max_memory != dst->mem.max_memory) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Target maximum memory size '%llu' "
+                         "doesn't match source '%llu'"),
+                       dst->mem.max_memory,
+                       src->mem.max_memory);
+        return false;
+    }
+
+    if (src->mem.memory_slots != dst->mem.memory_slots) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Target domain memory slots "
+                         "count '%u' doesn't match source '%u'"),
+                       dst->mem.memory_slots,
+                       src->mem.memory_slots);
+        return false;
+    }
+
+    return true;
+}
+
+
 static bool
 virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
                                     virDomainMemoryDefPtr dst)
@@ -19957,37 +20004,12 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
         goto error;
     }
 
-    if (virDomainDefGetMemoryInitial(src) != virDomainDefGetMemoryInitial(dst)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target domain max memory %lld does not match source %lld"),
-                       virDomainDefGetMemoryInitial(dst),
-                       virDomainDefGetMemoryInitial(src));
+    if (!virDomainMemtuneCheckABIStability(src, dst, flags))
         goto error;
-    }
-    if (!(flags & VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE) &&
-        src->mem.cur_balloon != dst->mem.cur_balloon) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target domain current memory %lld does not match source %lld"),
-                       dst->mem.cur_balloon, src->mem.cur_balloon);
-        goto error;
-    }
 
     if (!virDomainNumaCheckABIStability(src->numa, dst->numa))
         goto error;
 
-    if (src->mem.memory_slots != dst->mem.memory_slots) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target domain memory slots count '%u' doesn't match source '%u'"),
-                       dst->mem.memory_slots, src->mem.memory_slots);
-        goto error;
-    }
-    if (src->mem.max_memory != dst->mem.max_memory) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target maximum memory size '%llu' doesn't match source '%llu'"),
-                       dst->mem.max_memory, src->mem.max_memory);
-        goto error;
-    }
-
     if (!virDomainDefVcpuCheckAbiStability(src, dst))
         goto error;
 
-- 
2.13.0


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