Skip to content
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

automate fs share between host+guest #81

Open
nickdesaulniers opened this issue Dec 6, 2022 · 1 comment · May be fixed by #93
Open

automate fs share between host+guest #81

nickdesaulniers opened this issue Dec 6, 2022 · 1 comment · May be fixed by #93
Labels
enhancement New feature or request

Comments

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Dec 6, 2022

I know it's possible to create a 9p fs shared between guest and host. It would be awesome if we could automate the creation+reuse of such a fs when used with the -i flag.

@nathanchance also mentioned https://virtio-fs.gitlab.io/. If that works, then let's use that; the ends are more important to me than the means (so I don't care whether we ultimately use 9p or virtiofs). I'd like to be able to copy coverage and profile data out of a guest back to a host.

@nickdesaulniers nickdesaulniers added the enhancement New feature or request label Dec 6, 2022
@nickdesaulniers nickdesaulniers changed the title 9p fs to share between host+guest automate fs share between host+guest Dec 6, 2022
@nathanchance
Copy link
Member

nathanchance commented Dec 7, 2022

This is my implementation in my personal QEMU wrapper script:

nathanchance/env@71b7809

Basically, we start virtiofsd with the information about the shared folder then QEMU connects to it. virtiofsd should be readily available when QEMU is installed but it would be good to check, it is typically at /usr/libexec/virtiofsd.

If that looks acceptable, I can wire up similar support in here.

nathanchance added a commit to nathanchance/boot-utils that referenced this issue Dec 7, 2022
virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.

To use virtiofs, we first need to run virtiofsd, which is included with
most base QEMU packages. Once we find it, we run it in the background
and connect to it using some QEMU parameters, which were shamelessly
taken from the official virtiofs website:

https://virtio-fs.gitlab.io/howto-qemu.html

To use it within the guest (you can use a different path than
/mnt/shared but 'mount -t virtio shared' must be used):

  # mkdir /mnt/shared
  # mount -t virtiofs shared /mnt/shared
  # echo "$(uname -a)" >/mnt/shared/foo

On the host:

  $ cat shared/foo
  Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec  7 14:56:03 MST 2022 aarch64 GNU/Linux

This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise
it will not work inside the guest:

  / # mount -t virtiofs shared /mnt/shared
  mount: mounting shared on /mnt/shared failed: No such device

Link: ClangBuiltLinux#81
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
nathanchance added a commit to nathanchance/boot-utils that referenced this issue Dec 17, 2022
virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.

To use virtiofs, we first need to run virtiofsd, which is included with
most base QEMU packages. Once we find it, we run it in the background
and connect to it using some QEMU parameters, which were shamelessly
taken from the official virtiofs website:

https://virtio-fs.gitlab.io/howto-qemu.html

To use it within the guest (you can use a different path than
/mnt/shared but 'mount -t virtio shared' must be used):

  # mkdir /mnt/shared
  # mount -t virtiofs shared /mnt/shared
  # echo "$(uname -a)" >/mnt/shared/foo

On the host:

  $ cat shared/foo
  Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec  7 14:56:03 MST 2022 aarch64 GNU/Linux

This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise
it will not work inside the guest:

  / # mount -t virtiofs shared /mnt/shared
  mount: mounting shared on /mnt/shared failed: No such device

Link: ClangBuiltLinux#81
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
nathanchance added a commit to nathanchance/boot-utils that referenced this issue Feb 18, 2023
…rtiofs

virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.

To use virtiofs, we first need to run virtiofsd, which is included with
most base QEMU packages. Once we find it, we run it in the background
and connect to it using some QEMU parameters, which were shamelessly
taken from the official virtiofs website:

https://virtio-fs.gitlab.io/howto-qemu.html

To use it within the guest (you can use a different path than
/mnt/shared but 'mount -t virtio shared' must be used):

  # mkdir /mnt/shared
  # mount -t virtiofs shared /mnt/shared
  # echo "$(uname -a)" >/mnt/shared/foo

On the host:

  $ cat shared/foo
  Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec  7 14:56:03 MST 2022 aarch64 GNU/Linux

This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise
it will not work inside the guest:

  / # mount -t virtiofs shared /mnt/shared
  mount: mounting shared on /mnt/shared failed: No such device

Link: ClangBuiltLinux#81
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
nathanchance added a commit to nathanchance/boot-utils that referenced this issue Feb 21, 2023
…rtiofs

virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.

