flathub / org.gnome.Boxes

https://flathub.org/apps/details/org.gnome.Boxes
13 stars 10 forks source link

allowing boxes to be provisioned with system-wide visibility #81

Open brainchild0 opened 1 year ago

brainchild0 commented 1 year ago

I am not experienced in the details of FlatPak, and realize that applications operate with very particular limitations in system access.

Yet, I have wondered whether it would be possible for the FlatPak distribution of Boxes to support the creation and use of VMs that are accessible to all users on a system, rather than storing the images and manifest beneath the user's home.

sidt4 commented 8 months ago

Yes, this can be made available in GNOME Boxes (including non-flatpak version). For now, you can follow the steps below to achieve this.

GNOME Boxes (flatpak) locations:

GNOME Boxes (flatpak) stores all its per-user config and data in /home/$USER/.var/app/org.gnome.Boxes/ as shown below:

$ cd ~/.var/app/org.gnome.Boxes/

$ ls -l
total 12
drwxr-xr-x 8 sid sid 4096 Dec 22 20:39 cache
drwxr-xr-x 6 sid sid 4096 Dec 21 20:48 config
drwxr-xr-x 3 sid sid 4096 Dec 21 20:05 data

Primary among those are:

data - VM Disk images are stored in dir data/gnome-boxes/images/ config - libvirt config is stored in dir config/libvirt/ config - gnome-boxes config is stored in dir config/gnome-boxes/

GNOME Boxes sharing between users:

You have 2 options:

  1. You can try adding a common location (say /shared/ dir ) which is accessible to all users and symlink to the dirs listed above, and specify --filesystem=/shared/ as argument to flatpak run command.
  2. You can just create a VM for user2 and shutdown after ISO boot ( without doing the full install ), and edit the config to point to the disk image of user1 ( as shown below ):

E.g. If you want to share a debian-12 VM created by user1 with user2, login to user2 and create a VM with debian-12 ISO image. When the ISO install boot menu is displayed, shutdown the VM.

Run the following commands in user2 session:

$ flatpak run --command=sh --devel org.gnome.Boxes//stable

You are now inside the gnome-boxes flatpak env. Now get the list of all VMs created by user2

$ virsh list --all

Now, edit the config to point to the debian-12 disk image from user1 home dir.

$ virsh edit debian-12-vm  # VM name from above command

This would require that disk image dir permissions be adjusted accordingly.