-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEENG-42 - Add reboot/shutdown feature on launcher side #56
Conversation
c50140f
to
f9c981e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @patrick330602 !
There are some issues blocking compilation and needed to be addressed.
As I started to check those, I came to think of suggestions that could make easier to implement the feature you're working on. Please consider those approaches and maybe doing so we can avoid adding dependencies. Let me know if I'm being naive in those considerations.
- We can avoid adding more deps. - That modifies files which may conflict with upstream in the future. - Also the pipe thing can be simplified.
- Pipe not needed to read a file inside Linux filesystem. - Shutdown and relaunch the distro now by using `_wsystem`. - Removed dependences of Shell32.lib and Shlwapi.lib.
255c113
to
f9c981e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to approve what I requested to change in order to stop being a reviewer and request review.
Apart from the conflict which is very straightforward to fix, @didrocks, could you please review that code? I just noticed we don't really shutdown the VM in this feature. Writting to In my machine at least, editing the registry the right key in Previously we had that pipe code reading The way I see to solve this issue is make Subiquity write a file aside of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just work out the ^M issue, but otherwise looks good to me :)
DistroLauncher/OOBE.cpp
Outdated
CloseHandle(writePipe); | ||
// read the OOBE exit status file. | ||
// Even without interop activated Windows can still access Linux files under WSL. | ||
const TCHAR* launcherStatusPath = L"/run/subiquity/launcher-status"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this file to something else, as we may reuse it for other things to tell the launcher to reboot/shutdown.
So maybe /run/launcher-command
directly or any better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine. We just need to update Subiquity accordingly. If we go with my other suggestion, on the default UID, I'd like to have them close, in the same directory, but separate to make things simple. Of course we could read the /etc/wsl.conf generated by the OOBE, find the username and call this function (or do what it does: launch id -u
, create a pipe to read the stdout and register the uid as the default):
WSL/DistroLauncher/DistroLauncher.cpp
Line 61 in dd78a1a
HRESULT SetDefaultUser(std::wstring_view userName) |
Two files of one word each seems simpler and straightforward to me. If you believe that could be somewhat error prone due lack of validation, we can move to some standard syntax, like yaml or ini and put both pieces of information on the same file.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course we could read the /etc/wsl.conf generated by the OOBE,
I think if this is not useful (which is not as we will use the API call), let’s not add it towsl.conf
anymore.
So yeah, let’s do one file maybe? If you prefer yaml or json, or just a keyfile, this is fine. Maybe one with action:
and one for extra info like user
. That way, that file becomes the communication handler between the rootfs (distro) and the laucher (windows)?
I’m surprised that terminate is not enough, there are one VM per WSL app, no? (Honest question, that may be implemented differently but we tried to decipher this some time ago with jibel and it seemed like it) |
Well, there is one VM per Windows user running WSL. When a user launches more than one instance, let's say one Ubuntu and one Alpine, they share the same VM and kernel. When we do In order to have the changes in |
Ah, that matches exactly what I read in the early days. However, we were not capable of seeing this in practice. Out of curiousity, I think jibel and I would be interested in how you discovered and tested this on an instance :) However, this is annoying that wsl.conf is not fully reread (as this is per application/rootfs) without shutting down the VM. Mind trying other parameter changes - still having one other application running, to ensure that the other parameters like interoperability and mount for instance - are taken into account? Otherwise, the whole reboot thingy has to be revisited. For instance, we modified the boot parameter and this was taken immediately into account after a --terminate / relaunching the application. I think this is worth exploring |
That is exactly what happens with network. Recently my instances are not getting DNS working at start when |
Just to make sure this is clear after our hangout and tests together (somebody may ask in the future and this will be documented)
I'll make sure to add checks with |
My understanding is that:
So it's correct to use |
- By reading the UID file left by the OOBE installer. - Still considering a more robust approach.
- A process runner runs `wsl --list --running --quiet` and checks if stdout contains this distro name. - A timeout is given to avoid the risk of running the launcher forever.
I'd appreciate if one of you guys could go over my last two commits in this branch/PR. Once we approve those, I intend to merge this and start a new one with the following objectives:
I did a interesting research yesterday which will allow adding libraries to this project without changing the project definition files, keeping the diff between our fork and upstream minimal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments :)
- Renamed the `timeoutSeconds` as `maxNoOfRetries`.
This looks good to me! Note that you have a conflict apparently in OOBE.h. Then, good to merge to me with your testing :) |
CreateProcess
unfortunately always throws error 87 for me so I used ShellExecute here.