Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1439328lqd; Thu, 25 Apr 2024 16:10:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuDZUo91+JOgaFnC8S5p7HrNk/yn43UuF1+yrPAv9XvnpXvauW2d9LV4ZO92XrOoTgg/Kixadie2mFiCgzeEgja9JK4qvXjmsOlVQDvg== X-Google-Smtp-Source: AGHT+IFWNw+Q5q359Zgd17exhN8zuWgm34MBmSEEocY9RuRErJUf1JqeuPXrnE7XfKFwv3VMsSjj X-Received: by 2002:a17:906:53d7:b0:a58:8827:f85a with SMTP id p23-20020a17090653d700b00a588827f85amr3503262ejo.25.1714086657418; Thu, 25 Apr 2024 16:10:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714086657; cv=pass; d=google.com; s=arc-20160816; b=pRk4+enLUOOnsYBDPRR1Us3cgN3SU6kivzShKV2sLi3O238oth2PLcODm/+XpV3PTJ bHFMBaYS+JnLaqOclqtoj0RHknK5c1CAssvTEE+58jrTXbUzgu/4lLOKfCj/axCGOGCq J2TKZcTBycEVo59usjMSajskBui45d5ColzcxRojQjBecA7CR1/eWKDMuO+YU6hAPGHd 1nwTjPKnEhXu8sWugJZArwt39QpqGDiGzOxHBfyN8CjB/9stSit4ZZD77lOB2BCptKtl LcNJCvKDgaUvAzizh2HSw5/A6qfbMHgc297ySEU71EQ1Il+eaJyAtjdw2ROiWQKcxhkx EHCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=DUCYtH/HKWn8ExkVR1X+jCKv2DoEuOQK+l1YHfMHQfI=; fh=b3WHappogIZ7tevdP19aMaFveT4kCg8rt7VJzYp2eZs=; b=fP3gRJUBMPN80MjjHCOyse14sWAUqjn3GA8UbEL7lYJIAW3+I7BZhyPtYn5hZvXdkb YNX+tM4hD4cu1Clx66+fHy5Yhu4oPG6nBM+M8e702q3lUy2kIKq/OjPfuVN1gSpNVr2O NUXZ3xozJUiAP6ByEjvtZXRtfN2gfMhcui9xSZf6/AqoxXMQDldBKgqyvBAeHGmxT58L q8EfoqGWlU9wzI3SBRBknW+ivXlMOAUE7RAXx2D0j6hBjjtBGg+Kvyp1g+IAoCQIOqdp 8Uw+qjAJqR+YXhmafmJRNOAU1bQu3tWgYry960MP9kXvJWZgeYwjDwAFBsxSxqiW3L2/ 4BIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=D5sSIXoq; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-159352-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159352-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ji14-20020a170907980e00b00a55b1a62095si6349575ejc.149.2024.04.25.16.10.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 16:10:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159352-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=D5sSIXoq; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-159352-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159352-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 29E611F21B55 for ; Thu, 25 Apr 2024 23:10:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE82915686F; Thu, 25 Apr 2024 23:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="D5sSIXoq" Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB25715667C for ; Thu, 25 Apr 2024 23:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714086631; cv=none; b=hhn24C17ea4IT4F0WDfs42oGR1pSrovpOxQ7/ljOqEkF/JD8MKoQYgWmhtWyyqyfFrLTqAcwRkmVWIasydAPJBkSukmG5u+hO8Ic3Qv6fvEOwMln7v3+oftv2/GpyTqml0FtwFiWJH48Rh5sSnrxFStMr5qDvfEDa5kSNqJABKM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714086631; c=relaxed/simple; bh=zTkgFfAHRBc68cUsuLXVtOjsq96hByN4x7hSD1bfdOo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lgDI8dg5An/TqPNYiderFDIebdPowoSxqoe0m1g4O3lIvBQRgoNMgcSa8qFQqKg/TMWuriZHv0v201Yr6O52O/j/Q9ltGVUuzBWfl1XTAPo65zENTacYZGlQfL95nGctbI6aCr/jw+pF5//XLvzZp/2lFLuoowC7kVQF1DmXHTc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=D5sSIXoq; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6ed33476d82so1549653b3a.0 for ; Thu, 25 Apr 2024 16:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714086629; x=1714691429; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DUCYtH/HKWn8ExkVR1X+jCKv2DoEuOQK+l1YHfMHQfI=; b=D5sSIXoqnRr6ulKefBtpEoOHyLPfHzqUmlHk88pZmt3mdxh/kB/Nsz6GsuapNtCmVC dTcnjQ1TohaB89agucwuxvlUvwcQVIcg7rzOZFiBxWoSldVQYnSNzN5c6zF85YPTgL0b hkhTE2yI0zQFc5LzvQkNMDGs8dW77Y5VhzTHwhELr0FCwWgFwpuYT9Nf1E5BYXZvhe7n ztJu/iLbZ8O+zJn9UWxXhQaAbwSiQtO7YJTYynxSw/TpFxYDJ/dHrSEIwgvkNRbn5aDX uoMPVDkwGMvnpOJn4KPHlqsdtr1WRGNATjz8O03zHqLHr14d8GwLm2ICbRYTDWGjm+Fv iL6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714086629; x=1714691429; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DUCYtH/HKWn8ExkVR1X+jCKv2DoEuOQK+l1YHfMHQfI=; b=ILUctpthn88Kr5YI9f5moSxi6Rq+X5n6kJu/fxbJIHEyWQlMhuMX+oLdzIMkvjc0xE LJp+zjJy70J04riBpFKKsBdrKVgvpXKbx3v0rWiJQ+u+XPzI5WaPrlp8gVceF7On47E5 9SuKL7DObxDDEav/A4lVMyOPUT+WVGfAcB8c8MJzsT27bo5A8tOaYxzr35o13Z7OrweO Rm9blsoKNh3x2pWkqLMOZZTe6/kH0kdCeKNI15qTKIG6m7w4j+Q9hJgCynl+bwkbtxSV QPJh6xNqITraFJceIaeCGhW9aB7yE5W3A7mYAGRc0V7MloDXVGxbwhLpqyWDBneEzcq+ uzqA== X-Forwarded-Encrypted: i=1; AJvYcCWhl3ODYAuQ8EyY00GAZ52uKDJoYvUASBhbGf3DXaWMsrPSh6NJ29p2P7UTP2a+PtQxISLZTtMuE9xKc/O+o22HftI9HNkfD4LyID70 X-Gm-Message-State: AOJu0YwSrofJSH8u39//ZDw+eFjpmd/crjLobTvrD7FnCSzQmAL9r4ZR KCBb56IVmvQe3zcbnefOrRiqpylq/kH0pNqCnDWD71Dz1tjGtpPxxp5ONG/VaqCyhCwreZQDHpJ xcA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:1708:b0:6ed:95ce:3417 with SMTP id h8-20020a056a00170800b006ed95ce3417mr99147pfc.5.1714086628911; Thu, 25 Apr 2024 16:10:28 -0700 (PDT) Date: Thu, 25 Apr 2024 16:10:27 -0700 In-Reply-To: <20240415-kvm-selftests-no-sudo-v1-1-95153ad5f470@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240415-kvm-selftests-no-sudo-v1-1-95153ad5f470@google.com> Message-ID: Subject: Re: [PATCH] KVM: selftests: Avoid assuming "sudo" exists From: Sean Christopherson To: Brendan Jackman Cc: Paolo Bonzini , Shuah Khan , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Mon, Apr 15, 2024, Brendan Jackman wrote: > I ran into a failure running this test on a minimal rootfs. > > Can be fixed by just skipping the "sudo" in case we are already root. > > Signed-off-by: Brendan Jackman > --- > tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh > index 7cbb409801eea..0e56822e8e0bf 100755 > --- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh > +++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.sh > @@ -13,10 +13,21 @@ NX_HUGE_PAGES_RECOVERY_RATIO=$(cat /sys/module/kvm/parameters/nx_huge_pages_reco > NX_HUGE_PAGES_RECOVERY_PERIOD=$(cat /sys/module/kvm/parameters/nx_huge_pages_recovery_period_ms) > HUGE_PAGES=$(cat /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages) > > +# If we're already root, the host might not have sudo. > +if [ $(whoami) == "root" ]; then > + function maybe_sudo () { Any objection to do_sudo instead of maybe_sudo? I can fixup when applying if that works for you. > + "$@" > + } > +else > + function maybe_sudo () { > + sudo "$@" > + } > +fi > + > set +e > > function sudo_echo () { > - echo "$1" | sudo tee -a "$2" > /dev/null > + echo "$1" | maybe_sudo tee -a "$2" > /dev/null > } > > NXECUTABLE="$(dirname $0)/nx_huge_pages_test" > > --- > base-commit: 2c71fdf02a95b3dd425b42f28fd47fb2b1d22702 > change-id: 20240415-kvm-selftests-no-sudo-1a55f831f882 > > Best regards, > -- > Brendan Jackman >