From nobody Sat Jun 13 00:38:47 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.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 B0F0337F75E for ; Mon, 11 May 2026 20:12:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778530338; cv=none; b=s/AdXWlbQXKuRer382HbTszLiogKVuR3A+FIYQ7ZeClm2LT3AwDfpgZorB5LdtUqBmJtpeTEcawHi5Km4jAUTx+9lcqSi3AnBImLfszXmM7pepAAh3EkJXUUuRxqHSFSukTjP6dLEB1A/pNkCKgaDZfqnzombmigbV0zvzGJ5kA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778530338; c=relaxed/simple; bh=FGSM4U7hryVpiAmi3oDgdDYIdgAY0lSQze75TLXqOGQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hghjcoh2BTTIawV5lyDIV7aQgDIEN0tcfIjBZdIbIfN6HukAFtll0dJKd3SRJW0FQ6swV4adX8w2h4HU+3D37SwnHb0azYztpxb7ECqU2kzbgkh+j7JsZBpdffTcyg447jA383xo/hl5zJahs+B0MQRGaOMj94hrmP25xDuqDnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vipinsh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vgb9pvAG; arc=none smtp.client-ip=209.85.214.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--vipinsh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vgb9pvAG" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2bc7f9b2213so18041425ad.0 for ; Mon, 11 May 2026 13:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778530336; x=1779135136; 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=7dRVHPnXGrn5aswewvPP6Un3xORm3RDg3I3ZM7xnpfM=; b=vgb9pvAGp5fUQleSDPcQPs+lejOc0vipNYDORZS0nv7B/u9SODORfRE21m1hN2Lmkj lFYIA5VDWIk2vL36b4uPkgVoUMqdlJ74sD8PKNNn8eHgH/q4BvDB84pOiSsUro8sbo8y M07CLux0tuFUB3KoybXGNLRu/IhqiE0kjWL3QLnizFHhXhWtSJ4xPp6xq0huZX8UpJOf 36UiE4LwDQcaLKZ7P3S5WQvtL/J1I2Y3pZ1cZQJu9lHtUx5eeoTatoFqApOQYp4bz38R IaJ/1DKBza05w1cRkLdSOdupABr8J8fM8t0g+9wB0zYqsUESteqezdMyPaCbgG9sEbfP VGuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778530336; x=1779135136; 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=7dRVHPnXGrn5aswewvPP6Un3xORm3RDg3I3ZM7xnpfM=; b=k0sYAiChHGopvz6LwRa2cdV8ir8jaEAprHTZij3A+FTpPY0kFsfKIl2YtZyD3yNyT/ wSZ8bRiisaJ5kW6Fff8NrqoD85lCTpeBBmlnmPpvTrYuB+yFz9GVUN+/loQq7r/uG3B/ fBRPsyzvVQa9esu1bECZlpVjTHVjkQlmD1r4N88E5BwErLxBQZCaaM5JfmW8bCIHJfBJ 2dj7Fr3clK8NUUgIOdEFFqWyDBZUr5/a757bcDPE8rtFwfoe+Vt5wDD0QWexIP57byQr OD2rDURt7BMcEZh71VI1q2sQUnS0RylCsodCxG5sEzo7gDmCNAeFxnvHTaQsosU4+aCx uRWg== X-Forwarded-Encrypted: i=1; AFNElJ9ZbaxeYwqwkRiPymnX8bSMZsINP/iIBSUiFAYaiu3Ba/Oyn2WO3ocTdgRzNVYjEnFiALFWjeaoMF+90uE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw77fR1ZrxEB3tfcJ4untJdlMB2h+JEDC1Y461EHmGk5QJDM8rR Lr3FTKlLOV06es7p/PcGS3OQ/eMimFWzJiSzJJHYOVe7G3QoTlmjMu0n0HHCbPzmfWG37ruBCAR AoMvt0DSWwQ== X-Received: from plpj2.prod.google.com ([2002:a17:903:3d82:b0:2bc:b686:8143]) (user=vipinsh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f70b:b0:2ba:5e44:ce8f with SMTP id d9443c01a7336-2baf0bd5421mr161209745ad.0.1778530335808; Mon, 11 May 2026 13:12:15 -0700 (PDT) Date: Mon, 11 May 2026 13:11:54 -0700 In-Reply-To: <20260511201155.1488670-1-vipinsh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260511201155.1488670-1-vipinsh@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260511201155.1488670-2-vipinsh@google.com> Subject: [PATCH 1/2] selftests/liveupdate: Move luo_test_utils.* into a reusable library From: Vipin Sharma To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org Cc: shuah@kernel.org, dmatlack@google.com, skhawaja@google.com, tarunsahu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Vipin Sharma Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move luo_test_utils.[ch] into a lib/ directory and pull the rules to build them out into a separate make script. This will enable these utilities to be also built by and used within other selftests (such as VFIO). No functional change intended. Signed-off-by: Vipin Sharma Co-developed-by: David Matlack Signed-off-by: David Matlack Signed-off-by: Vipin Sharma Acked-by: Pratyush Yadav (Google) --- tools/testing/selftests/liveupdate/.gitignore | 1 + tools/testing/selftests/liveupdate/Makefile | 14 ++++--------- .../include/libliveupdate.h} | 8 ++++---- .../selftests/liveupdate/lib/libliveupdate.mk | 20 +++++++++++++++++++ .../{luo_test_utils.c =3D> lib/liveupdate.c} | 2 +- .../selftests/liveupdate/luo_kexec_simple.c | 2 +- .../selftests/liveupdate/luo_multi_session.c | 2 +- 7 files changed, 32 insertions(+), 17 deletions(-) rename tools/testing/selftests/liveupdate/{luo_test_utils.h =3D> lib/inclu= de/libliveupdate.h} (87%) create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk rename tools/testing/selftests/liveupdate/{luo_test_utils.c =3D> lib/liveu= pdate.c} (99%) diff --git a/tools/testing/selftests/liveupdate/.gitignore b/tools/testing/= selftests/liveupdate/.gitignore index 661827083ab6..18a0c7036cf3 100644 --- a/tools/testing/selftests/liveupdate/.gitignore +++ b/tools/testing/selftests/liveupdate/.gitignore @@ -3,6 +3,7 @@ !/**/ !*.c !*.h +!*.mk !*.sh !.gitignore !config diff --git a/tools/testing/selftests/liveupdate/Makefile b/tools/testing/se= lftests/liveupdate/Makefile index 080754787ede..a060cc21f27f 100644 --- a/tools/testing/selftests/liveupdate/Makefile +++ b/tools/testing/selftests/liveupdate/Makefile @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only =20 -LIB_C +=3D luo_test_utils.c - TEST_GEN_PROGS +=3D liveupdate =20 TEST_GEN_PROGS_EXTENDED +=3D luo_kexec_simple @@ -10,25 +8,21 @@ TEST_GEN_PROGS_EXTENDED +=3D luo_multi_session TEST_FILES +=3D do_kexec.sh =20 include ../lib.mk +include lib/libliveupdate.mk =20 CFLAGS +=3D $(KHDR_INCLUDES) CFLAGS +=3D -Wall -O2 -Wno-unused-function CFLAGS +=3D -MD =20 -LIB_O :=3D $(patsubst %.c, $(OUTPUT)/%.o, $(LIB_C)) TEST_O :=3D $(patsubst %, %.o, $(TEST_GEN_PROGS)) TEST_O +=3D $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED)) =20 -TEST_DEP_FILES :=3D $(patsubst %.o, %.d, $(LIB_O)) +TEST_DEP_FILES :=3D $(patsubst %.o, %.d, $(LIBLIVEUPDATE_O)) TEST_DEP_FILES +=3D $(patsubst %.o, %.d, $(TEST_O)) -include $(TEST_DEP_FILES) =20 -$(LIB_O): $(OUTPUT)/%.o: %.c - $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ - -$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: %.o $(LIB_O) - $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIB_O) $(LDLIB= S) -o $@ +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: %.o $(LIBLIVEUP= DATE_O) + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBLIVEUPDATE_= O) $(LDLIBS) -o $@ =20 -EXTRA_CLEAN +=3D $(LIB_O) EXTRA_CLEAN +=3D $(TEST_O) EXTRA_CLEAN +=3D $(TEST_DEP_FILES) diff --git a/tools/testing/selftests/liveupdate/luo_test_utils.h b/tools/te= sting/selftests/liveupdate/lib/include/libliveupdate.h similarity index 87% rename from tools/testing/selftests/liveupdate/luo_test_utils.h rename to tools/testing/selftests/liveupdate/lib/include/libliveupdate.h index 90099bf49577..4390a2737930 100644 --- a/tools/testing/selftests/liveupdate/luo_test_utils.h +++ b/tools/testing/selftests/liveupdate/lib/include/libliveupdate.h @@ -7,13 +7,13 @@ * Utility functions for LUO kselftests. */ =20 -#ifndef LUO_TEST_UTILS_H -#define LUO_TEST_UTILS_H +#ifndef SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H +#define SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H =20 #include #include #include -#include "../kselftest.h" +#include "../../../kselftest.h" =20 #define LUO_DEVICE "/dev/liveupdate" =20 @@ -41,4 +41,4 @@ typedef void (*luo_test_stage2_fn)(int luo_fd, int state_= session_fd); int luo_test(int argc, char *argv[], const char *state_session_name, luo_test_stage1_fn stage1, luo_test_stage2_fn stage2); =20 -#endif /* LUO_TEST_UTILS_H */ +#endif /* SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H */ diff --git a/tools/testing/selftests/liveupdate/lib/libliveupdate.mk b/tool= s/testing/selftests/liveupdate/lib/libliveupdate.mk new file mode 100644 index 000000000000..fffd95b085b6 --- /dev/null +++ b/tools/testing/selftests/liveupdate/lib/libliveupdate.mk @@ -0,0 +1,20 @@ +include $(top_srcdir)/scripts/subarch.include +ARCH ?=3D $(SUBARCH) + +LIBLIVEUPDATE_SRCDIR :=3D $(selfdir)/liveupdate/lib + +LIBLIVEUPDATE_C :=3D liveupdate.c + +LIBLIVEUPDATE_OUTPUT :=3D $(OUTPUT)/libliveupdate + +LIBLIVEUPDATE_O :=3D $(patsubst %.c, $(LIBLIVEUPDATE_OUTPUT)/%.o, $(LIBLIV= EUPDATE_C)) + +LIBLIVEUPDATE_O_DIRS :=3D $(shell dirname $(LIBLIVEUPDATE_O) | uniq) +$(shell mkdir -p $(LIBLIVEUPDATE_O_DIRS)) + +CFLAGS +=3D -I$(LIBLIVEUPDATE_SRCDIR)/include + +$(LIBLIVEUPDATE_O): $(LIBLIVEUPDATE_OUTPUT)/%.o : $(LIBLIVEUPDATE_SRCDIR)/= %.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +EXTRA_CLEAN +=3D $(LIBLIVEUPDATE_OUTPUT) diff --git a/tools/testing/selftests/liveupdate/luo_test_utils.c b/tools/te= sting/selftests/liveupdate/lib/liveupdate.c similarity index 99% rename from tools/testing/selftests/liveupdate/luo_test_utils.c rename to tools/testing/selftests/liveupdate/lib/liveupdate.c index 3c8721c505df..60121873f685 100644 --- a/tools/testing/selftests/liveupdate/luo_test_utils.c +++ b/tools/testing/selftests/liveupdate/lib/liveupdate.c @@ -21,7 +21,7 @@ #include #include =20 -#include "luo_test_utils.h" +#include =20 int luo_open_device(void) { diff --git a/tools/testing/selftests/liveupdate/luo_kexec_simple.c b/tools/= testing/selftests/liveupdate/luo_kexec_simple.c index d7ac1f3dc4cb..786ac93b9ae3 100644 --- a/tools/testing/selftests/liveupdate/luo_kexec_simple.c +++ b/tools/testing/selftests/liveupdate/luo_kexec_simple.c @@ -8,7 +8,7 @@ * across a single kexec reboot. */ =20 -#include "luo_test_utils.h" +#include =20 #define TEST_SESSION_NAME "test-session" #define TEST_MEMFD_TOKEN 0x1A diff --git a/tools/testing/selftests/liveupdate/luo_multi_session.c b/tools= /testing/selftests/liveupdate/luo_multi_session.c index 0ee2d795beef..aac24a5f5ce3 100644 --- a/tools/testing/selftests/liveupdate/luo_multi_session.c +++ b/tools/testing/selftests/liveupdate/luo_multi_session.c @@ -9,7 +9,7 @@ * files. */ =20 -#include "luo_test_utils.h" +#include =20 #define SESSION_EMPTY_1 "multi-test-empty-1" #define SESSION_EMPTY_2 "multi-test-empty-2" --=20 2.54.0.563.g4f69b47b94-goog From nobody Sat Jun 13 00:38:47 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 76E1837FF45 for ; Mon, 11 May 2026 20:12:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778530338; cv=none; b=kJ+4t8/M2KURPnP7rmoQ24CrY7Mt/wfSvGeNunHwdibW8BnygmWPH90cbBTXjVb1mOhN6BOS5KE7ZYAtpotxhSGAd18EFPF5MsPJ1ufrqbxjlIh3OJKb5jFPpTmGw768W1FP1zNJYIRine5ibKZGXHfmsYO1ZnlTkx6yqpgypOg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778530338; c=relaxed/simple; bh=LosrAfSQxPVTows0XSpMtnUfobK50ocOZjr+K95JoDw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nDnHU3lFLU5T99BOvOKZLoFeiKPW4lGFaY913NJdjp06goWmJHje85Fh4dQhXJf2optWHUp+c0CVnkdeyTEryLy00ZgO9XVjguIKxqnZLKjvruuqlhEH6G8nIn+vxmoCEWRq2CAH0NovWzPDpFqYxkhTF3X3GSbsN606elPePQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vipinsh.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jKYmkClf; arc=none smtp.client-ip=209.85.216.74 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--vipinsh.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jKYmkClf" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-367d73504f0so3938041a91.1 for ; Mon, 11 May 2026 13:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778530337; x=1779135137; 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=6W1DGO62TtNbBO2D5FHY4ip+Jsk22YoIIigyNl95Iuk=; b=jKYmkClfkELQQdtoojtMi7t9aGwdawOHymKABNWAC0U62iuKtzb1GCPvjkp0/ciARx RrKo6n0Qyae+IWVJLOI+d8DJ7LzhXfdPd76Xwh7y/n8K5uWVATCnRSui2XoPghd1CvqF FpP9BVLeG4513IHG8Z+PC9caRnvgLp7i9sNPcRnelrJFSBtWvfufTlqThmIOO43mV4Hg cXaG4HVAGQhdKHRQMdfp9EzxeckMouxQP4jrTAl/jhdTw0+opAlaj/mAXZMOKJVbypST JnIvB+UFwpbZQOtB8cjA24+KMIsuBKckacajYCrMmx6VWG6+g+vWOounsMDa3qu++G3e 2M6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778530337; x=1779135137; 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=6W1DGO62TtNbBO2D5FHY4ip+Jsk22YoIIigyNl95Iuk=; b=Dw5MD93nBB7ld79HWeu/4KwadiexP5ZPwSCRp0vP3TMj7m9P+hd1wSEbQc7CBQ5QI2 WCU+IoznlirGgcXtKqqyjsFgvpqLeo8k3wgImgxL5swRp0fRBjQrccoLY2xyETFWIads k+AZpAY4Zm5KxpT/U9rIAyjsWMpsv3z8SoC1A72QIc5LQ7kX6g1Los+uHvGCXpLKt8/D AKCjeVj/u6yr5F6R2AwSovqXH1zTPYAkV2s/vWICO0JghIHUZL8ziYGADaX2eiamyR8v GSmsRw+/aLtc3LKK45p+z+bDvQcvrjaRwif0rl7xwMpPBhtFRCDIBw6q7oTPRP4Q2Ezh 2eZw== X-Forwarded-Encrypted: i=1; AFNElJ/8eK2cwCr5EmEftBlof3+HSpJws5CGo5Fm2eIfWJNr20Xxq8wcV60H/dN4dbO3kzenDC6fLk5SFyLJkBU=@vger.kernel.org X-Gm-Message-State: AOJu0YyxoFyN5LnJmyIdBqvk+7ScTei16ZeLYovV39G0Iae9eK5N0PQ7 qUV/a13yZ0aX5oVW1PvKh53Jp43+IW30L00dYBPT7XVWbtrzQo/e9EOwU5tRpYHvds63PaUrj8P 3q+vjZ6NBTQ== X-Received: from pjbsb13.prod.google.com ([2002:a17:90b:50cd:b0:368:a71f:a24a]) (user=vipinsh job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:17ce:b0:35e:3e86:e2d1 with SMTP id 98e67ed59e1d1-367d46b8151mr11314907a91.7.1778530336737; Mon, 11 May 2026 13:12:16 -0700 (PDT) Date: Mon, 11 May 2026 13:11:55 -0700 In-Reply-To: <20260511201155.1488670-1-vipinsh@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260511201155.1488670-1-vipinsh@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260511201155.1488670-3-vipinsh@google.com> Subject: [PATCH 2/2] selftests/liveupdate: Add helpers to preserve/retrieve FDs From: Vipin Sharma To: pasha.tatashin@soleen.com, rppt@kernel.org, pratyush@kernel.org Cc: shuah@kernel.org, dmatlack@google.com, skhawaja@google.com, tarunsahu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Vipin Sharma Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add helper functions to preserve and retrieve file descriptors from an LUO session. This allows library users to work with FD preservation. No functional change intended. Signed-off-by: Vipin Sharma Co-developed-by: David Matlack Signed-off-by: David Matlack Signed-off-by: Vipin Sharma --- .../liveupdate/lib/include/libliveupdate.h | 3 ++ .../selftests/liveupdate/lib/liveupdate.c | 41 +++++++++++++++---- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/liveupdate/lib/include/libliveupdate.h= b/tools/testing/selftests/liveupdate/lib/include/libliveupdate.h index 4390a2737930..2b04b3256382 100644 --- a/tools/testing/selftests/liveupdate/lib/include/libliveupdate.h +++ b/tools/testing/selftests/liveupdate/lib/include/libliveupdate.h @@ -26,6 +26,9 @@ int luo_create_session(int luo_fd, const char *name); int luo_retrieve_session(int luo_fd, const char *name); int luo_session_finish(int session_fd); =20 +int luo_session_preserve_fd(int session_fd, int fd, __u64 token); +int luo_session_retrieve_fd(int session_fd, __u64 token); + int create_and_preserve_memfd(int session_fd, int token, const char *data); int restore_and_verify_memfd(int session_fd, int token, const char *expect= ed_data); =20 diff --git a/tools/testing/selftests/liveupdate/lib/liveupdate.c b/tools/te= sting/selftests/liveupdate/lib/liveupdate.c index 60121873f685..7bc6707d8bb7 100644 --- a/tools/testing/selftests/liveupdate/lib/liveupdate.c +++ b/tools/testing/selftests/liveupdate/lib/liveupdate.c @@ -54,9 +54,35 @@ int luo_retrieve_session(int luo_fd, const char *name) return arg.fd; } =20 +int luo_session_preserve_fd(int session_fd, int fd, __u64 token) +{ + struct liveupdate_session_preserve_fd arg =3D { + .size =3D sizeof(arg), + .fd =3D fd, + .token =3D token, + }; + + if (ioctl(session_fd, LIVEUPDATE_SESSION_PRESERVE_FD, &arg) < 0) + return -errno; + + return 0; +} + +int luo_session_retrieve_fd(int session_fd, __u64 token) +{ + struct liveupdate_session_retrieve_fd arg =3D { + .size =3D sizeof(arg), + .token =3D token, + }; + + if (ioctl(session_fd, LIVEUPDATE_SESSION_RETRIEVE_FD, &arg) < 0) + return -errno; + + return arg.fd; +} + int create_and_preserve_memfd(int session_fd, int token, const char *data) { - struct liveupdate_session_preserve_fd arg =3D { .size =3D sizeof(arg) }; long page_size =3D sysconf(_SC_PAGE_SIZE); void *map =3D MAP_FAILED; int mfd =3D -1, ret =3D -1; @@ -75,9 +101,8 @@ int create_and_preserve_memfd(int session_fd, int token,= const char *data) snprintf(map, page_size, "%s", data); munmap(map, page_size); =20 - arg.fd =3D mfd; - arg.token =3D token; - if (ioctl(session_fd, LIVEUPDATE_SESSION_PRESERVE_FD, &arg) < 0) + ret =3D luo_session_preserve_fd(session_fd, mfd, token); + if (ret) goto out; =20 ret =3D 0; @@ -92,15 +117,13 @@ int create_and_preserve_memfd(int session_fd, int toke= n, const char *data) int restore_and_verify_memfd(int session_fd, int token, const char *expected_data) { - struct liveupdate_session_retrieve_fd arg =3D { .size =3D sizeof(arg) }; long page_size =3D sysconf(_SC_PAGE_SIZE); void *map =3D MAP_FAILED; int mfd =3D -1, ret =3D -1; =20 - arg.token =3D token; - if (ioctl(session_fd, LIVEUPDATE_SESSION_RETRIEVE_FD, &arg) < 0) - return -errno; - mfd =3D arg.fd; + mfd =3D luo_session_retrieve_fd(session_fd, token); + if (mfd < 0) + return mfd; =20 map =3D mmap(NULL, page_size, PROT_READ, MAP_SHARED, mfd, 0); if (map =3D=3D MAP_FAILED) --=20 2.54.0.563.g4f69b47b94-goog