From nobody Tue May 13 16:08:47 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; 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 1538743607658233.9009147301217; Fri, 5 Oct 2018 05:46:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BBA0530B9331; Fri, 5 Oct 2018 12:46:45 +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 6D4056A755; Fri, 5 Oct 2018 12:46:45 +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 0921A3D385; Fri, 5 Oct 2018 12:46:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w95CkOBr023369 for ; Fri, 5 Oct 2018 08:46:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B26916EEA; Fri, 5 Oct 2018 12:46:24 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id D45C916EF5 for ; Fri, 5 Oct 2018 12:46:23 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Fri, 5 Oct 2018 14:44:12 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 51/53] [ACKED] vircgrouptest: add hybrid tests 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 05 Oct 2018 12:46:46 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- tests/vircgrouptest.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index fe0cb9585a..8fcee21bb2 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -604,6 +604,45 @@ static int testCgroupNewForSelfUnified(const void *arg= s ATTRIBUTE_UNUSED) } =20 =20 +static int testCgroupNewForSelfHybrid(const void *args ATTRIBUTE_UNUSED) +{ + virCgroupPtr cgroup =3D NULL; + int ret =3D -1; + const char *empty[VIR_CGROUP_CONTROLLER_LAST] =3D { 0 }; + const char *mounts[VIR_CGROUP_CONTROLLER_LAST] =3D { + [VIR_CGROUP_CONTROLLER_CPUSET] =3D "/not/really/sys/fs/cgroup/cpus= et", + [VIR_CGROUP_CONTROLLER_DEVICES] =3D "/not/really/sys/fs/cgroup/dev= ices", + [VIR_CGROUP_CONTROLLER_FREEZER] =3D "/not/really/sys/fs/cgroup/fre= ezer", + [VIR_CGROUP_CONTROLLER_NET_CLS] =3D "/not/really/sys/fs/cgroup/net= _cls", + [VIR_CGROUP_CONTROLLER_PERF_EVENT] =3D "/not/really/sys/fs/cgroup/= perf_event", + }; + const char *placement[VIR_CGROUP_CONTROLLER_LAST] =3D { + [VIR_CGROUP_CONTROLLER_CPUSET] =3D "/", + [VIR_CGROUP_CONTROLLER_DEVICES] =3D "/", + [VIR_CGROUP_CONTROLLER_FREEZER] =3D "/", + [VIR_CGROUP_CONTROLLER_NET_CLS] =3D "/", + [VIR_CGROUP_CONTROLLER_PERF_EVENT] =3D "/", + }; + unsigned int controllers =3D + (1 << VIR_CGROUP_CONTROLLER_CPU) | + (1 << VIR_CGROUP_CONTROLLER_CPUACCT) | + (1 << VIR_CGROUP_CONTROLLER_MEMORY) | + (1 << VIR_CGROUP_CONTROLLER_BLKIO); + + if (virCgroupNewSelf(&cgroup) < 0) { + fprintf(stderr, "Cannot create cgroup for self\n"); + goto cleanup; + } + + ret =3D validateCgroup(cgroup, "", mounts, empty, placement, + "/not/really/sys/fs/cgroup/unified", "/", control= lers); + + cleanup: + virCgroupFree(&cgroup); + return ret; +} + + static int testCgroupAvailable(const void *args) { bool got =3D virCgroupAvailable(); @@ -1023,6 +1062,15 @@ mymain(void) ret =3D -1; cleanupFakeFS(fakerootdir); =20 + /* cgroup hybrid */ + + fakerootdir =3D initFakeFS("hybrid", "hybrid"); + if (virTestRun("New cgroup for self (hybrid)", testCgroupNewForSelfHyb= rid, NULL) < 0) + ret =3D -1; + if (virTestRun("Cgroup available (hybrid)", testCgroupAvailable, (void= *)0x1) < 0) + ret =3D -1; + cleanupFakeFS(fakerootdir); + return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list