From nobody Tue Nov 26 08:52:20 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 1581975064335361.28077563885165; Mon, 17 Feb 2020 13:31:04 -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-314-LaDWHZoINjuqZTdGBo7ziA-1; Mon, 17 Feb 2020 16:30:12 -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 32E58800EBB; Mon, 17 Feb 2020 21:30:07 +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 E4DFB90F6C; Mon, 17 Feb 2020 21:30:06 +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 6AC7118089D8; Mon, 17 Feb 2020 21:30:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 01HLTa41031980 for ; Mon, 17 Feb 2020 16:29:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1FA642026D69; Mon, 17 Feb 2020 21:29:36 +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 1A8E92026D67 for ; Mon, 17 Feb 2020 21:29:36 +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 F4216800F25 for ; Mon, 17 Feb 2020 21:29:35 +0000 (UTC) Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-6-fiPve-O0u8_PCxQH6MeQ-1; Mon, 17 Feb 2020 16:29:33 -0500 Received: by mail-qv1-f67.google.com with SMTP id p2so8219977qvo.10; Mon, 17 Feb 2020 13:29:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 13:29:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581975062; 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=aJs54mh0O915cL0pYSMc19WQ57/Yye4plcTfGSr+qTo=; b=BrNVHTEoqKiyDho1PJMCFPYwhT49uvMK4kFZroa2jj0iiJrQDUV64it3I7+UsDqnk4sfRr 445qbwYoU/nTQRY2CLPneQrA3RK8R3d+Q5219DJ2+F35L1iDqP6m+iGdiZWKOD2MoaSD4P QYqISMnMxlUTko60ydC8kq/GNvwgf84= 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=2/40uXN8nxxVzodVpCikgAjtqme6wj+T4EYj6b6OZAs=; b=nrWw1rRLgprnBqe06lXrA2AvKKTP0osC6Nk/ZVeELxbVFyERC+YlHQ0MUDRfms8Zna BoNENn5qcQzVZa/JY7u4HfYP3MV551pEeMDrq8PeXwyZbC0VTYWoCPLjwI/1k5E7TAko zo5x2uYJOQcSMnUiGsd9XgRmqTewVPLk2wrQUexH5lKCOwiu7JVfZre4rgNPwKtjvwAC JVVSsl7rHlLcQgnNzDa1j8aMfgRCwAsEBfhaU2h6xnnAk2woaDDMtmaGDYLX4s+l4BKQ u5CT/OxXR32qkDIzj+ndyoZs9r/MYazODfgWZM9kXsBUcqqXNcVo2njGfkbKE7xXsyJC vqYg== X-Gm-Message-State: APjAAAWjvWKuNI6c441GYOBdoV2ybXKnLSQB5ztC2XNdrSX6zfpqBt5J El3UJ4XtbWCGLqc1dOQC7gJHG5NxoO8= X-Google-Smtp-Source: APXvYqyPq4b6ejGXVdIfkR27Q++6AnnBx6JJobFV2fQCMAe/bWAGMEsZQJN/800HJOOsuuRuD3QgLg== X-Received: by 2002:ad4:4d85:: with SMTP id cv5mr13839698qvb.171.1581974972879; Mon, 17 Feb 2020 13:29:32 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 06/14] vircgroup.c: add virCgroupSetupCpusetCpus() Date: Mon, 17 Feb 2020 16:29:13 -0500 Message-Id: <20200217212921.251616-7-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: 6-fiPve-O0u8_PCxQH6MeQ-1 X-MC-Unique: LaDWHZoINjuqZTdGBo7ziA-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 01HLTa41031980 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 code from qemuSetupCgroupCpusetCpus() and virLXCCgroupSetupCpusetTune() can be centralized in a new helper called virCgroupSetupCpusetCpus(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/lxc/lxc_cgroup.c | 11 +++-------- src/qemu/qemu_cgroup.c | 14 +------------- src/util/vircgroup.c | 15 +++++++++++++++ src/util/vircgroup.h | 1 + 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1bc5d17000..a58a5ed78b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1730,6 +1730,7 @@ virCgroupSetupBlkioDeviceReadIops; virCgroupSetupBlkioDeviceWeight; virCgroupSetupBlkioDeviceWriteBps; virCgroupSetupBlkioDeviceWriteIops; +virCgroupSetupCpusetCpus; virCgroupSupportsCpuBW; virCgroupTerminateMachine; =20 diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index eac1ee1ee0..618063bf43 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -69,14 +69,9 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr d= ef, virDomainNumatuneMemMode mode; =20 if (def->placement_mode !=3D VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO && - def->cpumask) { - if (!(mask =3D virBitmapFormat(def->cpumask))) - return -1; - - if (virCgroupSetCpusetCpus(cgroup, mask) < 0) - goto cleanup; - /* free mask to make sure we won't use it in a wrong way later */ - VIR_FREE(mask); + def->cpumask && + virCgroupSetupCpusetCpus(cgroup, def->cpumask) < 0) { + return -1; } =20 if (virDomainNumatuneGetMode(def->numa, -1, &mode) < 0 || diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 0c2f5f1b25..ee08b99064 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -1165,19 +1165,7 @@ int qemuSetupCgroupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask) { - int ret =3D -1; - char *new_cpus =3D NULL; - - if (!(new_cpus =3D virBitmapFormat(cpumask))) - goto cleanup; - - if (virCgroupSetCpusetCpus(cgroup, new_cpus) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - VIR_FREE(new_cpus); - return ret; + return virCgroupSetupCpusetCpus(cgroup, cpumask); } =20 =20 diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 261e63f6ec..dcbd55c0f1 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3666,3 +3666,18 @@ virCgroupSetupBlkioDeviceWriteBps(virCgroupPtr cgrou= p, const char *path, =20 return 0; } + + +int +virCgroupSetupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask) +{ + g_autofree char *new_cpus =3D NULL; + + if (!(new_cpus =3D virBitmapFormat(cpumask))) + return -1; + + if (virCgroupSetCpusetCpus(cgroup, new_cpus) < 0) + return -1; + + return 0; +} diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index d50a8d69d4..55132dedb6 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -245,6 +245,7 @@ int virCgroupGetCpusetMemoryMigrate(virCgroupPtr group,= bool *migrate); =20 int virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus); int virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus); +int virCgroupSetupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask); =20 int virCgroupRemove(virCgroupPtr group); =20 --=20 2.24.1