From nobody Thu May 2 07:40:27 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=1611318549; cv=none; d=zohomail.com; s=zohoarc; b=cjHDTdUwZ/GBjgSgaNEN0x2sF/bMbpZ8iku5o976S5RWpC/3bKe2+hV5Sv14R5g7dSy6wJQHbVRg7ED3COyCqi79L7YdPfgrpfVKewu1yAaE+PhIbrhFi60zPWYaK26m24iAiTtztl0ywjDGGKuNXTpzDYSYtLLtGM86O74Xmp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611318549; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=AdEsg/9RGu109V8naF6T0DE92cV7rIYUXNF542B9YGU=; b=PUAk36tR9oYnSHvAagDF5X399HD8fe7KsGOn8YQ1m4bfAH4nrc8QWbo47FjifCZ6272oLCDtpSYeITDTSro0bDWAnMFvDK/b+pod00JkmmHOHT93UP+Hz7ld6qUfqsN2iQQkqpLWjwIi0Xu5myhRc3cNMmsctOLxeSqpBy4Bh8w= 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 1611318549269350.1222323386538; Fri, 22 Jan 2021 04:29:09 -0800 (PST) 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-245-BOcIU9jjOC2XE0UGYdWxTQ-1; Fri, 22 Jan 2021 07:29:05 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EEA68018A4; Fri, 22 Jan 2021 12:28:57 +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 46E8E6B540; Fri, 22 Jan 2021 12:28:56 +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 A4F4B1809C9F; Fri, 22 Jan 2021 12:28:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10MCSgcD007963 for ; Fri, 22 Jan 2021 07:28:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9F38F10023AD; Fri, 22 Jan 2021 12:28:42 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 211DE10016F7 for ; Fri, 22 Jan 2021 12:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611318548; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AdEsg/9RGu109V8naF6T0DE92cV7rIYUXNF542B9YGU=; b=Yw1sGl7FY+hbfXfBkdeo1fdr9MCdkXecykM7FAXwhEjTaqeMxCdfyWnZJJslW6c9xKYym3 Dk7yVfYS07uoSIS2YXxeeLho8yBYEHsN8PJBBJjtY99oFbuyk/AuV1RhTU/l/j8oqYjtJy raoeGO2nt2Ttd2zAwsBp1ic0QGFOur0= X-MC-Unique: BOcIU9jjOC2XE0UGYdWxTQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virsh: Simplify @flags handing in cmdSetmem() and cmdSetmaxmem() Date: Fri, 22 Jan 2021 13:28:37 +0100 Message-Id: <60d32c546036eddf58481c3161a49aa7135188ff.1611318505.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.15 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" What code tries to achieve is that if no flags were provided to either 'setmem' or 'setmaxmem' commands then the old (no flags) API is called to be able to communicate with older daemons. Well, the code can be simplified a bit. Note that with this change the old no flag version of APIs is used more often. Previously if --current argument was given it resulted in *Flags() version to be called even though it is not necessary - VIR_DOMAIN_AFFECT_CURRENT is implied. Therefore, this change in fact allows virsh to talk with broader set of daemons. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- tools/virsh-domain.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 2bb136333f..9746117bdb 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9018,9 +9018,6 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_AFFECT_CONFIG; if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; - /* none of the options were specified */ - if (!current && !live && !config) - flags =3D -1; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -9037,7 +9034,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) } kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 - if (flags =3D=3D -1) { + if (flags =3D=3D 0) { if (virDomainSetMemory(dom, kibibytes) !=3D 0) ret =3D false; } else { @@ -9090,7 +9087,7 @@ cmdSetmaxmem(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 | VIR_DOMAIN_MEM_MAXI= MUM; + unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; =20 VSH_EXCLUSIVE_OPTIONS_VAR(current, live); VSH_EXCLUSIVE_OPTIONS_VAR(current, config); @@ -9099,9 +9096,6 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_AFFECT_CONFIG; if (live) flags |=3D VIR_DOMAIN_AFFECT_LIVE; - /* none of the options were specified */ - if (!current && !live && !config) - flags =3D -1; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -9118,13 +9112,13 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) } kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 - if (flags =3D=3D -1) { + if (flags =3D=3D 0) { if (virDomainSetMaxMemory(dom, kibibytes) !=3D 0) { vshError(ctl, "%s", _("Unable to change MaxMemorySize")); ret =3D false; } } else { - if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) { + if (virDomainSetMemoryFlags(dom, kibibytes, flags | VIR_DOMAIN_MEM= _MAXIMUM) < 0) { vshError(ctl, "%s", _("Unable to change MaxMemorySize")); ret =3D false; } --=20 2.26.2