From patchwork Thu Sep 26 21:18:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 174548 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2611896ill; Thu, 26 Sep 2019 14:23:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxy0bdhpQN8Pp/A2LwlDt5+mWxamg6AJmfe+Cj0iMfbYRuBBFkOrYcMWvbvW7W9e73ADxGq X-Received: by 2002:a02:b156:: with SMTP id s22mr5209436jah.102.1569533015540; Thu, 26 Sep 2019 14:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569533015; cv=none; d=google.com; s=arc-20160816; b=wLOZC6/b+bEppUiVQT520roVgbniZKhKVS+NG5g1/taa1UalkHvapvBvgDPJnaSZvs xcdMpwbrrb6EE9JWkR4NYgh4ifjpcstDoJCoy7cMZJf4Kx3qxxoQQtXi8ESV8eVKUTAB G+U6/a3dWAOG3cQGP0Q12SwC245MadtEvNDlAcWxAAntthR69vyrabioNJI5NqIiskAv hC/vbG8yqE0khmz3m3YlLYOhJ4GY1Sg9T2GiHol367ZxGo20dcIg8Idc++UYWv8xE96A d7ZpbvK8h3xty3z0eEaby1chrmdwbfXGcquonQCa5HEbRtD0fcc2jnBY8UQmcslZPqXu qWuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=5bni/YxIoOt2/d5cJP2uXZbu4G771Bs9qvt5IJnOMnk=; b=t0VMWmKPI3lbrxZnZPljgRqjWUlm5kJc6MgslmlPU42V6cDbMvAWCUXVgAj9eklbsU 2HkAfNGoDQFm0bfDLsA+MiK6UNfxf9u/8j+Pr+zBZGsyLhsZyFMhxYgq9KFmryXDjQqm gYs5oi+VFWpOgsJZOFs9TyUWMStEqfWK9Osbuf5fenGM4J8XsGRDdEiiInFZUdXNKGgd 86diXB6yA4/JU7RSTmmgvvgBokkzOFi2Azfcflqpf1cjqfj9pIoRsuoAxIeXKqF7vifd wjzZf2qHb2EsoVPG/OFctOEngpVTFSXRUj1YvvKZTBxBU5P+SZWGgCiNWO0gj8F/g8jg +zeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f2si4325662ion.129.2019.09.26.14.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Sep 2019 14:23:35 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 mx1.redhat.com (Postfix) with ESMTPS id 896285AFE3; Thu, 26 Sep 2019 21:23:33 +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 3CC575D6B0; Thu, 26 Sep 2019 21:23:30 +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 F205B1803B37; Thu, 26 Sep 2019 21:23:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8QLIV7W018377 for ; Thu, 26 Sep 2019 17:18:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3F2D60605; Thu, 26 Sep 2019 21:18:31 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-123-202.rdu2.redhat.com [10.10.123.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07D4560933; Thu, 26 Sep 2019 21:18:30 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 26 Sep 2019 17:18:40 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] vircgroupv2: Fix VM startup when legacy cgroups are defined 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 26 Sep 2019 21:23:34 +0000 (UTC) On Fedora 31, starting a 'mock' build alters /proc/$pid/cgroup, probably due to usage of systemd-nspawn. Before: $ cat /proc/self/cgroup 0::/user.slice/user-1000.slice/... After: $ cat /proc/self/cgroup 1:name=systemd:/ 0::/user.slice/user-1000.slice/... The cgroupv2 code mishandles that first line in the second case, which causes VM startup to fail with: Unable to read from '/sys/fs/cgroup/machine/cgroup.controllers': No such file or directory The kernel docs[1] say that the cgroupv2 path will always start with '0::', which in the code here controllers="". Only set the v2 placement path when we see that cgroup file entry. [1] https://www.kernel.org/doc/html/v5.3/admin-guide/cgroup-v2.html#processes https://bugzilla.redhat.com/show_bug.cgi?id=1751120 Signed-off-by: Cole Robinson --- src/util/vircgroupv2.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Pavel Hrdina diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 0663c67190..0cb20e4896 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -194,12 +194,16 @@ virCgroupV2DetectMounts(virCgroupPtr group, static int virCgroupV2DetectPlacement(virCgroupPtr group, const char *path, - const char *controllers ATTRIBUTE_UNUSED, + const char *controllers, const char *selfpath) { if (group->unified.placement) return 0; + /* controllers="" indicates the cgroupv2 controller path */ + if (STRNEQ_NULLABLE(controllers, "")) + return 0; + /* * selfpath == "/" + path="" -> "/" * selfpath == "/libvirt.service" + path == "" -> "/libvirt.service" From patchwork Thu Sep 26 21:18:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 174550 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp2568787oce; Thu, 26 Sep 2019 14:24:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGrdNlYbCtQB1ugVgE4tS2SQ0ZmMO2XqCkdTap7K8PdrQ77KAfB3YqoQuhDg2NoGM+87bg X-Received: by 2002:a6b:7d4c:: with SMTP id d12mr5416028ioq.165.1569533092957; Thu, 26 Sep 2019 14:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569533092; cv=none; d=google.com; s=arc-20160816; b=aBM8USuPCh1/iChg9WSZqRn6bkFzl9hDCAbPasAtffihTp5ANe9kggvaAuA0MUopok 5agyDioxbqcWtTmIeQvobevBgeiQz2/TViAam3aHIu56pIkc5CI98cxLrT/RoiyXHEDk EK4EeHMk6lf+dJ5bM//EDl3qxxbS4mEWYIt33uhjFHAjWMgNz3eHsiWo7cqNKojNkJWU LKlwie8Q6ON5G1N9Fh2FIYYLn8lIwzWHKHI1F2urVJRHqTrizjTDxTsKOLeHPozuMXgi 69BmxIt8AAVwrWNNoVCV2XSLDU/F3RVlABc3uDUKuKShZh4qzxzALuxv6maD2YjYPOu7 nm4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=RLjIztAnaZk1AiqlDPAF2dWF7j7fFNWHdanPp36eCA8=; b=iFhTIw4u4XML4RIvAiUQ3/Z0Q5VHQjoRXSZGWWu/3g/0wmoA0LVSfCinm3V0zUfrEJ SJzN6z5hVLAoJjSRtxZUgu9KuL2sD8DxsRKIpAJJypaxmtjCGzLUIe7TQsHeZA110pJg Ak5VkNLmHfldGriX1Mwp7RcrxN5ex1EFSt//nAavfF3giMP2eYZ5fqEJWXqaRq6jYEKs 0Qj28hUneHcojek+WOOnFylI76xN7vOiyfkKXxUd9JflKW3JipF8BKXDTVxMzuR+284A rgBuFvrGggu4DHda+/XT+KpOgipQEXNVHvQbKjUrz0lWS8pkNNJoQzM9+40a903a3phu zBbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id v130si3169303iod.33.2019.09.26.14.24.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Sep 2019 14:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 BA005C05AA52; Thu, 26 Sep 2019 21:24:51 +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 976776012C; Thu, 26 Sep 2019 21:24:51 +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 5558E4E9F2; Thu, 26 Sep 2019 21:24:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8QLIW2J018386 for ; Thu, 26 Sep 2019 17:18:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id A9E2A60A9F; Thu, 26 Sep 2019 21:18:32 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-123-202.rdu2.redhat.com [10.10.123.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2529E60605; Thu, 26 Sep 2019 21:18:32 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 26 Sep 2019 17:18:41 -0400 Message-Id: <4cbb8e7e5f9d3e7f38092c4e7af6fdc39f22c338.1569532456.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] vircgroup: Add some VIR_DEBUG statements 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 26 Sep 2019 21:24:52 +0000 (UTC) These helped with debugging https://bugzilla.redhat.com/show_bug.cgi?id=1612383 Signed-off-by: Cole Robinson --- src/util/vircgroup.c | 3 ++- src/util/vircgroupv2.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Pavel Hrdina diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 825f62a97b..4f9d80666d 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1157,7 +1157,8 @@ virCgroupNewMachineSystemd(const char *name, virCgroupFree(&init); if (!path || STREQ(path, "/") || path[0] != '/') { - VIR_DEBUG("Systemd didn't setup its controller"); + VIR_DEBUG("Systemd didn't setup its controller, path=%s", + NULLSTR(path)); return -2; } diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 0cb20e4896..f3f83c1e95 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -155,10 +155,14 @@ virCgroupV2CopyPlacement(virCgroupPtr group, const char *path, virCgroupPtr parent) { + VIR_DEBUG("group=%p path=%s parent=%p", group, path, parent); + if (path[0] == '/') { if (VIR_STRDUP(group->unified.placement, path) < 0) return -1; } else { + VIR_DEBUG("parent->unified.placement=%s", parent->unified.placement); + /* * parent == "/" + path="" => "/" * parent == "/libvirt.service" + path == "" => "/libvirt.service" @@ -172,6 +176,7 @@ virCgroupV2CopyPlacement(virCgroupPtr group, return -1; } + VIR_DEBUG("set group->unified.placement=%s", group->unified.placement); return 0; } @@ -200,6 +205,9 @@ virCgroupV2DetectPlacement(virCgroupPtr group, if (group->unified.placement) return 0; + VIR_DEBUG("group=%p path=%s controllers=%s selfpath=%s", + group, path, controllers, selfpath); + /* controllers="" indicates the cgroupv2 controller path */ if (STRNEQ_NULLABLE(controllers, "")) return 0; @@ -216,6 +224,7 @@ virCgroupV2DetectPlacement(virCgroupPtr group, path) < 0) return -1; + VIR_DEBUG("set group->unified.placement=%s", group->unified.placement); return 0; }