To use virtiofs, we first need to run virtiofsd, which is included with
most base QEMU packages. Once we find it, we run it in the background
and connect to it using some QEMU parameters, which were shamelessly
taken from the official virtiofs website:

https://virtio-fs.gitlab.io/howto-qemu.html

To use it within the guest (you can use a different path than
/mnt/shared but 'mount -t virtio shared' must be used):

  # mkdir /mnt/shared
  # mount -t virtiofs shared /mnt/shared
  # echo "$(uname -a)" >/mnt/shared/foo

On the host:

  $ cat shared/foo
  Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec  7 14:56:03 MST 2022 aarch64 GNU/Linux

This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise
it will not work inside the guest:

  / # mount -t virtiofs shared /mnt/shared
  mount: mounting shared on /mnt/shared failed: No such device

Link: ClangBuiltLinux#81
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
nathanchance added a commit to nathanchance/boot-utils that referenced this issue Feb 22, 2023
…rtiofs

virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.

To use virtiofs, we first need to run virtiofsd, which is included with
most base QEMU packages. Once we find it, we run it in the background
and connect to it using some QEMU parameters, which were shamelessly
taken from the official virtiofs website:

https://virtio-fs.gitlab.io/howto-qemu.html

To use it within the guest (you can use a different path than
/mnt/shared but 'mount -t virtio shared' must be used):

  # mkdir /mnt/shared
  # mount -t virtiofs shared /mnt/shared
  # echo "$(uname -a)" >/mnt/shared/foo

On the host:

  $ cat shared/foo
  Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec  7 14:56:03 MST 2022 aarch64 GNU/Linux

This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise
it will not work inside the guest:

  / # mount -t virtiofs shared /mnt/shared
  mount: mounting shared on /mnt/shared failed: No such device

Link: ClangBuiltLinux#81
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
nathanchance added a commit to nathanchance/boot-utils that referenced this issue Mar 13, 2023
…rtiofs

virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.

To use virtiofs, we first need to find and run virtiofsd, which has two
different implementations: a C implementation included with QEMU up until
8.0 (available on most distros) and a standalone Rust implementation
available on GitLab (not packaged on many distros but easy to build and
install). Once we find it, we run it in the background and connect to it
using some QEMU parameters, which were shamelessly taken from the
official virtiofs website:

https://virtio-fs.gitlab.io/howto-qemu.html

To use it within the guest (you can use a different path than
/mnt/shared but 'mount -t virtio shared' must be used):

  # mkdir /mnt/shared
  # mount -t virtiofs shared /mnt/shared
  # echo "$(uname -a)" >/mnt/shared/foo

On the host:

  $ cat shared/foo
  Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec  7 14:56:03 MST 2022 aarch64 GNU/Linux

This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise
it will not work inside the guest:

  / # mount -t virtiofs shared /mnt/shared
  mount: mounting shared on /mnt/shared failed: No such device

Closes: ClangBuiltLinux#81
Link: https://gitlab.com/virtio-fs/virtiofsd
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
nathanchance added a commit to nathanchance/boot-utils that referenced this issue Jul 12, 2023
…rtiofs

virtiofs, available in QEMU 5.2 or newer and Linux guests 5.4 or newer,
is a more modern way to pass local folders along to QEMU, as it takes
advantage of the fact that the folders are on the same machine as the
hypervisor.

To use virtiofs, we first need to find and run virtiofsd, which has two
different implementations: a C implementation included with QEMU up until
8.0 (available on most distros) and a standalone Rust implementation
available on GitLab (not packaged on many distros but easy to build and
install). Once we find it, we run it in the background and connect to it
using some QEMU parameters, which were shamelessly taken from the
official virtiofs website:

https://virtio-fs.gitlab.io/howto-qemu.html

To use it within the guest (you can use a different path than
/mnt/shared but 'mount -t virtio shared' must be used):

  # mkdir /mnt/shared
  # mount -t virtiofs shared /mnt/shared
  # echo "$(uname -a)" >/mnt/shared/foo

On the host:

  $ cat shared/foo
  Linux (none) 6.1.0-rc8-next-20221207 ClangBuiltLinux#2 SMP PREEMPT Wed Dec  7 14:56:03 MST 2022 aarch64 GNU/Linux

This does require guest kernel support (CONFIG_VIRTIO_FS=y), otherwise
it will not work inside the guest:

  / # mount -t virtiofs shared /mnt/shared
  mount: mounting shared on /mnt/shared failed: No such device

Closes: ClangBuiltLinux#81
Link: https://gitlab.com/virtio-fs/virtiofsd
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants