checkpoint-restore / criu

Checkpoint/Restore tool
criu.org
Other
2.77k stars 561 forks source link

Question: Is there a method modifying environment variable in restore? #2290

Open cgxu519 opened 8 months ago

cgxu519 commented 8 months ago

Description In our use case, we need set unique uuid through environment variable for every instance which restored from checkpoint, are there any restore options for this purpose?

Steps to reproduce the issue: 1. 2. 3.

Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

CRIU logs and information:

CRIU full dump/restore logs:

``` (paste your output here) ```

Output of `criu --version`:

``` (paste your output here) ```

Output of `criu check --all`:

``` (paste your output here) ```

Additional environment details:

adrianreber commented 8 months ago

In our use case, we need set unique uuid through environment variable for every instance which restored from checkpoint, are there any restore options for this purpose?

It depends. Changing a UUID should be possible. If it is the same length. Take a look at https://github.com/checkpoint-restore/checkpointctl to see how it displays the environment variable of a checkpointed container. But that will just change the environment variable and not the value stored in the memory of your restored process.

So if your restored process already did a getenv(), changing the environment variable before restore will only works if you do a getenv() after restore again to re-read it. If it is already loaded into memory of your process, changing the variable will not do anything. So you need to signal your process to re-read the environment variable. If you do that you could just have an interface in your process to get new values instead of changing CRIU image files an running getenv() again. That would sound simpler from my point of view.

cgxu519 commented 8 months ago

It depends. Changing a UUID should be possible. If it is the same length. Take a look at https://github.com/checkpoint-restore/checkpointctl to see how it displays the environment variable of a checkpointed container. But that will just change the environment variable and not the value stored in the memory of your restored process.

Thanks for the explanation. Our UUIDs are all in same length and now I get to know how to change the initial env for a restored process. However, if a process has changed the environment variable before checkpoint, the pointer of environment variable table might move to a new location (environ pointer in heap area), Any suggestion for this case?

adrianreber commented 8 months ago

Sorry, I don't think I understand your question and I am not sure if it is about CRIU or something else.

github-actions[bot] commented 7 months ago

A friendly reminder that this issue had no activity for 30 days.