From nobody Thu Sep 19 01:14:31 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537273109640641.6437626345559; Tue, 18 Sep 2018 05:18:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39269308FF2F; Tue, 18 Sep 2018 12:18:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA4D178DE1; Tue, 18 Sep 2018 12:18:26 +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 8D28E4A46C; Tue, 18 Sep 2018 12:18:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8ICIBDE015788 for ; Tue, 18 Sep 2018 08:18:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id E0589176A2; Tue, 18 Sep 2018 12:18:11 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 637DC176A7 for ; Tue, 18 Sep 2018 12:18:11 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 18 Sep 2018 14:18:00 +0200 Message-Id: <982608743d5e8a798ec27de5047425b41af44506.1537273033.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/9] vircgrouptest: call virCgroupDetectMounts directly 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 18 Sep 2018 12:18:28 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Because we can set which files to return for cgroup tests there is no need to have special function tailored to run tests. Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 2 +- src/util/vircgroup.c | 21 +++++---------------- src/util/vircgrouppriv.h | 4 +--- tests/vircgrouptest.c | 16 ++++++++-------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ad7ce57b65..7f3b5738c4 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1513,7 +1513,7 @@ virCgroupDelThread; virCgroupDenyAllDevices; virCgroupDenyDevice; virCgroupDenyDevicePath; -virCgroupDetectMountsFromFile; +virCgroupDetectMounts; virCgroupFree; virCgroupGetBlkioDeviceReadBps; virCgroupGetBlkioDeviceReadIops; diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 3211f63cb1..f8ef76136b 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -430,9 +430,7 @@ virCgroupMountOptsMatchController(const char *mntOpts, * mounted and where */ int -virCgroupDetectMountsFromFile(virCgroupPtr group, - const char *path, - bool checkLinks) +virCgroupDetectMounts(virCgroupPtr group) { size_t i; FILE *mounts =3D NULL; @@ -440,9 +438,9 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, char buf[CGROUP_MAX_VAL]; int ret =3D -1; =20 - mounts =3D fopen(path, "r"); + mounts =3D fopen("/proc/mounts", "r"); if (mounts =3D=3D NULL) { - virReportSystemError(errno, _("Unable to open %s"), path); + virReportSystemError(errno, "%s", _("Unable to open /proc/mounts")= ); return -1; } =20 @@ -470,8 +468,7 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, =20 /* If it is a co-mount it has a filename like "cpu,cpuacct" * and we must identify the symlink path */ - if (checkLinks && - virCgroupResolveMountLink(entry.mnt_dir, typestr, + if (virCgroupResolveMountLink(entry.mnt_dir, typestr, controller) < 0) { goto cleanup; } @@ -485,12 +482,6 @@ virCgroupDetectMountsFromFile(virCgroupPtr group, return ret; } =20 -static int -virCgroupDetectMounts(virCgroupPtr group) -{ - return virCgroupDetectMountsFromFile(group, "/proc/mounts", true); -} - =20 static int virCgroupCopyPlacement(virCgroupPtr group, @@ -4082,9 +4073,7 @@ virCgroupAvailable(void) =20 =20 int -virCgroupDetectMountsFromFile(virCgroupPtr group ATTRIBUTE_UNUSED, - const char *path ATTRIBUTE_UNUSED, - bool checkLinks ATTRIBUTE_UNUSED) +virCgroupDetectMounts(virCgroupPtr group ATTRIBUTE_UNUSED) { virReportSystemError(ENXIO, "%s", _("Control groups not supported on this platform"= )); diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index a0034f3889..f78fe8bb9c 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -50,9 +50,7 @@ struct _virCgroup { virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST]; }; =20 -int virCgroupDetectMountsFromFile(virCgroupPtr group, - const char *path, - bool checkLinks); +int virCgroupDetectMounts(virCgroupPtr group); =20 int virCgroupNewPartition(const char *path, bool create, diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 7968903cad..6a38091a86 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -164,21 +164,21 @@ testCgroupDetectMounts(const void *args) { int result =3D -1; const char *file =3D args; - char *mounts =3D NULL; char *parsed =3D NULL; const char *actual; virCgroupPtr group =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 - if (virAsprintf(&mounts, "%s/vircgroupdata/%s.mounts", - abs_srcdir, file) < 0 || - virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", - abs_srcdir, file) < 0 || - VIR_ALLOC(group) < 0) + setenv("VIR_CGROUP_MOCK_FILENAME", file, 1); + + if (virAsprintf(&parsed, "%s/vircgroupdata/%s.parsed", abs_srcdir, fil= e) < 0) + goto cleanup; + + if (VIR_ALLOC(group) < 0) goto cleanup; =20 - if (virCgroupDetectMountsFromFile(group, mounts, false) < 0) + if (virCgroupDetectMounts(group) < 0) goto cleanup; =20 for (i =3D 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { @@ -196,7 +196,7 @@ testCgroupDetectMounts(const void *args) result =3D 0; =20 cleanup: - VIR_FREE(mounts); + unsetenv("VIR_CGROUP_MOCK_FILENAME"); VIR_FREE(parsed); virCgroupFree(&group); virBufferFreeAndReset(&buf); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list