[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251018000713.677779-4-vipinsh@google.com>
Date: Fri, 17 Oct 2025 17:06:55 -0700
From: Vipin Sharma <vipinsh@...gle.com>
To: bhelgaas@...gle.com, alex.williamson@...hat.com, pasha.tatashin@...een.com,
dmatlack@...gle.com, jgg@...pe.ca, graf@...zon.com
Cc: pratyush@...nel.org, gregkh@...uxfoundation.org, chrisl@...nel.org,
rppt@...nel.org, skhawaja@...gle.com, parav@...dia.com, saeedm@...dia.com,
kevin.tian@...el.com, jrhilke@...gle.com, david@...hat.com,
jgowans@...zon.com, dwmw2@...radead.org, epetron@...zon.de,
junaids@...gle.com, linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org,
kvm@...r.kernel.org, linux-kselftest@...r.kernel.org,
Vipin Sharma <vipinsh@...gle.com>
Subject: [RFC PATCH 03/21] selftests/liveupdate: Move do_kexec.sh script to liveupdate/lib
Move do_kexec.sh to lib directory in the liveupdate selftest directory.
Add code in libliveupdate.mk to copy the script to generated
libliveupdate directory during the build.
Script allows liveupdate library users to initiate kexec for liveupdate
test flows.
Signed-off-by: Vipin Sharma <vipinsh@...gle.com>
---
tools/testing/selftests/liveupdate/Makefile | 2 --
.../selftests/liveupdate/{ => lib}/do_kexec.sh | 0
.../liveupdate/lib/include/liveupdate_util.h | 2 ++
.../testing/selftests/liveupdate/lib/libliveupdate.mk | 1 +
.../selftests/liveupdate/lib/liveupdate_util.c | 11 +++++++++++
tools/testing/selftests/liveupdate/luo_multi_file.c | 2 --
tools/testing/selftests/liveupdate/luo_multi_kexec.c | 2 --
.../testing/selftests/liveupdate/luo_multi_session.c | 2 --
tools/testing/selftests/liveupdate/luo_unreclaimed.c | 1 -
9 files changed, 14 insertions(+), 9 deletions(-)
rename tools/testing/selftests/liveupdate/{ => lib}/do_kexec.sh (100%)
diff --git a/tools/testing/selftests/liveupdate/Makefile b/tools/testing/selftests/liveupdate/Makefile
index 79d1c525f03c..f203fd681afe 100644
--- a/tools/testing/selftests/liveupdate/Makefile
+++ b/tools/testing/selftests/liveupdate/Makefile
@@ -9,8 +9,6 @@ LUO_MANUAL_TESTS += luo_multi_kexec
LUO_MANUAL_TESTS += luo_multi_session
LUO_MANUAL_TESTS += luo_unreclaimed
-TEST_FILES += do_kexec.sh
-
LUO_MAIN_TESTS += liveupdate
# --- Automatic Rule Generation (Do not edit below) ---
diff --git a/tools/testing/selftests/liveupdate/do_kexec.sh b/tools/testing/selftests/liveupdate/lib/do_kexec.sh
similarity index 100%
rename from tools/testing/selftests/liveupdate/do_kexec.sh
rename to tools/testing/selftests/liveupdate/lib/do_kexec.sh
diff --git a/tools/testing/selftests/liveupdate/lib/include/liveupdate_util.h b/tools/testing/selftests/liveupdate/lib/include/liveupdate_util.h
index f938ce60edb7..6ee9e124a1a4 100644
--- a/tools/testing/selftests/liveupdate/lib/include/liveupdate_util.h
+++ b/tools/testing/selftests/liveupdate/lib/include/liveupdate_util.h
@@ -11,10 +11,12 @@
#include <linux/liveupdate.h>
#define LUO_DEVICE "/dev/liveupdate"
+#define KEXEC_SCRIPT "libliveupdate/do_kexec.sh"
int luo_open_device(void);
int luo_create_session(int luo_fd, const char *name);
int luo_retrieve_session(int luo_fd, const char *name);
+int luo_session_preserve_fd(int session_fd, int fd, int token);
int luo_set_session_event(int session_fd, enum liveupdate_event event);
int luo_set_global_event(int luo_fd, enum liveupdate_event event);
diff --git a/tools/testing/selftests/liveupdate/lib/libliveupdate.mk b/tools/testing/selftests/liveupdate/lib/libliveupdate.mk
index b3fc2580a7cf..ddb9b1a4363b 100644
--- a/tools/testing/selftests/liveupdate/lib/libliveupdate.mk
+++ b/tools/testing/selftests/liveupdate/lib/libliveupdate.mk
@@ -8,6 +8,7 @@ LIBLIVEUPDATE_O := $(patsubst %.c, $(LIBLIVEUPDATE_OUTPUT)/%.o, $(LIBLIVEUPDATE_
LIBLIVEUPDATE_O_DIRS := $(shell dirname $(LIBLIVEUPDATE_O) | uniq)
$(shell mkdir -p $(LIBLIVEUPDATE_O_DIRS))
+$(shell cp -n $(LIBLIVEUPDATE_SRCDIR)/do_kexec.sh $(LIBLIVEUPDATE_OUTPUT))
CFLAGS += -I$(LIBLIVEUPDATE_SRCDIR)/include
diff --git a/tools/testing/selftests/liveupdate/lib/liveupdate_util.c b/tools/testing/selftests/liveupdate/lib/liveupdate_util.c
index 1e6fd9dd8fb9..26fd6a7763a2 100644
--- a/tools/testing/selftests/liveupdate/lib/liveupdate_util.c
+++ b/tools/testing/selftests/liveupdate/lib/liveupdate_util.c
@@ -30,6 +30,17 @@ int luo_create_session(int luo_fd, const char *name)
return arg.fd;
}
+int luo_session_preserve_fd(int session_fd, int fd, int token)
+{
+ struct liveupdate_session_preserve_fd arg = {
+ .size = sizeof(arg),
+ .fd = fd,
+ .token = token
+ };
+
+ return ioctl(session_fd, LIVEUPDATE_SESSION_PRESERVE_FD, &arg) < 0;
+}
+
int luo_retrieve_session(int luo_fd, const char *name)
{
struct liveupdate_ioctl_retrieve_session arg = { .size = sizeof(arg) };
diff --git a/tools/testing/selftests/liveupdate/luo_multi_file.c b/tools/testing/selftests/liveupdate/luo_multi_file.c
index ae38fe8aba4c..1a4f95046c75 100644
--- a/tools/testing/selftests/liveupdate/luo_multi_file.c
+++ b/tools/testing/selftests/liveupdate/luo_multi_file.c
@@ -7,8 +7,6 @@
#include "luo_test_utils.h"
-#define KEXEC_SCRIPT "./do_kexec.sh"
-
#define SESSION_NAME "multi_file_session"
#define TOKEN_A 101
#define TOKEN_B 102
diff --git a/tools/testing/selftests/liveupdate/luo_multi_kexec.c b/tools/testing/selftests/liveupdate/luo_multi_kexec.c
index 1f350990ee67..5cfecbc6d269 100644
--- a/tools/testing/selftests/liveupdate/luo_multi_kexec.c
+++ b/tools/testing/selftests/liveupdate/luo_multi_kexec.c
@@ -7,8 +7,6 @@
#include "luo_test_utils.h"
-#define KEXEC_SCRIPT "./do_kexec.sh"
-
#define NUM_SESSIONS 3
/* Helper to set up one session and all its files */
diff --git a/tools/testing/selftests/liveupdate/luo_multi_session.c b/tools/testing/selftests/liveupdate/luo_multi_session.c
index 9ea96d7b997f..389d4b559cb3 100644
--- a/tools/testing/selftests/liveupdate/luo_multi_session.c
+++ b/tools/testing/selftests/liveupdate/luo_multi_session.c
@@ -8,8 +8,6 @@
#include "luo_test_utils.h"
#include "../kselftest.h"
-#define KEXEC_SCRIPT "./do_kexec.sh"
-
#define NUM_SESSIONS 5
#define FILES_PER_SESSION 5
diff --git a/tools/testing/selftests/liveupdate/luo_unreclaimed.c b/tools/testing/selftests/liveupdate/luo_unreclaimed.c
index c3921b21b97b..b31bb354bfc3 100644
--- a/tools/testing/selftests/liveupdate/luo_unreclaimed.c
+++ b/tools/testing/selftests/liveupdate/luo_unreclaimed.c
@@ -8,7 +8,6 @@
#include "luo_test_utils.h"
#include "../kselftest.h"
-#define KEXEC_SCRIPT "./do_kexec.sh"
#define SESSION_NAME "unreclaimed_session"
#define TOKEN_A 100
--
2.51.0.858.gf9c4a03a3a-goog
Powered by blists - more mailing lists