From nobody Mon Feb 9 01:31:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 149563719979346.322683471581286; Wed, 24 May 2017 07:46:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1818361E4A; Wed, 24 May 2017 14:46:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C97287FDCA; Wed, 24 May 2017 14:46:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D2DC4180BAF4; Wed, 24 May 2017 14:46:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4OEkCqh022401 for ; Wed, 24 May 2017 10:46:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2B627FDE4; Wed, 24 May 2017 14:46:12 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37D8B7F3BA for ; Wed, 24 May 2017 14:46:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1818361E4A Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1818361E4A From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 24 May 2017 16:45:55 +0200 Message-Id: <61c3ce5695e227ab423c4aacaa285a90b474fe6c.1495637025.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/3] virDomainDefCheckABIStabilityFlags: move memtune checks into a separate function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 24 May 2017 14:46:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The checks are scattered all over the place. Move them into a single function. Signed-off-by: Michal Privoznik --- 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(virDomainTPMDefPt= r src, return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } =20 + +static bool +virDomainMemtuneCheckABIStability(const virDomainDef *src, + const virDomainDef *dst, + unsigned int flags) +{ + if (virDomainDefGetMemoryInitial(src) !=3D virDomainDefGetMemoryInitia= l(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 !=3D 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 !=3D 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 !=3D 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(virDomainDefPt= r src, goto error; } =20 - if (virDomainDefGetMemoryInitial(src) !=3D virDomainDefGetMemoryInitia= l(dst)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain max memory %lld does not match sou= rce %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 !=3D 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; - } =20 if (!virDomainNumaCheckABIStability(src->numa, dst->numa)) goto error; =20 - if (src->mem.memory_slots !=3D dst->mem.memory_slots) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain memory slots count '%u' doesn't ma= tch source '%u'"), - dst->mem.memory_slots, src->mem.memory_slots); - goto error; - } - if (src->mem.max_memory !=3D 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; =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list