liveupdate: Add internal APIs for file preservation
Subsystems (3)
v2 cover liveupdate: Add internal APIs for file preservation
Live update orchestrator file handlers depend on the preservation of other files. To make sure that the dependency is preserved, the file handlers needs to fetch the preservation token of the preserved dependency. Similarly during restore, a file handler wants to fetch the restored file of the dependency.
There are two known usecases of this,
- VFIO-Cdev preservation requires the preservation of iommufd. This is required by the IOMMU preservation series:
https://lore.kernel.org/all/[email protected]/
- guest_memfd preservation requires the preservation of kvmfd. This is required by the guest_memfd preservation series:
https://lore.kernel.org/all/20ae20f9d1a198b289444ebb4c824314cbba1bcf.1780676742.git.tarunsahu@google.com/
This patch was being sent as part of the IOMMU preservation series, but now it is being sent separately.
Note that LUO File Handlers may resolve the dependencies during preserve() as freeze() is very late and past the point of no return. Also FH might have preservation requirements on dependencies due to immutability, security and performance reasons.
v2:
- rebased on liveupdate/next to resolve conflicts
- Added a note about resolution of dependencies based on offline discussion with Pasha and David.
Pasha Tatashin (1):
liveupdate: luo_file: Add internal APIs for file preservation
include/linux/liveupdate.h | 22 ++++++++++ kernel/liveupdate/luo_file.c | 69 ++++++++++++++++++++++++++++++++ kernel/liveupdate/luo_internal.h | 17 ++++++++ 3 files changed, 108 insertions(+)
base-commit: cecfb90c5f2cc0622b363c2291b69d6cad272897
Signature · 1 line
2.55.0.229.g6434b31f56-goog
PATCH v2 1/1 liveupdate: luo_file: Add internal APIs for file preservation
From: Pasha Tatashin <[email protected]>
Live update orchestrator file handlers depend on the preservation of other files. To make sure that the dependency is preserved, the file handlers needs to fetch the preservation token of the preserved dependency. Similarly during restore, a file handler wants to fetch the restored file of the dependency.
Add APIs that allows fetching token of dependency during preservation, and fetching the restored file dependency during restore.
--- include/linux/liveupdate.h | 22 ++++++++++ kernel/liveupdate/luo_file.c | 69 ++++++++++++++++++++++++++++++++ kernel/liveupdate/luo_internal.h | 17 ++++++++ 3 files changed, 108 insertions(+)
include/linux/liveupdate.h +22 -0
@@ -25,6 +25,7 @@ struct file;/** * struct liveupdate_file_op_args - Arguments for file operation callbacks. * @handler: The file handler being called. +* @session: The session this file belongs to. * @retrieve_status: The retrieve status for the 'can_finish / finish' * operation. A value of 0 means the retrieve has not been * attempted, a positive value means the retrieve was
@@ -45,6 +46,7 @@ struct file;*/ struct liveupdate_file_op_args {struct liveupdate_file_handler *handler; +struct liveupdate_session *session;int retrieve_status;struct file *file;u64 serialized_data;
@@ -247,6 +249,14 @@ void liveupdate_flb_put_incoming(struct liveupdate_flb *flb);int liveupdate_flb_get_outgoing (struct liveupdate_flb *flb,void **objp);void liveupdate_flb_put_outgoing (struct liveupdate_flb *flb); +/* kernel can internally retrieve files */ +int liveupdate_get_file_incoming (struct liveupdate_session *s,u64 token, +struct file **filep); + +/* Get a token for an outgoing file, or -ENOENT if file is not preserved */ +int liveupdate_get_token_outgoing (struct liveupdate_session *s, +struct file *file,u64 *tokenp); +#else /* CONFIG_LIVEUPDATE */ static inline bool liveupdate_enabled (void )
@@ -299,5 +309,17 @@ static inline void liveupdate_flb_put_outgoing(struct liveupdate_flb *flb) { } +static inline int liveupdate_get_file_incoming (struct liveupdate_session *s, +u64 token,struct file **filep) +{ +return -EOPNOTSUPP ; +} + +static inline int liveupdate_get_token_outgoing (struct liveupdate_session *s, +struct file *file,u64 *tokenp) +{ +return -EOPNOTSUPP ; +} +#endif /* CONFIG_LIVEUPDATE */ #endif /* _LINUX_LIVEUPDATE_H */
kernel/liveupdate/luo_file.c +69 -0
114 lines not on this page · raw message
kernel/liveupdate/luo_internal.h +17 -0
@@ -77,6 +77,23 @@ struct luo_session {extern struct rw_semaphore luo_register_rwlock; +static inline struct liveupdate_session *luo_session_from_file_set (struct luo_file_set *file_set) +{ +struct luo_session *session; + + session = container_of(file_set, struct luo_session, file_set); + +return (struct liveupdate_session *)session; +} + +static inline struct luo_file_set *luo_file_set_from_session_locked (struct liveupdate_session *s) +{ +struct luo_session *session = (struct luo_session *)s; + +lockdep_assert_held (&session->mutex); +return &session->file_set; +} +int luo_session_create (const char *name,struct file **filep);int luo_session_retrieve (const char *name,struct file **filep);void __init luo_session_setup_outgoing (u64 *sessions_pa);
Signature · 1 line
2.55.0.229.g6434b31f56-goog
Quoted 9 lines · Samiullah Khawaja
liveupdate: Add internal APIs for file preservation
Live update orchestrator file handlers depend on the preservation of other files. To make sure that the dependency is preserved, the file handlers needs to fetch the preservation token of the preserved dependency. Similarly during restore, a file handler wants to fetch the restored file of the dependency.
[...]
Applied to luo-internal-api branch of liveupdate/linux.git tree, thanks!
[1/1] liveupdate: luo_file: Add internal APIs for file preservation
commit: f4d2e4f0d12d88155cd1128ed3294f7827bf4c5d
tree: https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux
branch: luo-internal-api
--
Sincerely yours,
Mike.