From nobody Sun Feb 8 03:11:16 2026 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