From nobody Tue Nov 26 08:34:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1581975010170631.2888625429256; Mon, 17 Feb 2020 13:30:10 -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-10-B8xNtfaYOpumAf4V_h41eQ-1; Mon, 17 Feb 2020 16:30:06 -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 AE0718018A3; Mon, 17 Feb 2020 21:30:00 +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 7B27F90F6A; Mon, 17 Feb 2020 21:30:00 +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 145B218089D6; Mon, 17 Feb 2020 21:30:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01HLTZu3031968 for ; Mon, 17 Feb 2020 16:29:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id A8D532166B2B; Mon, 17 Feb 2020 21:29:35 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4C4D2166B27 for ; Mon, 17 Feb 2020 21:29:33 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (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 8921F8012B3 for ; Mon, 17 Feb 2020 21:29:33 +0000 (UTC) Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-NYMTarp7Mredol_gxHZ-_A-1; Mon, 17 Feb 2020 16:29:29 -0500 Received: by mail-qk1-f193.google.com with SMTP id b7so17583668qkl.7; Mon, 17 Feb 2020 13:29:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 13:29:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581975008; 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=27v6Zb0M/14Fi9k6yxzaYLrb5tcfhbEvTUp98Tr5egs=; b=ihdenYbLs66LJoRPpLeUM/+ed0xykr+0cABJFyR36FJewg2F7hsG1urPrdr7Y8qEN04mr+ ubyJbfrUN1h+2Qa0qFCeh4n9Pcrfew2tfp4kzWpvFeDdejfduhQPeh4BmctTDrqzZaTWPh I/aMmQendyPqi9UQUUYPXDJDXovN3lI= 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=fpgAPSw2BkLAEAL8NjGLxFpx3Dt7qkmOd/zrhYe09dU=; b=Qc2WbYCSu6ukrNkS/rNr+0yZUTDMRMDMZQiK8BivfivLSMe0casAiY1LqOAOsoHI6R waV34VAnqK7etm/9ddte5f990wfuzIxMvOygmB9gzY5xZFi4+GIWTw2a80vFb5yk+RbI lTTBwT10LEvBmtwVRgjLHQrRQkA+C6sbyLKGmi6Kl8bTrv5Wjz76jpOncXn8mHwjxFu/ lFmmkM1II/ulGYVQFrlCOJCxBtVGqQj4e46WSzJWwZdl3bXnXwmydUn9KDv5yk+bhvba j61nZ8WoAY75rEenYZKGo36kYsDdiEnzz6rFsLJs3W913apKF2Xu1fJWGeGumJocrmjP gItQ== X-Gm-Message-State: APjAAAV6ja+QSgKYfE0F+8MtWnrj8EQFkZiv6kR+wYqlIj3fke4OVdwC iEZdRAjjWotTlRy+wzrwp1kT8PXbzvw= X-Google-Smtp-Source: APXvYqwLefbNXoBfgNTlzZDUpyiJEXmoUEdjncVOqJ1KFJuevBiG2N85kYjoqn+8XGrMK/mwT9qV5Q== X-Received: by 2002:a37:6d2:: with SMTP id 201mr15957690qkg.270.1581974968761; Mon, 17 Feb 2020 13:29:28 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 01/14] vircgroup.c: adding virCgroupSetupBlkioDevice* helpers Date: Mon, 17 Feb 2020 16:29:08 -0500 Message-Id: <20200217212921.251616-2-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: NYMTarp7Mredol_gxHZ-_A-1 X-MC-Unique: B8xNtfaYOpumAf4V_h41eQ-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01HLTZu3031968 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.79 on 10.5.11.15 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" The current use of the functions that sets and gets BlkioDevice attributes is doing a set(), following by a get() of the same parameter right after. This is done because there is no guarantee that the kernel will accept the desired value given by the set() call, thus we need to execute a get() right after to get the actual value. This patch adds helpers inside vircgroup.c to execute these operations. Next patch will use these helpers to reduce code repetition in LXC and QEMU files. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 5 +++ src/util/vircgroup.c | 85 ++++++++++++++++++++++++++++++++++++++++ src/util/vircgroup.h | 20 ++++++++++ 3 files changed, 110 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 125d1836dd..e26bfab101 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1730,6 +1730,11 @@ virCgroupSetMemoryHardLimit; virCgroupSetMemorySoftLimit; virCgroupSetMemSwapHardLimit; virCgroupSetOwner; +virCgroupSetupBlkioDeviceReadBps; +virCgroupSetupBlkioDeviceReadIops; +virCgroupSetupBlkioDeviceWeight; +virCgroupSetupBlkioDeviceWriteBps; +virCgroupSetupBlkioDeviceWriteIops; virCgroupSupportsCpuBW; virCgroupTerminateMachine; =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 0680ff7c24..302352aca3 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3581,3 +3581,88 @@ virCgroupDelThread(virCgroupPtr cgroup, =20 return 0; } + + +/** + * Calls virCgroupSetBlkioDeviceWeight() to set up blkio device weight, + * then retrieves the actual value set by the kernel with + * virCgroupGetBlkioDeviceWeight() in the same @weight pointer. + */ +int +virCgroupSetupBlkioDeviceWeight(virCgroupPtr cgroup, const char *path, + unsigned int *weight) +{ + if (virCgroupSetBlkioDeviceWeight(cgroup, path, *weight) < 0 || + virCgroupGetBlkioDeviceWeight(cgroup, path, weight) < 0) + return -1; + + return 0; +} + + +/** + * Calls virCgroupSetBlkioDeviceReadIops() to set up blkio device riops, + * then retrieves the actual value set by the kernel with + * virCgroupGetBlkioDeviceReadIops() in the same @riops pointer. + */ +int +virCgroupSetupBlkioDeviceReadIops(virCgroupPtr cgroup, const char *path, + unsigned int *riops) +{ + if (virCgroupSetBlkioDeviceReadIops(cgroup, path, *riops) < 0 || + virCgroupGetBlkioDeviceReadIops(cgroup, path, riops) < 0) + return -1; + + return 0; +} + + +/** + * Calls virCgroupSetBlkioDeviceWriteIops() to set up blkio device wiops, + * then retrieves the actual value set by the kernel with + * virCgroupGetBlkioDeviceWriteIops() in the same @wiops pointer. + */ +int +virCgroupSetupBlkioDeviceWriteIops(virCgroupPtr cgroup, const char *path, + unsigned int *wiops) +{ + if (virCgroupSetBlkioDeviceWriteIops(cgroup, path, *wiops) < 0 || + virCgroupGetBlkioDeviceWriteIops(cgroup, path, wiops) < 0) + return -1; + + return 0; +} + + +/** + * Calls virCgroupSetBlkioDeviceReadBps() to set up blkio device rbps, + * then retrieves the actual value set by the kernel with + * virCgroupGetBlkioDeviceReadBps() in the same @rbps pointer. + */ +int +virCgroupSetupBlkioDeviceReadBps(virCgroupPtr cgroup, const char *path, + unsigned long long *rbps) +{ + if (virCgroupSetBlkioDeviceReadBps(cgroup, path, *rbps) < 0 || + virCgroupGetBlkioDeviceReadBps(cgroup, path, rbps) < 0) + return -1; + + return 0; +} + + +/** + * Calls virCgroupSetBlkioDeviceWriteBps() to set up blkio device wbps, + * then retrieves the actual value set by the kernel with + * virCgroupGetBlkioDeviceWriteBps() in the same @wbps pointer. + */ +int +virCgroupSetupBlkioDeviceWriteBps(virCgroupPtr cgroup, const char *path, + unsigned long long *wbps) +{ + if (virCgroupSetBlkioDeviceWriteBps(cgroup, path, *wbps) < 0 || + virCgroupGetBlkioDeviceWriteBps(cgroup, path, wbps) < 0) + return -1; + + return 0; +} diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 15263f534a..6bd3f4fe9d 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -175,6 +175,26 @@ int virCgroupGetBlkioDeviceWriteBps(virCgroupPtr group, const char *path, unsigned long long *wbps); =20 +int virCgroupSetupBlkioDeviceWeight(virCgroupPtr cgroup, + const char *path, + unsigned int *weight); + +int virCgroupSetupBlkioDeviceReadIops(virCgroupPtr cgroup, + const char *path, + unsigned int *riops); + +int virCgroupSetupBlkioDeviceWriteIops(virCgroupPtr cgroup, + const char *path, + unsigned int *wiops); + +int virCgroupSetupBlkioDeviceReadBps(virCgroupPtr cgroup, + const char *path, + unsigned long long *rbps); + +int virCgroupSetupBlkioDeviceWriteBps(virCgroupPtr cgroup, + const char *path, + unsigned long long *wbps); + int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb); int virCgroupGetMemoryStat(virCgroupPtr group, unsigned long long *cache, --=20 2.24.1