Commit ed2e5d40 authored by Pawel Stradomski's avatar Pawel Stradomski Committed by Andrei Vagin

Fall back to opening image files readonly if readwrite fails.

This can happen when running in user namespace with auto-dedup enabled.
Right now this means auto-dedup gets disabled.
Signed-off-by: 's avatarPawel Stradomski <pstradomski@google.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent d5169560
...@@ -1304,6 +1304,15 @@ static int prepare_vma_ios(struct pstree_item *t, struct task_restore_args *ta) ...@@ -1304,6 +1304,15 @@ static int prepare_vma_ios(struct pstree_item *t, struct task_restore_args *ta)
*/ */
pages = open_image(CR_FD_PAGES, opts.auto_dedup ? O_RDWR : O_RSTR, pages = open_image(CR_FD_PAGES, opts.auto_dedup ? O_RDWR : O_RSTR,
rsti(t)->pages_img_id); rsti(t)->pages_img_id);
/* When running inside namespace we might lack privileges to open the file
* for writing.
* TODO: use userns_call to do the opening instead of downgrading to opening
* read-only.
*/
if (!pages && opts.auto_dedup) {
pr_warn("Failed to open image read-write, trying read-only instead. auto-dedup won't work\n");
pages = open_image(CR_FD_PAGES, O_RSTR, rsti(t)->pages_img_id);
}
if (!pages) if (!pages)
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment