From nobody Tue Nov 26 08:47:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1581975030907501.48325971939266; Mon, 17 Feb 2020 13:30:30 -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-285-cBtcv2GZMNWnQKvwG48VVg-1; Mon, 17 Feb 2020 16:30:25 -0500 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 0737818A8C86; Mon, 17 Feb 2020 21:30:19 +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 CA39B10021B2; Mon, 17 Feb 2020 21:30: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 63B771804744; Mon, 17 Feb 2020 21:30:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01HLTkEL032079 for ; Mon, 17 Feb 2020 16:29:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 01653D1BC7; Mon, 17 Feb 2020 21:29:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F046AD0B4B for ; Mon, 17 Feb 2020 21:29:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8AC69802711 for ; Mon, 17 Feb 2020 21:29:44 +0000 (UTC) Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-274-1paov4dFPJ6j_6xhm4GfYw-1; Mon, 17 Feb 2020 16:29:40 -0500 Received: by mail-qk1-f194.google.com with SMTP id c20so17616475qkm.1; Mon, 17 Feb 2020 13:29:40 -0800 (PST) Received: from rekt.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id i7sm872284qki.83.2020.02.17.13.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 13:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581975029; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=L3Uz6coJGHlhpCTDN6boTS0ts5zLRR1WEYLJ5Bi5Nao=; b=Y6tJ0rxAPFQV3RcVXMzY8qyRaiGVqGa6VFAXu8bqwKWrg1rwgafMNt9GlfUEOxqEJ8oZ7t CIFjk/V5HnE5ebRyqfWXiBBlW9BmeKaXCe+V2BPQBsXmMH1czvfQcQQvdIqd3GCnc5ZtMg bvgBpl8vttBXeM+Zg0MzidDIdkp5nXk= 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=Ql8WXdW2OXO3gETkbft+dyn4DG1yBYQoqraUZ/cKql0=; b=QA/Z8kpJMW77ABZKhoiPUrfoqp0fMB8k+LP57PKuV2xjP4ajesdY2W6yeBz2miDVC3 U2ai7u4lCs1OS8hK3TI9N3VDdx/1seJMhnauwEK9r9/0h8cmJm0kIwurMOY3tSK+ap0I H+wiOXu/Rh9O+EA04XqXbYPai77746LciLq9w8cwayVezOpWSs51Puo0EA5Nd28ECKqw f4wGBEzD0BRRy2cc5WUh3KUGEoVoEfSxYFgxCDGR99lRWN8eAfTF6bDSOBMNlcmxRola ga2zAtIMsKtAr4ULrxvsjaounYKJ6yrxfS8mPinBhYKDgGp5hQBe25QhhzIKGYNX/wmp KogA== X-Gm-Message-State: APjAAAX7IG4gw/DTaRODD5J+QkUwlzMweum0xd59Mdwp/QbfkGMBaaSG BJDnOygmiXUNXnWkpecOBRGvwhJ+tb8= X-Google-Smtp-Source: APXvYqxGhWEys4P9TCTkLEEypLGAyNRSrH809mH4noTYoT/wEEaegHI6gn6fmEAntei5FiaodWxmdg== X-Received: by 2002:a05:620a:15c2:: with SMTP id o2mr2374105qkm.324.1581974979555; Mon, 17 Feb 2020 13:29:39 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 14/14] vircgroup: add virCgroupGetCpuPeriodQuota() Date: Mon, 17 Feb 2020 16:29:21 -0500 Message-Id: <20200217212921.251616-15-danielhb413@gmail.com> In-Reply-To: <20200217212921.251616-1-danielhb413@gmail.com> References: <20200217212921.251616-1-danielhb413@gmail.com> MIME-Version: 1.0 X-MC-Unique: 1paov4dFPJ6j_6xhm4GfYw-1 X-MC-Unique: cBtcv2GZMNWnQKvwG48VVg-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01HLTkEL032079 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , jtomko@redhat.com, crobinso@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 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" Another vircgroup helper to avoid code repetition between the LXC and QEMU driver. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/lxc/lxc_driver.c | 8 +------- src/qemu/qemu_driver.c | 8 +------- src/util/vircgroup.c | 14 ++++++++++++++ src/util/vircgroup.h | 2 ++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 679e32116c..4c6ad89ecc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1692,6 +1692,7 @@ virCgroupGetCpuacctStat; virCgroupGetCpuacctUsage; virCgroupGetCpuCfsPeriod; virCgroupGetCpuCfsQuota; +virCgroupGetCpuPeriodQuota; virCgroupGetCpusetCpus; virCgroupGetCpusetMemoryMigrate; virCgroupGetCpusetMems; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index fc559d736a..b2e9bc3a46 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1783,13 +1783,7 @@ static int lxcGetVcpuBWLive(virCgroupPtr cgroup, unsigned long long *period, long long *quota) { - if (virCgroupGetCpuCfsPeriod(cgroup, period) < 0) - return -1; - - if (virCgroupGetCpuCfsQuota(cgroup, quota) < 0) - return -1; - - return 0; + return virCgroupGetCpuPeriodQuota(cgroup, period, quota); } =20 =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b65708385f..dda4bded08 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10532,13 +10532,7 @@ static int qemuGetVcpuBWLive(virCgroupPtr cgroup, unsigned long long *period, long long *quota) { - if (virCgroupGetCpuCfsPeriod(cgroup, period) < 0) - return -1; - - if (virCgroupGetCpuCfsQuota(cgroup, quota) < 0) - return -1; - - return 0; + return virCgroupGetCpuPeriodQuota(cgroup, period, quota); } =20 static int diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 1f853beb73..70d85200cb 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3739,3 +3739,17 @@ virCgroupSetupCpuPeriodQuota(virCgroupPtr cgroup, =20 return -1; } + + +int +virCgroupGetCpuPeriodQuota(virCgroupPtr cgroup, unsigned long long *period, + long long *quota) +{ + if (virCgroupGetCpuCfsPeriod(cgroup, period) < 0) + return -1; + + if (virCgroupGetCpuCfsQuota(cgroup, quota) < 0) + return -1; + + return 0; +} diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index cc53bae258..a5bd35586d 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -227,6 +227,8 @@ int virCgroupSetupCpuShares(virCgroupPtr cgroup, unsign= ed long long shares, =20 int virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_pe= riod); int virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_p= eriod); +int virCgroupGetCpuPeriodQuota(virCgroupPtr cgroup, unsigned long long *pe= riod, + long long *quota); int virCgroupSetupCpuPeriodQuota(virCgroupPtr cgroup, unsigned long long p= eriod, long long quota); =20 --=20 2.24.1