From nobody Wed May 14 07:09:09 2025 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.zohomail.com; dkim=fail; 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 15280494502041016.5842727464908; Sun, 3 Jun 2018 11:10:50 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D75E030667FF; Sun, 3 Jun 2018 18:10:48 +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 A783930012C9; Sun, 3 Jun 2018 18:10:48 +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 57921180005A; Sun, 3 Jun 2018 18:10:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w53IALD4021753 for ; Sun, 3 Jun 2018 14:10:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id A5110600C4; Sun, 3 Jun 2018 18:10:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E350600C2 for ; Sun, 3 Jun 2018 18:10:18 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE99830A3AD6 for ; Sun, 3 Jun 2018 18:10:06 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id v16-v6so4812834wmh.5 for ; Sun, 03 Jun 2018 11:10:06 -0700 (PDT) Received: from machado.local ([83.240.61.52]) by smtp.gmail.com with ESMTPSA id n12-v6sm23572465wrp.69.2018.06.03.11.10.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 03 Jun 2018 11:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fidencio-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kb/BXp5jo2QdlVyc475By1vbH+lmdjzIeBnMpOQ0Jyw=; b=dsfs/gHpdzUi1nDBVD9eEuRsrbzcxRMegLpjJZ+huXR8bNoDpJ8AJ6eM2KTvKE2fvI Un5Rw2AzoA6WAFpINr3OT4QXJdcmumMOEL5j+SQ7jR+kr/Mk7GK5tpiqkC8DjrhWM1Sg yfYqg2/esC4FtYN6gr8JH/fLk9MAc0OOibLZeKvs96f6TLN+E50bCTjNNJu8otqr/MfS nTXsOOMUg+AncJ2XWruEd7reWSjrzVISUpXuz6PIK7a2G46vZ4NlyuZiL2bkR2V+AoHL btoom5gRTFrxqsRnLtGsNGq/tKy+2EjSPuH1ypx+80tv+32XAgs4o4kj6W6iz7kqGt/k BIow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kb/BXp5jo2QdlVyc475By1vbH+lmdjzIeBnMpOQ0Jyw=; b=tDdpizjcEs/Pcvt0JGT+uY+/sywZWv2/8qQSu8GZZXF4un7qcRfbfNuoy+i1+26iWb WKvPTdCf8whaQCuwqgIukUjtitntYr9AFYrop1l//vTwDaVvytH/vGi2I+sEoGfQq9aV kHSPEcfS52LFwWPGMwkqjpsAUoPPFbq4GvBNzrIHLDRnwDU2TSXRwmhECcKrgRp1rBQP JeyFDmKhbg9GYdOUq6tI5xii7MBkBT/R5HeTZpPjr+TXT+Afh2AEbJm/ES15FXqZ26l2 DCFTZ7B5Yda/NOUQFEF7LEMRYGSO/3O+S44HxpS68HfRclGIG+mmwf8wpaojKnScTWhU sT2A== X-Gm-Message-State: APt69E37QOrtfF6tZJqeZ4MolfyYUGSqY76DwpEJHpVbcfi7gP9Qfns2 lAGiwMyipEPcBOWORtOgTKuvlUn9 X-Google-Smtp-Source: ADUXVKKOLvT3KbILEB01eNUbqRsbwNbmifJI1qmqxcf0D8d54FDPTMQBHr5M2oCmqvojYnfjvnSETA== X-Received: by 2002:a1c:9991:: with SMTP id b139-v6mr7958464wme.160.1528049405310; Sun, 03 Jun 2018 11:10:05 -0700 (PDT) From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Sun, 3 Jun 2018 20:10:00 +0200 Message-Id: <20180603181000.5621-3-fabiano@fidencio.org> In-Reply-To: <20180603181000.5621-1-fabiano@fidencio.org> References: <20180603181000.5621-1-fabiano@fidencio.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Sun, 03 Jun 2018 18:10:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Sun, 03 Jun 2018 18:10:07 +0000 (UTC) for IP:'74.125.82.65' DOMAIN:'mail-wm0-f65.google.com' HELO:'mail-wm0-f65.google.com' FROM:'fabiano@fidencio.org' RCPT:'' X-RedHat-Spam-Score: 0.08 (DKIM_SIGNED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID) 74.125.82.65 mail-wm0-f65.google.com 74.125.82.65 mail-wm0-f65.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH 2/2] vircgroup: Add virCgroupSetupMemtune() 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 03 Jun 2018 18:10:49 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 virCgroupSetupMemtune() has been introduced in order to remove the code duplication present between virLXCCgroupSetupMemTune() and qemuSetupMemoryCgroup(). Signed-off-by: Fabiano Fid=C3=AAncio --- src/libvirt_private.syms | 1 + src/lxc/lxc_cgroup.c | 20 ++------------------ src/qemu/qemu_cgroup.c | 14 +------------- src/util/vircgroup.c | 20 ++++++++++++++++++++ src/util/vircgroup.h | 1 + 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4bec93c786..39fce2e169 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1546,6 +1546,7 @@ virCgroupSetMemorySoftLimit; virCgroupSetMemSwapHardLimit; virCgroupSetOwner; virCgroupSetupBlkiotune; +virCgroupSetupMemtune; virCgroupSupportsCpuBW; virCgroupTerminateMachine; =20 diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index 2158c1c12b..a5e71aee53 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -113,26 +113,10 @@ static int virLXCCgroupSetupBlkioTune(virDomainDefPtr= def, static int virLXCCgroupSetupMemTune(virDomainDefPtr def, virCgroupPtr cgroup) { - int ret =3D -1; - if (virCgroupSetMemory(cgroup, virDomainDefGetMemoryInitial(def)) < 0) - goto cleanup; - - if (virMemoryLimitIsSet(def->mem.hard_limit)) - if (virCgroupSetMemoryHardLimit(cgroup, def->mem.hard_limit) < 0) - goto cleanup; - - if (virMemoryLimitIsSet(def->mem.soft_limit)) - if (virCgroupSetMemorySoftLimit(cgroup, def->mem.soft_limit) < 0) - goto cleanup; - - if (virMemoryLimitIsSet(def->mem.swap_hard_limit)) - if (virCgroupSetMemSwapHardLimit(cgroup, def->mem.swap_hard_limit)= < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - return ret; + return virCgroupSetupMemtune(cgroup, &def->mem); } =20 =20 diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 47ee23796c..7b6a4ec796 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -543,19 +543,7 @@ qemuSetupMemoryCgroup(virDomainObjPtr vm) } } =20 - if (virMemoryLimitIsSet(vm->def->mem.hard_limit)) - if (virCgroupSetMemoryHardLimit(priv->cgroup, vm->def->mem.hard_li= mit) < 0) - return -1; - - if (virMemoryLimitIsSet(vm->def->mem.soft_limit)) - if (virCgroupSetMemorySoftLimit(priv->cgroup, vm->def->mem.soft_li= mit) < 0) - return -1; - - if (virMemoryLimitIsSet(vm->def->mem.swap_hard_limit)) - if (virCgroupSetMemSwapHardLimit(priv->cgroup, vm->def->mem.swap_h= ard_limit) < 0) - return -1; - - return 0; + return virCgroupSetupMemtune(priv->cgroup, &vm->def->mem); } =20 =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 4e57f1322f..88f213e6da 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -4974,3 +4974,23 @@ virCgroupSetupBlkiotune(virCgroupPtr cgroup, =20 return 0; } + + +int +virCgroupSetupMemtune(virCgroupPtr cgroup, + virDomainMemtunePtr mem) +{ + if (virMemoryLimitIsSet(mem->hard_limit)) + if (virCgroupSetMemoryHardLimit(cgroup, mem->hard_limit) < 0) + return -1; + + if (virMemoryLimitIsSet(mem->soft_limit)) + if (virCgroupSetMemorySoftLimit(cgroup, mem->soft_limit) < 0) + return -1; + + if (virMemoryLimitIsSet(mem->swap_hard_limit)) + if (virCgroupSetMemSwapHardLimit(cgroup, mem->swap_hard_limit) < 0) + return -1; + + return 0; +} diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index bd7e7c6d70..5d7973b272 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -300,4 +300,5 @@ int virCgroupHasEmptyTasks(virCgroupPtr cgroup, int con= troller); bool virCgroupControllerAvailable(int controller); =20 int virCgroupSetupBlkiotune(virCgroupPtr cgroup, virDomainBlkiotunePtr blk= io); +int virCgroupSetupMemtune(virCgroupPtr cgroup, virDomainMemtunePtr mem); #endif /* __VIR_CGROUP_H__ */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list