Skip to content

Conversation

Saviq
Copy link
Collaborator

@Saviq Saviq commented Oct 7, 2020

No description provided.

@Saviq Saviq requested a review from ricab October 7, 2020 10:54
Copy link
Collaborator

@ricab ricab left a 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?

@Saviq
Copy link
Collaborator Author

Saviq commented Oct 7, 2020

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.

Copy link
Collaborator

@ricab ricab left a 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.

@Saviq Saviq changed the title [daemon] add MULTIPASS_STORAGE support (Fixes #1215) [daemon] add MULTIPASS_STORAGE support (Fixes: #1215) Oct 7, 2020
@Saviq Saviq changed the title [daemon] add MULTIPASS_STORAGE support (Fixes: #1215) [daemon] add MULTIPASS_STORAGE support (Fixes #1215) Oct 7, 2020
@Saviq Saviq force-pushed the support-multipass-storage branch from 1939cbb to d1511c7 Compare October 7, 2020 14:23
Copy link
Collaborator Author

@Saviq Saviq left a 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.

@Saviq Saviq force-pushed the support-multipass-storage branch from d1511c7 to 8d1a034 Compare October 7, 2020 14:36
@codecov
Copy link

codecov bot commented Oct 7, 2020

Codecov Report

Merging #1789 into master will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
include/multipass/process/qemuimg_process_spec.h 100.00% <ø> (ø)
src/daemon/daemon.cpp 32.99% <100.00%> (ø)
src/daemon/daemon_config.cpp 65.38% <100.00%> (+5.11%) ⬆️
...c/platform/backends/shared/linux/backend_utils.cpp 83.14% <100.00%> (ø)
src/process/qemuimg_process_spec.cpp 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9a7264...f2456c7. Read the comment docs.

@Saviq
Copy link
Collaborator Author

Saviq commented Oct 7, 2020

I'll write down exactly what needs doing on each platform later today.

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

@Saviq
Copy link
Collaborator Author

Saviq commented Oct 8, 2020

I'll write down exactly what needs doing on each platform later today.

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

@Saviq
Copy link
Collaborator Author

Saviq commented Oct 8, 2020

I'll write down exactly what needs doing on each platform later today.

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

@Saviq
Copy link
Collaborator Author

Saviq commented Oct 8, 2020

macOS build available: multipass-1.5.0-dev.358.pr1789+g3b3183e9.mac-Darwin.pkg
Linux build available: snap refresh multipass --channel edge/pr1789
Windows build available: multipass-1.5.0-dev.358.pr1789+g3b3183e9.win-win64.exe

Copy link
Collaborator

@ricab ricab left a 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]>
@Saviq Saviq force-pushed the support-multipass-storage branch from 19cfd19 to dc256bb Compare October 8, 2020 12:03
@Saviq Saviq force-pushed the support-multipass-storage branch from dc256bb to 97a70c3 Compare October 8, 2020 12:57
Copy link
Contributor

@townsend2010 townsend2010 left a 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?

Copy link
Collaborator

@ricab ricab left a 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+

@bors
Copy link
Contributor

bors bot commented Oct 8, 2020

✌️ Saviq can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

Co-authored-by: Ricardo Abreu <[email protected]>
@Saviq
Copy link
Collaborator Author

Saviq commented Oct 8, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 8, 2020

Build failed:

@Saviq Saviq merged commit 0e74ed7 into master Oct 8, 2020
@bors bors bot deleted the support-multipass-storage branch October 8, 2020 19:12
@fsevenm
Copy link

fsevenm commented Feb 23, 2021

I'll write down exactly what needs doing on each platform later today.

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

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?

@valentinmk
Copy link

@fsevenm
First check logs with journalctl -au snap.multipass*
In my case I had
multipassd[3453]: Caught an unhandled exception: unable to create directory '/media/sdb1/multipass-volumes/cache'
Reason:
I created this directory and chown'ed it with current user. After I revert chown to root user I was able to start Multipass w/o errors.

@fsevenm
Copy link

fsevenm commented May 6, 2021

@valentinmk Ok, noted. Thanks. Btw I ended up building multipass from source and it was working.

@jj-owens
Copy link

jj-owens commented Sep 6, 2022

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!

@pacozaa
Copy link

pacozaa commented Nov 20, 2022

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.

@erlangparasu
Copy link

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

@ricab
Copy link
Collaborator

ricab commented Nov 23, 2022

Hi @pacozaa, @erlangparasu, we haven't got around to writing "official" documentation for MULTIPASS_STORAGE yet because we regard it rather as a temporary measure, until we implement a proper setting. That is probably going to take a while though, so you are right that we should put something up in the docs. In the meantime, you can find instructions for each of the platforms buried above in this thread: Linux, macOS, Windows.

@pacozaa
Copy link

pacozaa commented Nov 24, 2022

@ricab Hi, thank you so much for replying with such kindness. I really appreciate it.

Just for confirmation, I can do
export MULTIPASS_STORAGE=[absolute path to the location]

and follow the thread above? Is that correct?

@ricab
Copy link
Collaborator

ricab commented Nov 24, 2022

Hey @pacozaa, you're welcome!

Just for confirmation, I can do
export MULTIPASS_STORAGE=[absolute path to the location]

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
Copy link

pacozaa commented Nov 24, 2022

@ricab Ahh for macOS, it's the line /bin/launchctl setenv MULTIPASS_STORAGE "<path>".

I will change "<path>" to the location I want then. Thank you so much.

@Saviq
Copy link
Collaborator Author

Saviq commented Nov 24, 2022

it's the line /bin/launchctl setenv MULTIPASS_STORAGE "<path>".

I will change "<path>" to the location I want then. Thank you so much.

@pacozaa note this doesn't survive reboots, which is why there's the plist service that sets it on boot.

@pacozaa
Copy link

pacozaa commented Nov 26, 2022

macOS build available: multipass-1.5.0-dev.358.pr1789+g3b3183e9.mac-Darwin.pkg Linux build available: snap refresh multipass --channel edge/pr1789 Windows build available: multipass-1.5.0-dev.358.pr1789+g3b3183e9.win-win64.exe

I can't download this from the link for macOS. I got XML <Code>AccessDenied</Code> from aws s3.

@Saviq Is it available for the public yet?

@Saviq
Copy link
Collaborator Author

Saviq commented Nov 26, 2022

@Saviq Is it available for the public yet?

It's on stable.

@pacozaa
Copy link

pacozaa commented Nov 26, 2022

@Saviq How do I download it? I tried to switch the branch to stable and here https://github.com/canonical/multipass/releases
I still can't find a way to download it. Or Do I need to build stable from the source on my machine?

@Saviq
Copy link
Collaborator Author

Saviq commented Nov 26, 2022

@Saviq How do I download it? I tried to switch the branch to stable and here https://github.com/canonical/multipass/releases
I still can't find a way to download it. Or Do I need to build stable from the source on my machine?

https://multipass.run/docs/installing-on-macos

@pacozaa
Copy link

pacozaa commented Nov 27, 2022

@Saviq How do I download it? I tried to switch the branch to stable and here https://github.com/canonical/multipass/releases
I still can't find a way to download it. Or Do I need to build stable from the source on my machine?

https://multipass.run/docs/installing-on-macos

I tried this one but it doesn't install 1.5.0 version for me.

Here is a list of what I tried
brew install --cask [email protected]
brew install --cask [email protected]
brew install --cask multipass@stable

All of them don't work for me. Maybe @ricab Would you mind helping out? Thank you guys a lot.

@Saviq
Copy link
Collaborator Author

Saviq commented Nov 27, 2022

@pacozaa why are you trying to install an old version? Just use the latest. It didn't lose support for the storage variable…

@pacozaa
Copy link

pacozaa commented Nov 27, 2022

@Saviq Sorry I thought 1.5.0 is newer than 1.10.0. All good now. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add configure option to use different vault location
9 participants