Re: [PATCH 2/2] selftests/liveupdate: Add helpers to preserve/retrieve FDs

From: Pratyush Yadav

Date: Mon Jun 08 2026 - 10:41:56 EST


On Mon, May 18 2026, Vipin Sharma wrote:

> On Mon, May 18, 2026 at 11:29:49AM +0000, tarunsahu@xxxxxxxxxx wrote:
>> Vipin Sharma <vipinsh@xxxxxxxxxx> writes:
>>
>> > 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 <vipinsh@xxxxxxxxxx>
>> > Co-developed-by: David Matlack <dmatlack@xxxxxxxxxx>
>> > Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
>> > Signed-off-by: Vipin Sharma <vipinsh@xxxxxxxxxx>
>> > ---
>> > .../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);
>> >
>> > +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);
>> >
>> > diff --git a/tools/testing/selftests/liveupdate/lib/liveupdate.c b/tools/testing/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;
>> > }
>> >
>> > +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;
>> > +
>> > + return 0;
>> > +}
>> > +
>> > +int luo_session_retrieve_fd(int session_fd, __u64 token)
>> nit: Can add a comment that, once it is failed, retrieved status is saved,
>> So it is permanent failure.
>
> I think appropriate place will be the official documentation which is
> here include/uapi/linux/liveupdate.h
>
> I don't see it is mentioned in the documentation (yes, code does what
> you have said), I will refrain from adding that comment here.

Would be a good addition to the LUO docs I think. Patches welcome :-)

[...]

--
Regards,
Pratyush Yadav