Make liveupdate selftests library
Subsystems (3)
v2 cover Make liveupdate selftests library
Hello,
This is v2 series of refactoring liveupdate selftests as a library. It exposes common liveupdate ioctls as a library which can be used by other selftests like VFIO and IOMMU.
Currently, there are no users of this change but it is being used in VFIO and iommu liveupdate series.
https://lore.kernel.org/kvm/[email protected]/
https://lore.kernel.org/linux-iommu/[email protected]/
I think it is better to move the patches out from the above series and propose them as a separate series for inclusion in liveupdate repo. That way we can decouple multiple downstream dependencies and then it can be used by VFIO, IOMMU, and KVM (guest_memfd preservation) separately.
v2:
- Addressed Sashiko feedback regarding folder creation.
https://sashiko.dev/#/patchset/20260511201155.1488670-1-vipinsh%40google.com
- Update liveupdate.c test to use ioctl wrappers in library
v1: https://lore.kernel.org/all/[email protected]/
Vipin Sharma (2):
selftests/liveupdate: Move luo_test_utils.* into a reusable library selftests/liveupdate: Add helpers to preserve/retrieve FDs
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 ++----
.../include/libliveupdate.h} | 10 +++--
.../selftests/liveupdate/lib/libliveupdate.mk | 20 +++++++++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++++++++++++++-----
.../testing/selftests/liveupdate/liveupdate.c | 40 ++++++-----------
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
.../selftests/liveupdate/luo_stress_files.c | 2 +-
.../liveupdate/luo_stress_sessions.c | 2 +-
10 files changed, 81 insertions(+), 55 deletions(-)
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (91%)base-commit: 3a358c78093f98a70d84c934b7054f636bc846f2
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog
PATCH v2 1/2 selftests/liveupdate: Move luo_test_utils.* into a reusable library
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.
---
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 => lib/liveupdate.c} | 2 +-
.../testing/selftests/liveupdate/liveupdate.c | 2 +-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
.../selftests/liveupdate/luo_stress_files.c | 2 +-
.../liveupdate/luo_stress_sessions.c | 2 +-
10 files changed, 35 insertions(+), 20 deletions(-)
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (87%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (99%)tools/testing/selftests/liveupdate/.gitignore +1 -0
@@ -3,6 +3,7 @@ !/**/ !*.c !*.h +!*.mk !*.sh !.gitignore !config
tools/testing/selftests/liveupdate/Makefile +4 -10
@@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -LIB_C += luo_test_utils.c - TEST_GEN_PROGS += liveupdate TEST_GEN_PROGS_EXTENDED += luo_kexec_simple
@@ -12,25 +10,21 @@ TEST_GEN_PROGS_EXTENDED += luo_stress_files TEST_FILES += do_kexec.sh include ../lib.mk +include lib/libliveupdate.mk CFLAGS += $(KHDR_INCLUDES) CFLAGS += -Wall -O2 -Wno-unused-function CFLAGS += -MD -LIB_O := $(patsubst %.c, $(OUTPUT)/%.o, $(LIB_C)) TEST_O := $(patsubst %, %.o, $(TEST_GEN_PROGS)) TEST_O += $(patsubst %, %.o, $(TEST_GEN_PROGS_EXTENDED)) -TEST_DEP_FILES := $(patsubst %.o, %.d, $(LIB_O)) +TEST_DEP_FILES := $(patsubst %.o, %.d, $(LIBLIVEUPDATE_O)) TEST_DEP_FILES += $(patsubst %.o, %.d, $(TEST_O)) -include $(TEST_DEP_FILES) -$(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) $(LDLIBS) -o $@ +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/%: %.o $(LIBLIVEUPDATE_O) + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) $< $(LIBLIVEUPDATE_O) $(LDLIBS) -o $@ -EXTRA_CLEAN += $(LIB_O) EXTRA_CLEAN += $(TEST_O) EXTRA_CLEAN += $(TEST_DEP_FILES)
tools/testing/selftests/liveupdate/lib/include/libliveupdate.h renamed from tools/testing/selftests/liveupdate/luo_test_utils.h +4 -4
@@ -7,13 +7,13 @@* Utility functions for LUO kselftests. */ -#ifndef LUO_TEST_UTILS_H -#define LUO_TEST_UTILS_H +#ifndef SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H +#define SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H #include <errno.h> #include <string.h> #include <linux/liveupdate.h> -#include "../kselftest.h" +#include "../../../kselftest.h" #define LUO_DEVICE "/dev/liveupdate"
@@ -43,4 +43,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); -#endif /* LUO_TEST_UTILS_H */ +#endif /* SELFTESTS_LIVEUPDATE_LIB_LIVEUPDATE_H */
tools/testing/selftests/liveupdate/lib/libliveupdate.mk new file +20 -0
@@ -0,0 +1,20 @@ +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) + +LIBLIVEUPDATE_SRCDIR := $(selfdir)/liveupdate/lib + +LIBLIVEUPDATE_C := liveupdate.c + +LIBLIVEUPDATE_OUTPUT := $(OUTPUT)/libliveupdate + +LIBLIVEUPDATE_O := $(patsubst %.c, $(LIBLIVEUPDATE_OUTPUT)/%.o, $(LIBLIVEUPDATE_C)) + +CFLAGS += -I$(LIBLIVEUPDATE_SRCDIR)/include + +$(LIBLIVEUPDATE_OUTPUT): + $(Q)mkdir -p $@ + +$(LIBLIVEUPDATE_O): $(LIBLIVEUPDATE_OUTPUT)/%.o : $(LIBLIVEUPDATE_SRCDIR)/%.c | $(LIBLIVEUPDATE_OUTPUT) + $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +EXTRA_CLEAN += $(LIBLIVEUPDATE_OUTPUT)
tools/testing/selftests/liveupdate/lib/liveupdate.c renamed from tools/testing/selftests/liveupdate/luo_test_utils.c +1 -1
@@ -22,7 +22,7 @@#include <errno.h> #include <stdarg.h> -#include "luo_test_utils.h" +#include <libliveupdate.h> int luo_open_device (void ) {
tools/testing/selftests/liveupdate/liveupdate.c +1 -1
@@ -25,8 +25,8 @@#include <unistd.h> #include <linux/liveupdate.h> +#include <libliveupdate.h> -#include "luo_test_utils.h" #include "../kselftest.h" #include "../kselftest_harness.h"
tools/testing/selftests/liveupdate/luo_kexec_simple.c +1 -1
@@ -8,7 +8,7 @@* across a single kexec reboot. */ -#include "luo_test_utils.h" +#include <libliveupdate.h> #define TEST_SESSION_NAME "test-session"#define TEST_MEMFD_TOKEN 0x1A
tools/testing/selftests/liveupdate/luo_multi_session.c +1 -1
@@ -9,7 +9,7 @@* files. */ -#include "luo_test_utils.h" +#include <libliveupdate.h> #define SESSION_EMPTY_1 "multi-test-empty-1"#define SESSION_EMPTY_2 "multi-test-empty-2"
tools/testing/selftests/liveupdate/luo_stress_files.c +1 -1
@@ -10,7 +10,7 @@#include <stdio.h> #include <unistd.h> -#include "luo_test_utils.h" +#include <libliveupdate.h> #define NUM_FILES 500#define STATE_SESSION_NAME "kexec_many_files_state"
tools/testing/selftests/liveupdate/luo_stress_sessions.c +1 -1
@@ -10,7 +10,7 @@#include <stdio.h> #include <unistd.h> -#include "luo_test_utils.h" +#include <libliveupdate.h> #define NUM_SESSIONS 2000#define STATE_SESSION_NAME "kexec_many_state"
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog
Pasha Tatashin
maintainerRe: [PATCH v2 1/2] selftests/liveupdate: Move luo_test_utils.* into a reusable library
tools/testing/selftests/liveupdate/lib/libliveupdate.mk line 20
Quoted 13 lines · Vipin Sharma
tools/testing/selftests/liveupdate/lib/libliveupdate.mk new file +0
-0@@ -0,0 +1,20 @@[ ... skip 14 lines ... ]
tools/testing/selftests/liveupdate/lib/libliveupdate.mk new file +6
-0+ $(Q)mkdir -p $@ + +$(LIBLIVEUPDATE_O): $(LIBLIVEUPDATE_OUTPUT)/%.o : $(LIBLIVEUPDATE_SRCDIR)/%.c | $(LIBLIVEUPDATE_OUTPUT) + $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +EXTRA_CLEAN += $(LIBLIVEUPDATE_OUTPUT)
since this file contains utility functions (luo_open_device, luo_test, etc.), naming it liveupdate.c makes it sound like the main implementation rather than a test helper library. Using something distinct like lu_utils.c would make more sense.
Quoted 9 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c renamed from tools/testing/selftests/liveupdate/luo_test_utils.c +0
-0
tools/testing/selftests/liveupdate/lib/liveupdate.c line 25
Quoted 5 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c renamed from tools/testing/selftests/liveupdate/luo_test_utils.c +1
-1@@ -22,7 +22,7 @@#include <errno.h> #include <stdarg.h> -#include "luo_test_utils.h" +#include <libliveupdate.h>
Linux kernel coding style generally prefers block headers to be sorted alphabetically.
tools/testing/selftests/liveupdate/liveupdate.c line 28
Quoted 10 lines
tools/testing/selftests/liveupdate/liveupdate.c +1
-0@@ -25,8 +25,8 @@#include <unistd.h> #include <linux/liveupdate.h> +#include <libliveupdate.h>
Please sort alphabetically
Signature · 1 line
Pasha Tatashin <[email protected]>
Re: [PATCH v2 1/2] selftests/liveupdate: Move luo_test_utils.* into a reusable library
Quoted 11 lines · Pasha Tatashin
Quoted 10 lines · Vipin Sharma
tools/testing/selftests/liveupdate/lib/libliveupdate.mk new file +0
-0@@ -0,0 +1,20 @@[ ... skip 14 lines ... ]
tools/testing/selftests/liveupdate/lib/libliveupdate.mk new file +3
-0+ $(Q)mkdir -p $@ + +$(LIBLIVEUPDATE_O): $(LIBLIVEUPDATE_OUTPUT)/%.o : $(LIBLIVEUPDATE_SRCDIR)/%.c | $(LIBLIVEUPDATE_OUTPUT)
Quoted 8 lines
tools/testing/selftests/liveupdate/lib/libliveupdate.mk line 20
Quoted 3 lines
tools/testing/selftests/liveupdate/lib/libliveupdate.mk new file +3
-0+ $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ + +EXTRA_CLEAN += $(LIBLIVEUPDATE_OUTPUT)since this file contains utility functions (
luo_open_device,luo_test, etc.), naming itliveupdate.cmakes it sound like the main implementation rather than a test helper library. Using something distinct likelu_utils.cwould make more sense.
Okay, I will rename the new file to lu_utils.[ch]
Quoted 13 lines
Quoted 13 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c renamed from tools/testing/selftests/liveupdate/luo_test_utils.c +0
-0@@ -22,7 +22,7 @@#include <errno.h> #include <stdarg.h>
Quoted 6 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c line 25
Quoted 2 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c renamed from tools/testing/selftests/liveupdate/luo_test_utils.c +1
-1-#include "luo_test_utils.h" +#include <libliveupdate.h> Linux kernel coding style generally prefers block headers to be sorted alphabetically.
Okay, I will reoder them here and in the other files.
Thanks!
PATCH v2 2/2 selftests/liveupdate: Add helpers to preserve/retrieve FDs
In reply to Vipin SharmaAdd helper functions to preserve and retrieve file descriptors from an LUO session. This allows library users to work with FD preservation.
Now that there are helpers, use them instead of direct ioctl calls in liveupdate.c
No functional change intended.
--- .../liveupdate/lib/include/libliveupdate.h | 2 + .../selftests/liveupdate/lib/liveupdate.c | 41 +++++++++++++++---- .../testing/selftests/liveupdate/liveupdate.c | 38 ++++++----------- 3 files changed, 46 insertions(+), 35 deletions(-)
tools/testing/selftests/liveupdate/lib/include/libliveupdate.h +2 -0
@@ -27,6 +27,8 @@ int luo_retrieve_session(int luo_fd, const char *name);int luo_session_finish (int session_fd);int luo_ensure_nofile_limit (long min_limit); +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 *expected_data);
tools/testing/selftests/liveupdate/lib/liveupdate.c +32 -9
65 lines not on this page · raw message
tools/testing/selftests/liveupdate/liveupdate.c +12 -26
@@ -170,20 +170,6 @@ TEST_F(liveupdate_device, create_distinct_sessions)ASSERT_EQ (close (session_fd2),0 ); } -static int preserve_fd (int session_fd,int fd_to_preserve,__u64 token) -{ -struct liveupdate_session_preserve_fd args = {}; - - args.size =sizeof (args); - args.fd = fd_to_preserve; - args.token = token; - -if (ioctl (session_fd,LIVEUPDATE_SESSION_PRESERVE_FD , &args)) -return -errno; - -return 0 ; -} -/* * Test Case: Preserve MemFD *
@@ -208,7 +194,7 @@ TEST_F(liveupdate_device, preserve_memfd)ASSERT_GE (mem_fd,0 );ASSERT_EQ (write (mem_fd, test_str,strlen (test_str)),strlen (test_str)); -ASSERT_EQ (preserve_fd (session_fd, mem_fd,0x1234 ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd, mem_fd,0x1234 ),0 );ASSERT_EQ (close (session_fd),0 );ASSERT_EQ (lseek (mem_fd,0 ,SEEK_SET ),0 );
@@ -247,8 +233,8 @@ TEST_F(liveupdate_device, preserve_multiple_memfds)ASSERT_EQ (write (mem_fd1, test_str1,strlen (test_str1)),strlen (test_str1));ASSERT_EQ (write (mem_fd2, test_str2,strlen (test_str2)),strlen (test_str2)); -ASSERT_EQ (preserve_fd (session_fd, mem_fd1,0xAAAA ),0 ); -ASSERT_EQ (preserve_fd (session_fd, mem_fd2,0xBBBB ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd, mem_fd1,0xAAAA ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd, mem_fd2,0xBBBB ),0 );memset (read_buf,0 ,sizeof (read_buf));ASSERT_EQ (lseek (mem_fd1,0 ,SEEK_SET ),0 );
@@ -303,10 +289,10 @@ TEST_F(liveupdate_device, preserve_complex_scenario) mem_fd_empty2 =memfd_create ("empty2" ,0 );ASSERT_GE (mem_fd_empty2,0 ); -ASSERT_EQ (preserve_fd (session_fd1, mem_fd_data1,0x1111 ),0 ); -ASSERT_EQ (preserve_fd (session_fd1, mem_fd_empty1,0x2222 ),0 ); -ASSERT_EQ (preserve_fd (session_fd2, mem_fd_data2,0x3333 ),0 ); -ASSERT_EQ (preserve_fd (session_fd2, mem_fd_empty2,0x4444 ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd1, mem_fd_data1,0x1111 ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd1, mem_fd_empty1,0x2222 ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd2, mem_fd_data2,0x3333 ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd2, mem_fd_empty2,0x4444 ),0 );ASSERT_EQ (lseek (mem_fd_data1,0 ,SEEK_SET ),0 );ASSERT_EQ (read (mem_fd_data1, read_buf,sizeof (read_buf)),strlen (data1));
@@ -355,7 +341,7 @@ TEST_F(liveupdate_device, preserve_unsupported_fd) unsupported_fd =open ("/dev/null" ,O_RDWR );ASSERT_GE (unsupported_fd,0 ); - ret =preserve_fd (session_fd, unsupported_fd,0xDEAD ); + ret =luo_session_preserve_fd (session_fd, unsupported_fd,0xDEAD );EXPECT_EQ (ret, -ENOENT );ASSERT_EQ (close (unsupported_fd),0 );
@@ -388,14 +374,14 @@ TEST_F(liveupdate_device, prevent_double_preservation)ASSERT_GE (mem_fd,0 );/* First preservation should succeed */ -ASSERT_EQ (preserve_fd (session_fd1, mem_fd,0x1111 ),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd1, mem_fd,0x1111 ),0 );/* Second preservation in a different session should fail with EBUSY */ - ret =preserve_fd (session_fd2, mem_fd,0x2222 ); + ret =luo_session_preserve_fd (session_fd2, mem_fd,0x2222 );EXPECT_EQ (ret, -EBUSY );/* Second preservation in the same session (different token) should fail with EBUSY */ - ret =preserve_fd (session_fd1, mem_fd,0x3333 ); + ret =luo_session_preserve_fd (session_fd1, mem_fd,0x3333 );EXPECT_EQ (ret, -EBUSY );ASSERT_EQ (close (mem_fd),0 );
@@ -565,7 +551,7 @@ TEST_F(liveupdate_device, preserve_many_files)for (i =0 ; i <MANY_FILES ; i++) { mem_fds[i] =memfd_create ("test-memfd" ,0 );ASSERT_GE (mem_fds[i],0 ); -ASSERT_EQ (preserve_fd (session_fd, mem_fds[i], i),0 ); +ASSERT_EQ (luo_session_preserve_fd (session_fd, mem_fds[i], i),0 ); }for (i =0 ; i <MANY_FILES ; i++)
Signature · 1 line
2.54.0.1099.g489fc7bff1-goog
Re: [PATCH v2 2/2] selftests/liveupdate: Add helpers to preserve/retrieve FDs
Quoted 11 lines · Vipin Sharma
Add helper functions to preserve and retrieve file descriptors from an LUO session. This allows library users to work with FD preservation.
Now that there are helpers, use them instead of direct ioctl calls in
liveupdate.cNo functional change intended.
Co-developed-by David Matlack <[email protected]>Signed-off-by David Matlack <[email protected]>Signed-off-by Vipin Sharma <[email protected]>
[...]
Signature · 2 lines
Regards, Pratyush Yadav
Re: [PATCH v2 2/2] selftests/liveupdate: Add helpers to preserve/retrieve FDs
In reply to Vipin SharmaQuoted 8 lines · Vipin Sharma
tools/testing/selftests/liveupdate/lib/liveupdate.c +0
-0@@ -78,9 +78,35 @@ int luo_retrieve_session(int luo_fd, const char *name)return arg.fd; }
tools/testing/selftests/liveupdate/lib/liveupdate.c int luo_retrieve_session(int luo_fd, const char *name) · line 90
Quoted 10 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c +10
-0+int luo_session_preserve_fd (int session_fd,int fd,__u64 token) +{ +struct liveupdate_session_preserve_fd arg = { + .size =sizeof (arg), + .fd = fd, + .token = token, + }; + +if (ioctl (session_fd,LIVEUPDATE_SESSION_PRESERVE_FD , &arg) <0 ) +return -errno;
We do not return positive values on success either, so !ioctl() would be a tighter check, but < 0 is also acceptable.
Signature · 1 line
Pasha Tatashin <[email protected]>
Re: [PATCH v2 2/2] selftests/liveupdate: Add helpers to preserve/retrieve FDs
Quoted 23 lines · Pasha Tatashin
Quoted 8 lines · Vipin Sharma
tools/testing/selftests/liveupdate/lib/liveupdate.c +0
-0@@ -78,9 +78,35 @@ int luo_retrieve_session(int luo_fd, const char *name)return arg.fd; }tools/testing/selftests/liveupdate/lib/liveupdate.c int luo_retrieve_session(int luo_fd, const char *name) · line 90
Quoted 10 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c +10
-0+int luo_session_preserve_fd (int session_fd,int fd,__u64 token) +{ +struct liveupdate_session_preserve_fd arg = { + .size =sizeof (arg), + .fd = fd, + .token = token, + }; + +if (ioctl (session_fd,LIVEUPDATE_SESSION_PRESERVE_FD , &arg) <0 ) +return -errno;We do not return positive values on success either, so !ioctl() would be a tighter check, but < 0 is also acceptable.
Quoted 1 line
Reviewed-by Pasha Tatashin <[email protected]>
I have to send v3 for other feedbacks, I will address this also in that version.
Thanks!
Re: [PATCH v2 2/2] selftests/liveupdate: Add helpers to preserve/retrieve FDs
Quoted 24 lines · Vipin Sharma
Quoted 23 lines · Pasha Tatashin
Quoted 8 lines · Vipin Sharma
tools/testing/selftests/liveupdate/lib/liveupdate.c +0
-0@@ -78,9 +78,35 @@ int luo_retrieve_session(int luo_fd, const char *name)return arg.fd; }tools/testing/selftests/liveupdate/lib/liveupdate.c int luo_retrieve_session(int luo_fd, const char *name) · line 90
Quoted 10 lines
tools/testing/selftests/liveupdate/lib/liveupdate.c +10
-0+int luo_session_preserve_fd (int session_fd,int fd,__u64 token) +{ +struct liveupdate_session_preserve_fd arg = { + .size =sizeof (arg), + .fd = fd, + .token = token, + }; + +if (ioctl (session_fd,LIVEUPDATE_SESSION_PRESERVE_FD , &arg) <0 ) +return -errno;We do not return positive values on success either, so !ioctl() would be a tighter check, but < 0 is also acceptable.
Quoted 4 lines
Quoted 1 line
Reviewed-by Pasha Tatashin <[email protected]>I have to send v3 for other feedbacks, I will address this also in that version.
I forgot this before, other two ioctls LIVEUPDATE_IOCTL_CREATE_SESSION and LIVEUPDATE_IOCTL_RETRIEVE_SESSION are using the same pattern of checking with '< 0'. Lets keep it same, I can send a separate patch if there is a desire to use tighter check.