Skip to content

Conversation

StevenFryto
Copy link
Contributor

Previously, the rootlessDir variable in src/runtime/virtcontainers/pkg/rootless.go was initialized at package load time using os.Getenv("XDG_RUNTIME_DIR"). However, in rootless VMM mode, the correct value of $XDG_RUNTIME_DIR is set later during runtime using os.Setenv(), so rootlessDir remained empty.

This patch defers the initialization of rootlessDir until the first call to GetRootlessDir(), ensuring it always reflects the current environment value of $XDG_RUNTIME_DIR.

Fixes: #11526

Copy link
Member

@justxuewei justxuewei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, thanks!

@justxuewei
Copy link
Member

@StevenFryto Commit message check throws the following error.

  4ce840ce267b6743a108db1606a49aa5fb5f69a6    Expected "stevenfryto <sunzitai_1832@bupt.edu.cn>", but got "Zitai Sun <sunzitai_1832@bupt.edu.cn>".

I checked your commit using git show HEAD, and found that commit author and S-o-b author do not match

commit 4ce840ce267b6743a108db1606a49aa5fb5f69a6 (HEAD -> fix-runtime-rootless-bugs)
Author: stevenfryto <sunzitai_1832@bupt.edu.cn>
Date:   Mon Jul 7 05:43:01 2025 +0000

    runtime: Fix rootlessDir not correctly set in rootless VMM mode
// ...

To append the correct S-o-b, execute git commit --amend -s.

@StevenFryto StevenFryto force-pushed the fix-runtime-rootless-bugs branch from 4ce840c to a033295 Compare July 8, 2025 22:52
@StevenFryto
Copy link
Contributor Author

@StevenFryto Commit message check throws the following error.

  4ce840ce267b6743a108db1606a49aa5fb5f69a6    Expected "stevenfryto <sunzitai_1832@bupt.edu.cn>", but got "Zitai Sun <sunzitai_1832@bupt.edu.cn>".

I checked your commit using git show HEAD, and found that commit author and S-o-b author do not match

commit 4ce840ce267b6743a108db1606a49aa5fb5f69a6 (HEAD -> fix-runtime-rootless-bugs)
Author: stevenfryto <sunzitai_1832@bupt.edu.cn>
Date:   Mon Jul 7 05:43:01 2025 +0000

    runtime: Fix rootlessDir not correctly set in rootless VMM mode
// ...

To append the correct S-o-b, execute git commit --amend -s.

Thanks, I’ve updated the commit metadata as suggested.

Previously, the rootlessDir variable in `src/runtime/virtcontainers/pkg/rootless.go` was initialized at
package load time using `os.Getenv("XDG_RUNTIME_DIR")`. However, in rootless
VMM mode, the correct value of $XDG_RUNTIME_DIR is set later during runtime
using os.Setenv(), so rootlessDir remained empty.

This patch defers the initialization of rootlessDir until the first call
to `GetRootlessDir()`, ensuring it always reflects the current environment
value of $XDG_RUNTIME_DIR.

Fixes: kata-containers#11526

Signed-off-by: stevenfryto <sunzitai_1832@bupt.edu.cn>
@justxuewei justxuewei force-pushed the fix-runtime-rootless-bugs branch from a033295 to 3c7a670 Compare July 9, 2025 01:51
Copy link
Contributor

@Apokleos Apokleos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @StevenFryto LGTM

@justxuewei justxuewei merged commit b883814 into kata-containers:main Jul 9, 2025
678 of 716 checks passed
@StevenFryto StevenFryto deleted the fix-runtime-rootless-bugs branch July 11, 2025 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

runtime: KataHostSharedDir should be created under /run/user/<uid>/ in rootless VMM mode
4 participants