unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#39815: Sharing the store between a host and a guest
@ 2020-02-27 20:28 Damien Cassou
  2020-02-27 20:33 ` raingloom
  2020-02-28  6:50 ` Damien Cassou
  0 siblings, 2 replies; 7+ messages in thread
From: Damien Cassou @ 2020-02-27 20:28 UTC (permalink / raw)
  To: 39815

Hi,

`guix system vm` generates a VM which shares /gnu/store with the
host. However, the share is done read-only.  The info pages recommends
copying the VM image and making it writable.

Is it possible/recommended to get a writable and shared /gnu/store in
the VM?

Best,

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#39815: Sharing the store between a host and a guest
  2020-02-27 20:28 bug#39815: Sharing the store between a host and a guest Damien Cassou
@ 2020-02-27 20:33 ` raingloom
  2020-02-28  6:50 ` Damien Cassou
  1 sibling, 0 replies; 7+ messages in thread
From: raingloom @ 2020-02-27 20:33 UTC (permalink / raw)
  To: 39815

Would have to share the connection with the Guix daemon. The VM would 
see the changes but it could write to the store directly. But that's 
effectively what you want. When you use guix as a user, the guix 
command doesn't write to the store, it tells the daemon to do things. 
Same deal here.

On Thu, Feb 27, 2020 at 21:28, Damien Cassou <damien@cassou.me> wrote:
> Hi,
> 
> `guix system vm` generates a VM which shares /gnu/store with the
> host. However, the share is done read-only.  The info pages recommends
> copying the VM image and making it writable.
> 
> Is it possible/recommended to get a writable and shared /gnu/store in
> the VM?
> 
> Best,
> 
> --
> Damien Cassou
> 
> "Success is the ability to go from one failure to another without
> losing enthusiasm." --Winston Churchill
> 
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#39815: Sharing the store between a host and a guest
  2020-02-27 20:28 bug#39815: Sharing the store between a host and a guest Damien Cassou
  2020-02-27 20:33 ` raingloom
@ 2020-02-28  6:50 ` Damien Cassou
  2020-02-28 21:07   ` Leo Famulari
  1 sibling, 1 reply; 7+ messages in thread
From: Damien Cassou @ 2020-02-28  6:50 UTC (permalink / raw)
  To: 39815

Hi,

I kept experimenting. I can't manage to install anything in the VM:

$ guix pull
Updating channel 'guix' from Git repository at 'file:///home/cassou/...'
guix pull: error: Git error: failed to mmap. Could not write data:
Invalid argument

The folder at 'file:///home/cassou/...' contains a git clone of Guix
repository and the VM has read-write access to it.

$ mount | grep /gnu/store
/dev/vda1 on /gnu/store type ext4 (ro,relatime)

I don't understand why /gnu/store is mounted read-only. Also, I haven't
done that myself.

$ cat ./build-vm.sh
#!/bin/sh

FILE=$(guix system vm-image ./current.scm --save-provenance --image-size=6G --share=/home/cassou=/mnt/host-home)

cp -f "$FILE" ./image.qcow2

$ cat ./start-vm.sh
#!/bin/sh

qemu-system-x86_64 \
    -nic user,model=virtio-net-pci \
    -enable-kvm \
    -m 4G \
    -device virtio-blk,drive=myhd \
    -drive if=none,file=./image.qcow2,id=myhd \
    -virtfs local,path="/home/cassou",security_model=none,mount_tag="host-home" \
    -virtfs local,path="./share/home",security_model=none,mount_tag="guest-home"


As you can see, I'm not even trying to share the store. Moreover, I
think the --share option passed to `guix system vm-image` above doesn't
do anything. If it is the case, I would expect the command to complain
about the unknown parameter.

Can anyone please give me a clue as to what is happening and why? Is
there a way I can install applications in my VM?

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#39815: Sharing the store between a host and a guest
  2020-02-28  6:50 ` Damien Cassou
