From nobody Tue May 14 04:20:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621419445; cv=none; d=zohomail.com; s=zohoarc; b=fVEo5rZ0629TbPR2UJgbGAGqshfTy/wVOlm3A8Sz7iI/RCWYGgFMPhFwawM1vT6VWxyRUr0U+XsqIZqYmVVVqX/YVqMIUdbU0squNYMkoMtCD1sCvBvhGdBcpEgUWihP4tYEeyp8jXiLpYrxVFxKE3fyImhhbU6jOc+Kq8NCxec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621419445; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oyps405s3f5f8D7RZ3Pf08ZajTXJLVa1Ru84GwyntL8=; b=eP8pH9KhUdfUWlQcejx8zDEOoF0+RUFathZM5D6M3sO75vHGnygV3shBfA/KAlPzvDODwNpdYN2EifVwG+dVVvY7+pdgxb5Wfj2P60hrHZZ5W1PsW1BNFtoY4AvrRCWMvF0NpmzHfKWV6nPJFeNlSYNdj4o0xO2Ft28kTJFJThY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1621419445707739.215866302246; Wed, 19 May 2021 03:17:25 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-wYs8r9ehNWKvhSa8IXk-Lw-1; Wed, 19 May 2021 06:17:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B41C800FF0; Wed, 19 May 2021 10:17:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6980A5D9CC; Wed, 19 May 2021 10:17:16 +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 9DFA855344; Wed, 19 May 2021 10:17:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14JAHARm013689 for ; Wed, 19 May 2021 06:17:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 892B0705B5; Wed, 19 May 2021 10:17:10 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D6DF705AC for ; Wed, 19 May 2021 10:17:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621419444; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oyps405s3f5f8D7RZ3Pf08ZajTXJLVa1Ru84GwyntL8=; b=Uq2XFQC5z25e0jvyVen1y79uhqZU/CAZORy6EWzfjI8dRfwDTS/gpW1MyM8liNKJyA4qJn /8SIhIGZPTE04dTEXBB8ur9bIc2POuR+rRyWgJ/JGRh/GUDPBg0VRR8Vzn2MHTsf4xgp59 kNHW2zXd5i1/5zrrhh3YpxqpoNI7wJw= X-MC-Unique: wYs8r9ehNWKvhSa8IXk-Lw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/3] virsh: Fix logic wrt to --current flag in cmdSetmem Date: Wed, 19 May 2021 12:16:55 +0200 Message-Id: <89492efb6584d8bd04b002c29c53d4c6ff044260.1621419287.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In my commit of v7.1.0-rc1~376 I've simplified the logic of handling @flags. My assumption back then was that calling virDomainSetMemory() is equivalent to virDomainSetMemoryFlags(flags =3D 0). But that is not the case, because it is equivalent to virDomainSetMemoryFlags(flags =3D VIR_DOMAIN_AFFECT_LIVE). Fix the condition that calls the old API. Fixes: b5e267e8c59a257652f88d034cb1e0ce1ed4b58a Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1961118 Signed-off-by: Michal Privoznik --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0825f82522..9316aae3fd 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9025,7 +9025,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) } kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 - if (flags =3D=3D 0) { + if (!current && !live && !config) { if (virDomainSetMemory(dom, kibibytes) !=3D 0) ret =3D false; } else { --=20 2.26.3 From nobody Tue May 14 04:20:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621419449; cv=none; d=zohomail.com; s=zohoarc; b=BZG6EZg2GNtrBFTORdLnTwXIP3gu/8qX00CSG/A1TeCZtoMJ/pg999g0oxgwKpqYcpd6u7y/RjPt0desSBydxxIYQbMtEvXKlDObPdnPGbBYwY7UWJurkhyLYPR1VK4Qd3P3E2XLhTWP80QXEduUPkH8rF2i/eTp8Bbn6sPUdNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621419449; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/U874Os1wDSi6vnreJeBxOn0eznRx3KreT29DB+29Nc=; b=PSuqAIpHii0RQ+SD2YRteleTqLJwk0mkRdBICqV2Bot6aoN2COku5K3JSwVqeScUfW0v55luLCdRmiJmacOG6KcQBwXKW3Wd7Sc5y4YVhWyxqVhBRgyR6UGE1EQ9Wg2jUIsGzivmbseP852uSmgzghEswWDsLmTwuI4jwH72r1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1621419449016128.26818728542094; Wed, 19 May 2021 03:17:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-Y85ZrypsMNGNlbGdn2SOMQ-1; Wed, 19 May 2021 06:17:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB21D801107; Wed, 19 May 2021 10:17:18 +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 6D45A70581; Wed, 19 May 2021 10:17:18 +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 CE2B61801029; Wed, 19 May 2021 10:17:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14JAHG2c013711 for ; Wed, 19 May 2021 06:17:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id D234360C04; Wed, 19 May 2021 10:17:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 574C72AE99 for ; Wed, 19 May 2021 10:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621419448; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/U874Os1wDSi6vnreJeBxOn0eznRx3KreT29DB+29Nc=; b=OO4BDi1vhI0k/rflJc8R0U3aLg512RKJ5s5b6sQGAxKe8HVPXJ2MVgsOU9itrrL6MLzznW 11TG7Z2dsJOnu+aIFiWCM0CgDwmkyO6Yif0iYLCDm1rmJK/tPSTtDr5illQf+vvrEXPcEy XksnS3GBPbdsYSDEmG/M706ud7FHF5k= X-MC-Unique: Y85ZrypsMNGNlbGdn2SOMQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/3] virsh-domain: Fix @ret handling in cmdSetmem and cmdSetmaxmem Date: Wed, 19 May 2021 12:16:56 +0200 Message-Id: <7d20c9d02fb41cafd5c1d2f5a93ce84a1ec98323.1621419287.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" These functions initialize @ret to true and only after something fails either they call cleanup code (which consists only from virshDomainFree()) and return false, or they set ret =3D false and carry on (when the failure occurred close to cleanup code). Switch them to the usual pattern in which ret is initialized to failure, goto cleanup is used and ret is set to true only after everything succeeded. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/virsh-domain.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 9316aae3fd..5a5215ab4c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8996,7 +8996,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) unsigned long long bytes =3D 0; unsigned long long max; unsigned long kibibytes =3D 0; - bool ret =3D true; + bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -9019,20 +9019,20 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) max =3D 1024ull * ULONG_MAX; else max =3D ULONG_MAX; - if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) { - virshDomainFree(dom); - return false; - } + if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) + goto cleanup; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 if (!current && !live && !config) { if (virDomainSetMemory(dom, kibibytes) !=3D 0) - ret =3D false; + goto cleanup; } else { if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) - ret =3D false; + goto cleanup; } =20 + ret =3D true; + cleanup: virshDomainFree(dom); return ret; } @@ -9074,7 +9074,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) unsigned long long bytes =3D 0; unsigned long long max; unsigned long kibibytes =3D 0; - bool ret =3D true; + bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -9097,24 +9097,24 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) max =3D 1024ull * ULONG_MAX; else max =3D ULONG_MAX; - if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) { - virshDomainFree(dom); - return false; - } + if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) + goto cleanup; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 if (flags =3D=3D 0) { if (virDomainSetMaxMemory(dom, kibibytes) !=3D 0) { vshError(ctl, "%s", _("Unable to change MaxMemorySize")); - ret =3D false; + goto cleanup; } } else { if (virDomainSetMemoryFlags(dom, kibibytes, flags | VIR_DOMAIN_MEM= _MAXIMUM) < 0) { vshError(ctl, "%s", _("Unable to change MaxMemorySize")); - ret =3D false; + goto cleanup; } } =20 + ret =3D true; + cleanup: virshDomainFree(dom); return ret; } --=20 2.26.3 From nobody Tue May 14 04:20:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621419562; cv=none; d=zohomail.com; s=zohoarc; b=mfL7in9AKKC8FQXHoftTGABdPTUhPBCVRICkjlgGVb7F4abwJifUkVAR/oCvt+PCI7bPrhhIWK00tQzIWOUqhUkkggDkB3r5sWeKRLFe9CEz+f0HyY25oPsw228gk4u2tyImjxsnSR0lJFgypAZ1H7D7P+vPIYuwWLh/awceQKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621419562; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d9CNiP6Gc8E5uL8RRGXT+CbOKQxUp7gGfM9UoeRTIv8=; b=CDZy7DH+nTrJ8HRdsAb55coHS/mbqD3H5WD1xrmYVIwY38XQmXgJUd/oHbg+3vUeE1ZvT1O931Rnk++2OF9Fy9vAcY93TOg6WTlfmdXxBSbsySdHFlNGAIyVUOsGrlW1PcQWC86zKK6TYgkQ8wTFCmemYR8a7ToZBf/JiinvBU8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16214195628001014.9853399366039; Wed, 19 May 2021 03:19:22 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-xf34u-TbNwuTo-bH0h8qDA-1; Wed, 19 May 2021 06:19:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0DFA1935780; Wed, 19 May 2021 10:19:13 +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 8B8E2100AE43; Wed, 19 May 2021 10:19:13 +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 5B17A180140D; Wed, 19 May 2021 10:19:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 14JAHHSa013719 for ; Wed, 19 May 2021 06:17:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA30C18BB8; Wed, 19 May 2021 10:17:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EFC660C04 for ; Wed, 19 May 2021 10:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621419561; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=d9CNiP6Gc8E5uL8RRGXT+CbOKQxUp7gGfM9UoeRTIv8=; b=LkP58M1hBhTgscXm8Rw8szuf3ATW9pMkhtvUUTAHM99AnkkTqj6ChGM6nJC70WSi4mUCYs rl088KUZMaP7/OgVmJlzf7KMlTuAMSBADZ26HN0URcvOoERWLxlNGKps9ruvBq2ktmsIeI 0ksYTWAm1n5ZC0zyJOJFrlFFd8w0jqw= X-MC-Unique: xf34u-TbNwuTo-bH0h8qDA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/3] virsh-domain: Drop support for old APIs in cmdSetmem and cmdSetmaxmem Date: Wed, 19 May 2021 12:16:57 +0200 Message-Id: <863edf955da8b1e4810a400a7e83fb287c745cde.1621419287.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Some of our really old APIs are missing @flags argument. We introduced their variants with "Flags" suffix and wired some logic into virsh to call the new variant only if necessary. This enables virsh to talk to older daemon which may be lacking new APIs. However, in case of cmdSetmem() we are talking about v0.1.1 (virDomainSetMemory()) vs. v0.9.0 (virDomainSetMemoryFlags()) and in case of cmdSetmaxmem() we are talking about v0.0.3 (virDomainSetMaxMemory()) vs v0.9.0 (virDomainSetMemoryFlags()). Libvirt v0.9.0 was released more than 10 years ago and recently we dropped support for RHEL-7 which has v4.5.0 (released ~3 years ago). Thus it is not really necessary to have support in virsh for such old daemons. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- tools/virsh-domain.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5a5215ab4c..81357d23aa 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9000,15 +9000,15 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); - unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; + unsigned int flags =3D VIR_DOMAIN_AFFECT_LIVE; =20 VSH_EXCLUSIVE_OPTIONS_VAR(current, live); VSH_EXCLUSIVE_OPTIONS_VAR(current, config); =20 + if (current) + flags =3D VIR_DOMAIN_AFFECT_CURRENT; if (config) flags |=3D VIR_DOMAIN_AFFECT_CONFIG; - if (live) - flags |=3D VIR_DOMAIN_AFFECT_LIVE; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -9023,13 +9023,8 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) goto cleanup; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 - if (!current && !live && !config) { - if (virDomainSetMemory(dom, kibibytes) !=3D 0) - goto cleanup; - } else { - if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) - goto cleanup; - } + if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) + goto cleanup; =20 ret =3D true; cleanup: @@ -9101,16 +9096,9 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) goto cleanup; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 - if (flags =3D=3D 0) { - if (virDomainSetMaxMemory(dom, kibibytes) !=3D 0) { - vshError(ctl, "%s", _("Unable to change MaxMemorySize")); - goto cleanup; - } - } else { - if (virDomainSetMemoryFlags(dom, kibibytes, flags | VIR_DOMAIN_MEM= _MAXIMUM) < 0) { - vshError(ctl, "%s", _("Unable to change MaxMemorySize")); - goto cleanup; - } + if (virDomainSetMemoryFlags(dom, kibibytes, flags | VIR_DOMAIN_MEM_MAX= IMUM) < 0) { + vshError(ctl, "%s", _("Unable to change MaxMemorySize")); + goto cleanup; } =20 ret =3D true; --=20 2.26.3