-
Notifications
You must be signed in to change notification settings - Fork 725
[daemon] add MULTIPASS_STORAGE support (Fixes #1215) #1789
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
Conversation
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 need to look a bit deeper, but some things I can ask already: how do you see users interfacing with this on Windows and macOS? Would we just communicate it as a stop-gap measure and give them a recipe to manually edit how the daemon is launched? Ask them to launch manually? Or would we do something in installers? How did you test it in each platform?
Yes, we'd document how to set this variable on each platform. System variables on Windows, launchd on macOS and systemd on Linux. I'll write down exactly what needs doing on each platform later today. |
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 questions about robustness in error cases and a couple of suggestions for portability.
1939cbb
to
d1511c7
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.
Some questions about robustness in error cases and a couple of suggestions for portability.
I kinda beat two chickens with the same stone now.
d1511c7
to
8d1a034
Compare
Codecov Report
@@ Coverage Diff @@
## master #1789 +/- ##
==========================================
+ Coverage 76.70% 76.74% +0.04%
==========================================
Files 229 229
Lines 8464 8472 +8
==========================================
+ Hits 6492 6502 +10
+ Misses 1972 1970 -2
Continue to review full report at Codecov.
|
For snap: # as root
$ snap stop multipass
$ snap connect multipass:removable-media # for /mnt /media https://snapcraft.io/docs/removable-media-interface
$ snap connect multipass:all-home # for /home/* https://snapcraft.io/docs/home-interface
$ mkdir -p <path>
$ mkdir /etc/systemd/system/snap.multipass.multipassd.service.d/
$ tee /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf <<EOF
[Service]
Environment=MULTIPASS_STORAGE=<path>
EOF
$ systemctl daemon-reload
$ snap start multipass |
for macOS: # as root
$ launchctl stop /Library/LaunchDaemons/com.canonical.multipassd.plist
$ tee /Library/LaunchDaemons/setenv.MULTIPASS_STORAGE.plist <<\EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>setenv.MULTIPASS_STORAGE</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>
if [ -z "$( /bin/launchctl getenv MULTIPASS_STORAGE )" ]; then
/bin/launchctl setenv MULTIPASS_STORAGE "<path>"
/bin/launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
/bin/launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist
fi
</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
$ launchctl load /Library/LaunchDaemons/setenv.MULTIPASS_STORAGE.plist |
for Windows: # In Administrator's PowerShell
PS> Stop-Service Multipass
PS> Set-ItemProperty -Path "HKLM:System\CurrentControlSet\Control\Session Manager\Environment" -Name MULTIPASS_STORAGE -Value "<path>"
PS> Start-Service Multipass |
macOS build available: multipass-1.5.0-dev.358.pr1789+g3b3183e9.mac-Darwin.pkg |
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.
Thanks for clarifications and updates. I am still testing, so far it looks good. Meanwhile just a suggestion for a small tweak.
Co-authored-by: Ricardo Abreu <[email protected]>
19cfd19
to
dc256bb
Compare
dc256bb
to
97a70c3
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.
Would it require a lot of effort to test the changes in daemon_config.cpp
to increase the coverage?
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.
Nice, thanks for the fixmes and tests. I'm proposing a little cleanup batch for the copy-pasta in tests, but approving already.
It may be worth mentioning somewhere that uninstallers won't remove data in folders configured this way. And the command to revert the windows var:
Remove-ItemProperty -Path "HKLM:System\CurrentControlSet\Control\Session Manager\Environment" -Name MULTIPASS_STORAGE
Successfully tested with a home dir on:
- linux: qemu, libvirt
- macOS: hyperkit, virtualbox
- windows: hyperv, virtualbox
bors d+
✌️ Saviq can now approve this pull request. To approve and merge a pull request, simply reply with |
Co-authored-by: Ricardo Abreu <[email protected]>
bors r+ |
Build failed: |
I got errors after trying this on Ubuntu 18.04. Snapcraft cannot find the socket. ❯ snapcraft
Launching a VM.
Build environment is in unknown state, cleaning first.
info failed: cannot connect to the multipass socket
Please ensure multipassd is running and '/var/snap/multipass/common/multipass_socket' is accessible
launch failed: cannot connect to the multipass socket
Please ensure multipassd is running and '/var/snap/multipass/common/multipass_socket' is accessible
An error occurred with the instance when trying to launch with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again. ❯ ls /var/snap/multipass/common/multipass_socket
ls: cannot access '/var/snap/multipass/common/multipass_socket': No such file or directory ❯ sudo systemctl status snap.multipass.multipassd
● snap.multipass.multipassd.service - Service for snap application multipass.multipassd
Loaded: loaded (/etc/systemd/system/snap.multipass.multipassd.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/snap.multipass.multipassd.service.d
└─override.conf
Active: failed (Result: exit-code) since Wed 2021-02-24 06:45:45 WITA; 26s ago
Process: 623 ExecStart=/usr/bin/snap run multipass.multipassd (code=exited, status=1/FAILURE)
Main PID: 623 (code=exited, status=1/FAILURE)
Feb 24 06:45:45 fsevenm systemd[1]: snap.multipass.multipassd.service: Service hold-off time over, scheduling restart.
Feb 24 06:45:45 fsevenm systemd[1]: snap.multipass.multipassd.service: Scheduled restart job, restart counter is at 5.
Feb 24 06:45:45 fsevenm systemd[1]: Stopped Service for snap application multipass.multipassd.
Feb 24 06:45:45 fsevenm systemd[1]: snap.multipass.multipassd.service: Start request repeated too quickly.
Feb 24 06:45:45 fsevenm systemd[1]: snap.multipass.multipassd.service: Failed with result 'exit-code'.
Feb 24 06:45:45 fsevenm systemd[1]: Failed to start Service for snap application multipass.multipassd. Any help? |
@fsevenm |
@valentinmk Ok, noted. Thanks. Btw I ended up building multipass from source and it was working. |
I ran into an issue with this as posted here: https://stackoverflow.com/q/71506189/7834131, but was able to figure out the reason the instance generation was failing. Hope this helps anyone who runs into the same issue, and apologies if this should be better shared somewhere else. If so please let me know. Thanks! |
Can anyone write a manual/official documentation/article about using MULTIPASS_STORAGE and some explanation, please? I read through this issue but don't understand what concrete action I need to take to set VM location path to my external harddisk. |
any info? @Saviq |
Hi @pacozaa, @erlangparasu, we haven't got around to writing "official" documentation for |
@ricab Hi, thank you so much for replying with such kindness. I really appreciate it. Just for confirmation, I can do and follow the thread above? Is that correct? |
Hey @pacozaa, you're welcome!
Not exactly. That would set the variable only in the shell you entered it in, along with its children. You need it to be set in the environment that the Multipass daemon gets when it is started. That is what the recipes above are for. So you don't need to set the variable in a shell. |
@pacozaa note this doesn't survive reboots, which is why there's the plist service that sets it on boot. |
I can't download this from the link for macOS. I got XML @Saviq Is it available for the public yet? |
It's on stable. |
@Saviq How do I download it? I tried to switch the branch to stable and here https://github.com/canonical/multipass/releases |
|
I tried this one but it doesn't install 1.5.0 version for me. Here is a list of what I tried All of them don't work for me. Maybe @ricab Would you mind helping out? Thank you guys a lot. |
@pacozaa why are you trying to install an old version? Just use the latest. It didn't lose support for the storage variable… |
@Saviq Sorry I thought 1.5.0 is newer than 1.10.0. All good now. Thanks again. |
No description provided.