@ 2020-02-28 21:07   ` Leo Famulari
  2020-02-29 14:11     ` Damien Cassou
  2020-03-08 22:16     ` Ludovic Courtès
  0 siblings, 2 replies; 7+ messages in thread
From: Leo Famulari @ 2020-02-28 21:07 UTC (permalink / raw)
  To: Damien Cassou; +Cc: 39815

Hi Damien,

Currently Guix does not include tools to support your use case of
"writable and shared /gnu/store in the VM".

`guix system container` might be useful but the isolation guarantees are
weaker than with QEMU. However, QEMU is not bulletproof either.

The recommended way to get a writeable store in a VM is to use `guix
system vm-image`, copy the image out of /gnu/store, make it writeable
with `chmod`, and then run it in QEMU. This will not share the store
with the host.

As you found, what you get with `guix system vm` is read-only. Even
though you copied build-vm.sh out of /gnu/store, it is just a shell
script that refers to immutable data in the host /gnu/store.

In order to share the store with a VM, you would need to also share the
store database — at least /var/guix/db if not all of /var/guix — and
also use the host's guix-daemon.

It would be great to support your use case but I don't think anyone has
worked on it yet.

Leo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#39815: Sharing the store between a host and a guest
  2020-02-28 21:07   ` Leo Famulari
@ 2020-02-29 14:11     ` Damien Cassou
  2020-03-08 22:16     ` Ludovic Courtès
  1 sibling, 0 replies; 7+ messages in thread
From: Damien Cassou @ 2020-02-29 14:11 UTC (permalink / raw)
  To: Leo Famulari; +Cc: 39815

Hi Léo,

Leo Famulari <leo@famulari.name> writes:
> Currently Guix does not include tools to support your use case of
> "writable and shared /gnu/store in the VM" […]

Thank you very much for your extensive explanation. I understand things
better now.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#39815: Sharing the store between a host and a guest
  2020-02-28 21:07   ` Leo Famulari
  2020-02-29 14:11     ` Damien Cassou
@ 2020-03-08 22:16     ` Ludovic Courtès
  2020-03-09 13:00       ` Damien Cassou
  1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2020-03-08 22:16 UTC (permalink / raw)
  To: Leo Famulari; +Cc: Damien Cassou, 39815

Hi!

Leo Famulari <leo@famulari.name> skribis:

> As you found, what you get with `guix system vm` is read-only. Even
> though you copied build-vm.sh out of /gnu/store, it is just a shell
> script that refers to immutable data in the host /gnu/store.
>
> In order to share the store with a VM, you would need to also share the
> store database — at least /var/guix/db if not all of /var/guix — and
> also use the host's guix-daemon.
>
> It would be great to support your use case but I don't think anyone has
> worked on it yet.

Unfortunately, the Unix-domain socket in /var/guix/daemon-socket cannot
be shared over 9p AFAICS (with ‘guix system vm --expose’).

However, one thing that could work is to:

  1. in the guest, set GUIX_DAEMON_SOCKET=guix://localhost:1234;

  2. set up QEMU port forwarding such that the guest’s port 1234 is
     somehow redirected to a port the host guix-daemon listens to (with
     ‘--listen’);

  3. share /var/guix with the guest.

It would be easier if Unix-domain sockets could be forwarded between the
host and the guest, but that doesn’t seem to be the case.  :-/

Ludo’.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#39815: Sharing the store between a host and a guest
  2020-03-08 22:16     ` Ludovic Courtès
@ 2020-03-09 13:00       ` Damien Cassou
  0 siblings, 0 replies; 7+ messages in thread
From: Damien Cassou @ 2020-03-09 13:00 UTC (permalink / raw)
  To: Ludovic Courtès, Leo Famulari; +Cc: 39815

Ludovic Courtès <ludo@gnu.org> writes:
> However, one thing that could work is to:
>
>   1. in the guest, set GUIX_DAEMON_SOCKET=guix://localhost:1234;
>
>   2. set up QEMU port forwarding such that the guest’s port 1234 is
>      somehow redirected to a port the host guix-daemon listens to (with
>      ‘--listen’);
>
>   3. share /var/guix with the guest.
>
> It would be easier if Unix-domain sockets could be forwarded between the
> host and the guest, but that doesn’t seem to be the case.  :-/

thank you Ludovic.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-09 13:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-27 20:28 bug#39815: Sharing the store between a host and a guest Damien Cassou
2020-02-27 20:33 ` raingloom
2020-02-28  6:50 ` Damien Cassou
2020-02-28 21:07   ` Leo Famulari
2020-02-29 14:11     ` Damien Cassou
2020-03-08 22:16     ` Ludovic Courtès
2020-03-09 13:00       ` Damien Cassou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).